From b156dc7b2098f0408a9749668d15303ca33d09c2 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 24 Sep 2026 07:06:05 +0000 Subject: [PATCH 1/2] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-typescript-sdk: 3.35.8 --- .fern/metadata.json | 1 + .fern/replay.lock | 10 + .fernignore | 4 +- .gitattributes | 1 + .github/workflows-disabled/ci.yml | 76 - README.md | 43 + package.json | 4 +- pnpm-lock.yaml | 692 +- reference.md | 12341 +++++++++++--- src/BaseClient.ts | 8 +- src/Client.ts | 28 +- src/api/resources/admins/client/Client.ts | 21 +- .../client/requests/ListAdminsRequest.ts | 12 + .../resources/admins/client/requests/index.ts | 1 + src/api/resources/admins/types/index.ts | 2 +- .../admins/types/{Admin.ts => types.ts} | 0 src/api/resources/aiAgent/types/index.ts | 2 +- .../aiAgent/types/{AiAgent.ts => types.ts} | 0 .../aiContent/types/ContentImportSource.ts | 39 - .../types/ContentImportSourcesList.ts | 16 - .../resources/aiContent/types/ExternalPage.ts | 35 - .../aiContent/types/ExternalPagesList.ts | 16 - src/api/resources/aiContent/types/index.ts | 5 +- src/api/resources/aiContent/types/types.ts | 103 + .../resources/aiContentSource/types/index.ts | 2 +- .../types/{ContentSource.ts => types.ts} | 0 src/api/resources/articles/client/Client.ts | 8 + .../client/requests/UpdateArticleRequest.ts | 4 +- src/api/resources/articles/types/Article.ts | 10 - .../articles/types/ArticleListItem.ts | 49 - .../articles/types/ArticleSearchHighlights.ts | 61 - .../articles/types/ArticleSearchResponse.ts | 28 - .../articles/types/InternalArticle.ts | 8 - src/api/resources/articles/types/index.ts | 6 +- src/api/resources/articles/types/types.ts | 147 + .../awayStatusReasons/client/Client.ts | 6 +- .../types/ListCallsWithTranscriptsResponse.ts | 21 - src/api/resources/calls/types/index.ts | 3 +- .../calls/types/{Call.ts => types.ts} | 18 + src/api/resources/companies/client/Client.ts | 10 +- .../types/CompaniesRetrieveResponse.ts | 17 - src/api/resources/companies/types/index.ts | 3 +- .../companies/types/{Company.ts => types.ts} | 16 +- src/api/resources/contacts/client/Client.ts | 83 +- .../client/requests/MergeContactsRequest.ts | 4 +- .../client/requests/UpdateContactRequest.ts | 4 +- .../contacts/types/ContactsCreateResponse.ts | 8 - .../contacts/types/ContactsFindResponse.ts | 8 - .../types/ContactsMergeLeadInUserResponse.ts | 8 - .../contacts/types/ContactsUpdateResponse.ts | 8 - .../types/ShowContactByExternalIdResponse.ts | 8 - src/api/resources/contacts/types/index.ts | 7 +- .../contacts/types/{Contact.ts => types.ts} | 45 +- .../resources/conversations/client/Client.ts | 52 +- .../requests/CreateConversationRequest.ts | 4 + .../conversations/types/Conversation.ts | 67 - .../types/ConversationsManageRequestBody.ts | 27 - .../resources/conversations/types/index.ts | 3 +- .../resources/conversations/types/types.ts | 150 + .../customChannelEvents/client/Client.ts | 423 - .../NotifyAttributeCollectedRequest.ts | 22 - .../requests/NotifyNewMessageRequest.ts | 20 - .../NotifyQuickReplySelectedRequest.ts | 22 - .../client/requests/index.ts | 3 - .../customObjectInstances/types/index.ts | 2 +- .../{CustomObjectInstance.ts => types.ts} | 0 .../types/DataAttributesListRequestModel.ts | 9 - .../resources/dataAttributes/types/index.ts | 3 +- .../types/{DataAttribute.ts => types.ts} | 8 + src/api/resources/dataEvents/types/index.ts | 2 +- .../types/{DataEvent.ts => types.ts} | 2 +- src/api/resources/dataExport/client/Client.ts | 4 +- .../DataExportExportReportingDataResponse.ts | 8 - src/api/resources/dataExport/types/index.ts | 3 +- .../types/{DataExport.ts => types.ts} | 9 +- .../PostExportReportingDataEnqueueResponse.ts | 8 - src/api/resources/export/types/index.ts | 2 - src/api/resources/finAgent/client/Client.ts | 418 + .../client/index.ts | 0 .../client/requests/ReplyToFinRequest.ts | 77 + .../requests/StartFinConversationRequest.ts | 117 + .../client/requests/SubmitFinCsatRequest.ts | 36 + .../finAgent/client/requests/index.ts | 3 + .../resources/{export => finAgent}/index.ts | 0 src/api/resources/finAgent/types/index.ts | 1 + src/api/resources/finAgent/types/types.ts | 387 + .../resources/helpCenter/types/HelpCenter.ts | 25 - .../helpCenter/types/HelpCenterList.ts | 13 - src/api/resources/helpCenter/types/index.ts | 4 +- .../types/{Collection.ts => types.ts} | 34 + src/api/resources/index.ts | 13 +- .../types/InternalArticleListItem.ts | 25 - .../types/InternalArticleSearchResponse.ts | 26 - .../resources/internalArticles/types/index.ts | 3 +- .../types/types.ts} | 25 + src/api/resources/jobs/types/index.ts | 2 +- .../jobs/types/{Jobs.ts => types.ts} | 0 src/api/resources/messages/types/index.ts | 2 +- .../messages/types/{Message.ts => types.ts} | 0 src/api/resources/news/types/Newsfeed.ts | 19 - .../news/types/NewsfeedAssignment.ts | 11 - src/api/resources/news/types/index.ts | 4 +- .../news/types/{NewsItem.ts => types.ts} | 42 +- src/api/resources/notes/types/index.ts | 2 +- .../notes/types/{Note.ts => types.ts} | 0 .../{unstable => preview}/client/Client.ts | 124 +- .../{unstable => preview}/client/index.ts | 0 .../errors/BadRequestError.ts | 0 .../errors/ConflictError.ts | 2 +- .../errors/ForbiddenError.ts | 2 +- src/api/resources/preview/errors/GoneError.ts | 17 + .../errors/InternalServerError.ts | 2 +- .../preview/errors/MethodNotAllowedError.ts | 17 + .../errors/NotFoundError.ts | 0 .../preview/errors/ServiceUnavailableError.ts | 17 + .../errors/TooManyRequestsError.ts | 2 +- .../errors/UnauthorizedError.ts | 2 +- .../errors/UnprocessableEntityError.ts | 0 .../{unstable => preview}/errors/index.ts | 3 + .../resources/{unstable => preview}/index.ts | 0 .../preview/resources/admins/client/Client.ts | 678 + .../resources/admins}/client/index.ts | 0 .../requests/ListActivityLogsRequest.ts | 0 .../client/requests/ListAdminsRequest.ts | 12 + .../client/requests/RemoveAdminRequest.ts | 30 + .../client/requests/RetrieveAdminRequest.ts | 0 .../requests/SearchActivityLogsRequest.ts | 28 + .../client/requests/SetAwayAdminRequest.ts | 0 .../resources/admins/client/requests/index.ts | 3 + .../resources/admins/index.ts | 0 .../preview/resources/admins/types/index.ts | 1 + .../preview/resources/admins/types/types.ts | 71 + .../resources/aiAgent/index.ts | 0 .../preview/resources/aiAgent/types/index.ts | 1 + .../resources/aiAgent/types/types.ts} | 2 +- .../resources/aiContent/client/Client.ts | 191 +- .../resources/aiContent}/client/index.ts | 0 .../CreateContentImportSourceRequest.ts | 6 + .../requests/CreateExternalPageRequest.ts | 2 + .../DeleteContentImportSourceRequest.ts | 0 .../requests/DeleteExternalPageRequest.ts | 0 .../requests/GetContentImportSourceRequest.ts | 0 .../client/requests/GetExternalPageRequest.ts | 0 .../UpdateContentImportSourceRequest.ts | 8 + .../requests/UpdateExternalPageRequest.ts | 8 +- .../aiContent/client/requests/index.ts | 0 .../resources/aiContent/index.ts | 0 .../resources/aiContent/types/index.ts | 1 + .../resources/aiContent/types/types.ts | 105 + .../resources/aiContentSource/index.ts | 0 .../resources/aiContentSource/types/index.ts | 1 + .../resources/aiContentSource/types/types.ts} | 1 + .../preview/resources/aiTopics/index.ts | 1 + .../preview/resources/aiTopics/types/index.ts | 1 + .../preview/resources/aiTopics/types/types.ts | 13 + .../resources/articles/client/Client.ts | 1090 ++ .../resources/articles}/client/index.ts | 0 .../requests/AttachTagToArticleRequest.ts | 17 + .../client/requests/DeleteArticleRequest.ts | 0 .../requests/DetachTagFromArticleRequest.ts | 15 + .../requests/FindArticleVersionRequest.ts | 18 + .../requests/ListArticleVersionsRequest.ts | 21 + .../requests/PublishArticleDraftRequest.ts | 18 + .../requests/RetrieveArticleDraftRequest.ts | 12 + .../client/requests/RetrieveArticleRequest.ts | 0 .../client/requests/SearchArticlesRequest.ts | 0 .../requests/StageArticleDraftRequest.ts | 19 + .../articles/client/requests/index.ts | 10 + .../resources/articles/index.ts | 0 .../preview/resources/articles/types/index.ts | 1 + .../preview/resources/articles/types/types.ts | 259 + .../resources/audiences}/client/Client.ts | 318 +- .../resources/audiences}/client/index.ts | 0 .../client/requests/CreateAudienceRequest.ts | 30 + .../client/requests/DeleteAudienceRequest.ts} | 6 +- .../client/requests/ListAudiencesRequest.ts | 15 + .../requests/RetrieveAudienceRequest.ts | 12 + .../client/requests/UpdateAudienceRequest.ts | 27 + .../audiences/client/requests/index.ts | 5 + .../resources/audiences}/index.ts | 0 .../resources/audiences/types/index.ts | 1 + .../resources/audiences/types/types.ts | 23 + .../resources/authTokens/client/Client.ts | 366 + .../resources/authTokens}/client/index.ts | 0 .../client/requests/CreateAuthTokenRequest.ts | 27 + .../client/requests/ListAuthTokensRequest.ts | 15 + .../requests/RetrieveAuthTokenRequest.ts | 12 + .../client/requests/UpdateAuthTokenRequest.ts | 24 + .../authTokens/client/requests/index.ts | 4 + .../resources/authTokens}/index.ts | 0 .../resources/authTokens/types/index.ts | 1 + .../resources/authTokens/types/types.ts | 27 + .../awayStatusReasons/client/Client.ts | 17 +- .../awayStatusReasons/client/index.ts | 0 .../resources/awayStatusReasons}/index.ts | 0 .../resources/banners/client/Client.ts | 184 + .../resources/banners}/client/index.ts | 0 .../requests/DismissContactBannerRequest.ts | 15 + .../requests/ListContactBannersRequest.ts} | 4 +- .../banners/client/requests/index.ts | 2 + .../resources/banners}/index.ts | 0 .../preview/resources/banners/types/index.ts | 1 + .../preview/resources/banners/types/types.ts | 86 + .../resources/brands/client/Client.ts | 38 +- .../resources/brands}/client/index.ts | 0 .../client/requests/RetrieveBrandRequest.ts | 0 .../resources/brands/client/requests/index.ts | 0 .../resources/brands}/index.ts | 0 .../preview/resources/brands/types/index.ts | 1 + .../resources/brands/types/types.ts} | 11 + .../resources/calls/client/Client.ts | 262 +- .../resources/calls}/client/index.ts | 0 .../CollectFinVoiceCallByExternalIdRequest.ts | 0 .../CollectFinVoiceCallByIdRequest.ts | 0 ...CollectFinVoiceCallByPhoneNumberRequest.ts | 0 ...ectFinVoiceCallsByConversationIdRequest.ts | 12 + .../calls/client/requests/ListCallsRequest.ts | 0 .../ListCallsWithTranscriptsRequest.ts | 0 .../requests/ShowCallRecordingRequest.ts | 0 .../calls/client/requests/ShowCallRequest.ts | 0 .../requests/ShowCallTranscriptRequest.ts | 0 .../resources/calls/client/requests/index.ts | 1 + .../resources/calls}/index.ts | 0 .../preview/resources/calls/types/index.ts | 1 + .../resources/calls/types/types.ts} | 36 +- .../resources/companies/client/Client.ts | 1558 ++ .../resources/companies}/client/index.ts | 0 .../AttachContactToACompanyRequest.ts | 0 .../requests/BulkCreateCompaniesRequest.ts | 80 + .../requests/BulkDeleteCompaniesRequest.ts | 47 + .../requests/BulkUpdateCompaniesRequest.ts | 79 + .../client/requests/CompanySearchRequest.ts | 53 + .../client/requests/DeleteCompanyRequest.ts | 0 .../DetachContactFromACompanyRequest.ts | 0 .../requests/ListAllCompaniesRequest.ts | 0 .../requests/ListAttachedContactsRequest.ts | 0 ...ListAttachedSegmentsForCompaniesRequest.ts | 0 .../requests/RetrieveACompanyByIdRequest.ts | 0 .../client/requests/RetrieveCompanyRequest.ts | 0 .../requests/ScrollOverAllCompaniesRequest.ts | 0 .../requests/ShowBulkCompaniesJobRequest.ts | 12 + .../client/requests/UpdateCompanyRequest.ts | 0 .../companies/client/requests/index.ts | 5 + .../resources/companies}/index.ts | 0 .../resources/companies/types/index.ts | 1 + .../resources/companies/types/types.ts} | 68 +- .../resources/contacts/client/Client.ts | 2570 +++ .../resources/contacts}/client/index.ts | 0 .../client/requests/ArchiveContactRequest.ts | 0 .../client/requests/BlockContactRequest.ts | 0 .../requests/BulkCreateContactsRequest.ts | 155 + .../requests/BulkDeleteContactsRequest.ts | 47 + .../requests/BulkUpdateContactsRequest.ts | 166 + .../client/requests/ContactSearchRequest.ts | 56 + .../client/requests/DeleteContactRequest.ts | 0 .../ListCompaniesForAContactRequest.ts | 0 .../requests/ListContactActivitiesRequest.ts | 15 + .../ListContactMergeHistoryRequest.ts | 23 + .../client/requests/ListContactsRequest.ts | 12 + .../requests/ListDeletedContactsRequest.ts | 15 + .../ListGrantedCompaniesForAContactRequest.ts | 31 + .../ListSegmentsForAContactRequest.ts | 0 .../ListSubscriptionsForAContactRequest.ts | 0 .../requests/ListTagsForAContactRequest.ts | 0 .../client/requests/MergeContactsRequest.ts | 28 + .../client/requests/MergePreviewRequest.ts | 25 + ...RemoveGrantedCompanyFromAContactRequest.ts | 15 + .../ReplaceGrantedCompaniesRequest.ts | 39 + .../ShowBulkUpdateContactsJobRequest.ts | 12 + .../ShowContactByExternalIdRequest.ts | 15 + .../client/requests/ShowContactRequest.ts | 15 + .../requests/UnarchiveContactRequest.ts | 0 .../client/requests/UpdateContactRequest.ts | 12 +- .../contacts/client/requests/index.ts | 25 + .../resources/contacts}/index.ts | 0 .../preview/resources/contacts/types/index.ts | 1 + .../preview/resources/contacts/types/types.ts | 207 + .../resources/content/client/Client.ts | 432 + .../resources/content}/client/index.ts | 0 .../requests/ContentBulkActionRequest.ts | 183 + .../client/requests/SearchContentRequest.ts | 65 + .../content/client/requests/index.ts | 2 + .../resources/content}/index.ts | 0 .../preview/resources/content/types/index.ts | 1 + .../preview/resources/content/types/types.ts | 46 + .../contentSnippets}/client/Client.ts | 418 +- .../contentSnippets}/client/index.ts | 0 .../AttachTagToContentSnippetRequest.ts | 17 + .../requests/ContentSnippetCreateRequest.ts | 32 + .../requests/ContentSnippetUpdateRequest.ts | 34 + .../requests/DeleteContentSnippetRequest.ts | 12 + .../DetachTagFromContentSnippetRequest.ts | 15 + .../requests/GetContentSnippetRequest.ts | 12 + .../requests/ListContentSnippetsRequest.ts | 15 + .../contentSnippets/client/requests/index.ts | 7 + .../resources/contentSnippets}/index.ts | 0 .../resources/contentSnippets/types/index.ts | 1 + .../resources/contentSnippets/types/types.ts | 35 + .../preview/resources/conversation/index.ts | 1 + .../resources/conversation/types/index.ts | 1 + .../resources/conversation/types/types.ts | 15 + .../conversationParticipants/client/Client.ts | 240 + .../conversationParticipants}/client/index.ts | 0 .../AttachContactToConversationRequest.ts | 6 +- .../DetachContactFromConversationRequest.ts | 0 .../client/requests/index.ts | 2 + .../conversationParticipants}/index.ts | 0 .../conversationParts/client/Client.ts | 224 + .../conversationParts}/client/index.ts | 0 .../requests/UpdateConversationPartRequest.ts | 41 + .../client/requests/index.ts | 1 + .../resources/conversationParts}/index.ts | 0 .../resources/conversations/client/Client.ts | 807 +- .../resources/conversations}/client/index.ts | 0 .../ConvertConversationToTicketRequest.ts | 4 +- .../requests/CreateConversationRequest.ts | 9 +- .../requests/DeleteConversationRequest.ts | 15 + .../requests/ListConversationsRequest.ts | 29 + .../ListDeletedConversationIdsRequest.ts | 18 + .../requests/ListHandlingEventsRequest.ts | 0 .../client/requests/ListHitlEventsRequest.ts | 12 + .../requests/ListSideConversationsRequest.ts | 18 + .../requests/ManageConversationRequest.ts | 2 +- .../requests/MergeConversationsRequestBody.ts | 15 + .../requests/ReplyConversationRequest.ts | 2 +- .../requests/RetrieveConversationRequest.ts | 51 + .../requests/SearchConversationsRequest.ts | 50 + .../requests/UpdateConversationRequest.ts | 30 +- .../conversations/client/requests/index.ts | 7 +- .../resources/conversations}/index.ts | 0 .../resources/conversations/types/index.ts | 1 + .../resources/conversations/types/types.ts | 342 + .../conversationsAttributes/client/Client.ts | 716 + .../conversationsAttributes}/client/index.ts | 0 ...reateConversationAttributeOptionRequest.ts | 18 + ...eleteConversationAttributeOptionRequest.ts | 15 + .../DeleteConversationAttributeRequest.ts | 12 + .../GetConversationAttributeRequest.ts | 12 + .../ListConversationAttributesRequest.ts | 12 + ...pdateConversationAttributeOptionRequest.ts | 18 + .../UpdateConversationAttributeRequest.ts | 47 + .../client/requests/index.ts | 7 + .../conversationsAttributes}/index.ts | 0 .../conversationsAttributes/types/index.ts | 1 + .../conversationsAttributes/types/types.ts | 50 + .../customObjectInstances/client/Client.ts | 171 +- .../customObjectInstances}/client/index.ts | 0 ...eateOrUpdateCustomObjectInstanceRequest.ts | 0 ...ustomObjectInstancesByExternalIdRequest.ts | 0 .../DeleteCustomObjectInstancesByIdRequest.ts | 0 .../GetCustomObjectInstancesByIdRequest.ts | 0 .../ListCustomObjectInstancesRequest.ts | 27 + .../client/requests/index.ts | 2 +- .../resources/customObjectInstances}/index.ts | 0 .../customObjectInstances/types/index.ts | 1 + .../customObjectInstances/types/types.ts} | 15 + .../resources/dataAttributes/client/Client.ts | 82 +- .../resources/dataAttributes}/client/index.ts | 0 .../requests/LisDataAttributesRequest.ts | 4 +- .../requests/UpdateDataAttributeRequest.ts | 0 .../dataAttributes/client/requests/index.ts | 0 .../resources/dataAttributes}/index.ts | 0 .../resources/dataAttributes/types/index.ts | 1 + .../resources/dataAttributes/types/types.ts} | 10 +- .../resources/dataConnectors/client/Client.ts | 724 + .../resources/dataConnectors}/client/index.ts | 0 .../requests/CreateDataConnectorRequest.ts | 134 + .../requests/DeleteDataConnectorRequest.ts | 12 + ...istDataConnectorExecutionResultsRequest.ts | 35 + .../requests/ListDataConnectorsRequest.ts | 15 + .../requests/RetrieveDataConnectorRequest.ts | 17 + ...ShowDataConnectorExecutionResultRequest.ts | 15 + .../requests/UpdateDataConnectorRequest.ts | 134 + .../dataConnectors/client/requests/index.ts | 7 + .../resources/dataConnectors}/index.ts | 0 .../resources/dataConnectors/types/index.ts | 1 + .../resources/dataConnectors/types/types.ts | 413 + .../resources/dataEvents/client/Client.ts | 42 +- .../resources/dataEvents}/client/index.ts | 0 .../CreateDataEventSummariesRequest.ts | 0 .../client/requests/LisDataEventsRequest.ts | 2 +- .../dataEvents/client/requests/index.ts | 0 .../resources/dataEvents}/index.ts | 0 .../resources/dataEvents/types/index.ts | 1 + .../resources/dataEvents/types/types.ts} | 13 +- .../resources/dataExport/client/Client.ts | 54 +- .../resources/dataExport}/client/index.ts | 0 .../requests/CancelDataExportRequest.ts | 0 .../requests/CreateDataExportsRequest.ts | 0 .../requests/DownloadDataExportRequest.ts | 0 .../client/requests/GetDataExportRequest.ts | 0 .../dataExport/client/requests/index.ts | 0 .../resources/dataExport}/index.ts | 0 .../resources/dataExport/types/index.ts | 1 + .../resources/dataExport/types/types.ts} | 2 +- .../ecommerceConnectors/client/Client.ts | 258 + .../ecommerceConnectors}/client/index.ts | 0 .../requests/UploadEcommerceCatalogRequest.ts | 56 + .../client/requests/index.ts | 1 + .../resources/ecommerceConnectors}/index.ts | 0 .../resources/emails/client/Client.ts | 38 +- .../resources/emails}/client/index.ts | 0 .../client/requests/RetrieveEmailRequest.ts | 0 .../resources/emails/client/requests/index.ts | 0 .../resources/emails}/index.ts | 0 .../preview/resources/emails/types/index.ts | 1 + .../resources/emails/types/types.ts} | 11 + .../resources/finAgent/client/Client.ts | 906 ++ .../resources/finAgent}/client/index.ts | 0 .../finAgent/client/requests/AskFinRequest.ts | 87 + .../requests/ListFinCapabilitiesRequest.ts | 15 + .../client/requests/ReplyToFinRequest.ts | 97 + .../client/requests/RunFinProcedureRequest.ts | 91 + .../requests/StartFinConversationRequest.ts | 137 + .../client/requests/SubmitFinCsatRequest.ts | 36 + .../finAgent/client/requests/index.ts | 6 + .../resources/finAgent}/index.ts | 0 .../preview/resources/finAgent/types/index.ts | 1 + .../preview/resources/finAgent/types/types.ts | 525 + .../resources/folders}/client/Client.ts | 299 +- .../resources/folders}/client/index.ts | 0 .../client/requests/CreateFolderRequest.ts | 28 + .../client/requests/DeleteFolderRequest.ts | 12 + .../client/requests/ListFoldersRequest.ts | 18 + .../client/requests/RetrieveFolderRequest.ts | 12 + .../client/requests/UpdateFolderRequest.ts | 30 + .../folders/client/requests/index.ts | 5 + .../resources/folders}/index.ts | 0 .../preview/resources/folders/types/index.ts | 1 + .../preview/resources/folders/types/types.ts | 33 + .../resources/helpCenter}/client/Client.ts | 713 +- .../resources/helpCenter}/client/index.ts | 0 .../requests/CreateCollectionRequest.ts | 2 +- .../CreateHelpCenterRedirectRequest.ts | 33 + .../requests/DeleteCollectionRequest.ts | 0 .../DeleteHelpCenterRedirectRequest.ts | 15 + .../ListHelpCenterRedirectsRequest.ts | 18 + .../requests/RetrieveCollectionRequest.ts | 0 .../RetrieveHelpCenterRedirectRequest.ts | 15 + .../requests/RetrieveHelpCenterRequest.ts | 0 .../requests/UpdateCollectionRequest.ts | 2 +- .../helpCenter/client/requests/index.ts | 4 + .../resources/helpCenter}/index.ts | 0 .../resources/helpCenter/types/index.ts | 1 + .../resources/helpCenter/types/types.ts | 106 + .../client/Client.ts | 266 + .../client/index.ts | 0 ...CreateIdentityVerificationSecretRequest.ts | 27 + ...DeleteIdentityVerificationSecretRequest.ts | 12 + .../client/requests/index.ts | 2 + .../identityVerificationSecrets}/index.ts | 0 .../types/index.ts | 1 + .../types/types.ts | 31 + .../{unstable => preview}/resources/index.ts | 58 +- .../internalArticles/client/Client.ts | 340 +- .../internalArticles}/client/index.ts | 0 .../AttachTagToInternalArticleRequest.ts | 17 + .../requests/DeleteInternalArticleRequest.ts | 0 .../DetachTagFromInternalArticleRequest.ts | 15 + .../RetrieveInternalArticleRequest.ts | 0 .../requests/SearchInternalArticlesRequest.ts | 12 + .../UpdateInternalArticleRequestBody.ts | 42 + .../internalArticles/client/requests/index.ts | 2 + .../resources/internalArticles}/index.ts | 0 .../resources/internalArticles/types/index.ts | 1 + .../resources/internalArticles/types/types.ts | 63 + .../resources/jobs/client/Client.ts | 24 +- .../resources/jobs}/client/index.ts | 0 .../jobs/client/requests/JobsStatusRequest.ts | 0 .../resources/jobs/client/requests/index.ts | 0 .../resources/jobs}/index.ts | 0 .../preview/resources/jobs/types/index.ts | 1 + .../resources/jobs/types/types.ts} | 0 .../resources/macros/client/Client.ts | 60 +- .../resources/macros}/client/index.ts | 0 .../macros/client/requests/GetMacroRequest.ts | 0 .../client/requests/ListMacrosRequest.ts | 0 .../resources/macros/client/requests/index.ts | 0 .../preview/resources/macros/index.ts | 2 + .../preview/resources/macros/types/index.ts | 1 + .../resources/macros/types/types.ts} | 38 + .../resources/messages/client/Client.ts | 171 +- .../resources/messages}/client/index.ts | 0 .../GetWhatsAppMessageStatusRequest.ts | 0 .../RetrieveWhatsAppMessageStatusRequest.ts | 17 + .../messages/client/requests/index.ts | 2 + .../preview/resources/messages/index.ts | 2 + .../preview/resources/messages/types/index.ts | 1 + .../resources/messages/types/types.ts} | 0 .../resources/news/client/Client.ts | 162 +- .../resources/news}/client/index.ts | 0 .../client/requests/DeleteNewsItemRequest.ts | 0 .../requests/ListLiveNewsfeedItemsRequest.ts | 0 .../requests/RetrieveNewsItemRequest.ts | 0 .../requests/RetrieveNewsfeedRequest.ts | 0 .../client/requests/UpdateNewsItemRequest.ts | 2 +- .../resources/news/client/requests/index.ts | 0 .../resources/preview/resources/news/index.ts | 2 + .../preview/resources/news/types/index.ts | 1 + .../resources/news/types/types.ts} | 30 +- .../preview/resources/notes/client/Client.ts | 501 + .../preview/resources/notes/client/index.ts | 1 + .../requests/CreateCompanyNoteRequest.ts | 31 + .../client/requests/CreateNoteRequest.ts | 0 .../client/requests/DeleteNoteRequest.ts} | 4 +- .../requests/ListCompanyNotesRequest.ts | 4 +- .../notes/client/requests/ListNotesRequest.ts | 0 .../client/requests/RetrieveNoteRequest.ts | 0 .../resources/notes/client/requests/index.ts | 2 + .../preview/resources/notes/index.ts | 2 + .../preview/resources/notes/types/index.ts | 1 + .../preview/resources/notes/types/types.ts | 75 + .../resources/officeHours/client/Client.ts | 866 + .../resources/officeHours/client/index.ts | 1 + .../CreateOfficeHoursExceptionRequest.ts | 37 + .../CreateOfficeHoursScheduleRequest.ts | 23 + .../DeleteOfficeHoursExceptionRequest.ts | 15 + .../DeleteOfficeHoursScheduleRequest.ts | 12 + .../GetOfficeHoursExceptionRequest.ts | 15 + .../requests/GetOfficeHoursScheduleRequest.ts | 12 + .../ListOfficeHoursExceptionsRequest.ts | 12 + .../UpdateOfficeHoursExceptionRequest.ts | 43 + .../UpdateOfficeHoursScheduleRequest.ts | 25 + .../officeHours/client/requests/index.ts | 9 + .../preview/resources/officeHours/index.ts | 2 + .../resources/officeHours/types/index.ts | 1 + .../resources/officeHours/types/types.ts | 84 + .../resources/procedures/client/Client.ts | 161 + .../resources/procedures/client/index.ts | 1 + .../requests/CollectAgentInputRequest.ts | 46 + .../procedures/client/requests/index.ts | 1 + .../resources/procedures}/index.ts | 0 .../reportingDataExport}/client/Client.ts | 60 +- .../reportingDataExport/client/index.ts | 1 + .../PostExportReportingDataEnqueueRequest.ts | 1 + .../client/requests/index.ts | 0 .../resources/reportingDataExport/index.ts | 2 + .../reportingDataExport/types/index.ts | 1 + .../reportingDataExport/types/types.ts} | 10 + .../resources/roles}/client/Client.ts | 90 +- .../preview/resources/roles/client/index.ts | 1 + .../client/requests/RetrieveRoleRequest.ts | 12 + .../resources/roles/client/requests/index.ts | 1 + .../preview/resources/roles/index.ts | 2 + .../preview/resources/roles/types/index.ts | 1 + .../preview/resources/roles/types/types.ts | 27 + .../preview/resources/salesAgent/index.ts | 1 + .../resources/salesAgent/types/index.ts | 1 + .../resources/salesAgent/types/types.ts | 25 + .../resources/segments/client/Client.ts | 44 +- .../resources/segments/client/index.ts | 1 + .../client/requests/ListSegmentsRequest.ts | 0 .../client/requests/RetrieveSegmentRequest.ts | 0 .../segments/client/requests/index.ts | 0 .../preview/resources/segments/index.ts | 2 + .../preview/resources/segments/types/index.ts | 1 + .../resources/segments/types/types.ts} | 0 .../subscriptionTypes/client/Client.ts | 64 +- .../subscriptionTypes/client/index.ts | 1 + .../AttachSubscriptionTypeToContactRequest.ts | 0 .../DetachSubscriptionTypeToContactRequest.ts | 0 .../client/requests/index.ts | 0 .../resources/subscriptionTypes/index.ts | 2 + .../subscriptionTypes/types/index.ts | 1 + .../subscriptionTypes/types/types.ts} | 4 +- .../resources/switch/client/Client.ts | 22 +- .../resources/switch/client/index.ts | 0 .../resources/switch}/index.ts | 0 .../resources/tags/client/Client.ts | 251 +- .../preview/resources/tags/client/index.ts | 1 + .../requests/AttachTagToContactRequest.ts | 0 .../AttachTagToConversationRequest.ts | 0 .../requests/AttachTagToTicketRequest.ts | 0 .../tags/client/requests/DeleteTagRequest.ts | 0 .../requests/DetachTagFromContactRequest.ts | 0 .../DetachTagFromConversationRequest.ts | 0 .../requests/DetachTagFromTicketRequest.ts | 0 .../tags/client/requests/FindTagRequest.ts | 0 .../resources/tags/client/requests/index.ts | 0 .../resources/preview/resources/tags/index.ts | 2 + .../preview/resources/tags/types/index.ts | 1 + .../preview/resources/tags/types/types.ts | 37 + .../resources/teams}/client/Client.ts | 260 +- .../preview/resources/teams/client/index.ts | 1 + .../client/requests/GetTeamMetricsRequest.ts | 15 + .../client/requests/RetrieveTeamRequest.ts | 0 .../requests/UpdateTeamMembersRequest.ts | 22 + .../resources/teams/client/requests/index.ts | 3 + .../preview/resources/teams/index.ts | 2 + .../preview/resources/teams/types/index.ts | 1 + .../resources/teams/types/types.ts} | 6 +- .../resources/ticketStates/client/Client.ts | 14 +- .../resources/ticketStates/client/index.ts | 0 .../resources/ticketStates}/index.ts | 0 .../ticketTypeAttributes/client/Client.ts | 40 +- .../ticketTypeAttributes/client/index.ts | 1 + .../CreateTicketTypeAttributeRequest.ts | 0 .../UpdateTicketTypeAttributeRequest.ts | 0 .../client/requests/index.ts | 0 .../resources/ticketTypeAttributes}/index.ts | 0 .../resources/ticketTypes/client/Client.ts | 48 +- .../resources/ticketTypes/client/index.ts | 1 + .../client/requests/GetTicketTypeRequest.ts | 0 .../ticketTypes/client/requests/index.ts | 0 .../resources/ticketTypes}/index.ts | 0 .../resources/tickets/client/Client.ts | 465 +- .../preview/resources/tickets/client/index.ts | 1 + .../requests/ChangeTicketTypeRequest.ts | 20 + .../client/requests/DeleteTicketRequest.ts | 17 + .../requests/EnqueueCreateTicketRequest.ts | 2 +- .../client/requests/GetTicketRequest.ts | 17 + .../LinkConversationToTicketRequest.ts | 15 + .../client/requests/ReplyTicketRequest.ts | 25 +- .../UnlinkConversationFromTicketRequest.ts | 15 + .../client/requests/UpdateTicketRequest.ts | 32 +- .../tickets/client/requests/index.ts | 3 + .../preview/resources/tickets/index.ts | 2 + .../preview/resources/tickets/types/index.ts | 1 + .../preview/resources/tickets/types/types.ts | 292 + .../resources/visitors/client/Client.ts | 70 +- .../resources/visitors/client/index.ts | 1 + .../client/requests/ConvertVisitorRequest.ts | 0 .../RetrieveVisitorWithUserIdRequest.ts | 0 .../visitors/client/requests/index.ts | 0 .../preview/resources/visitors/index.ts | 1 + .../resources/workflows/client/Client.ts | 28 +- .../resources/workflows/client/index.ts | 1 + .../client/requests/ExportWorkflowRequest.ts | 0 .../workflows/client/requests/index.ts | 0 .../preview/resources/workflows/index.ts | 1 + src/api/resources/preview/types/index.ts | 1 + src/api/resources/preview/types/types.ts | 4956 ++++++ .../client/Client.ts | 24 +- .../reportingDataExport/client/index.ts | 1 + .../PostExportReportingDataEnqueueRequest.ts | 0 .../client/requests/index.ts | 0 .../resources/reportingDataExport/index.ts | 2 + .../reportingDataExport/types/index.ts | 1 + .../types/types.ts} | 7 + src/api/resources/segments/types/index.ts | 2 +- .../Segment.ts => segments/types/types.ts} | 12 +- .../subscriptionTypes/types/index.ts | 2 +- .../types/{SubscriptionType.ts => types.ts} | 0 src/api/resources/tags/client/Client.ts | 12 +- src/api/resources/tags/types/Tag.ts | 18 - src/api/resources/tags/types/TagBasic.ts | 13 - .../tags/types/TagsCreateRequestBody.ts | 9 - src/api/resources/tags/types/index.ts | 4 +- src/api/resources/tags/types/types.ts | 37 + src/api/resources/teams/types/index.ts | 2 +- .../teams/types/{Team.ts => types.ts} | 8 +- src/api/resources/tickets/client/Client.ts | 27 +- .../client/requests/FindTicketRequest.ts | 7 +- .../client/requests/ReplyToTicketRequest.ts | 12 + .../client/requests/UpdateTicketRequest.ts | 29 +- .../tickets/types/DeleteTicketResponse.ts | 13 - src/api/resources/tickets/types/Ticket.ts | 47 - .../resources/tickets/types/TicketContacts.ts | 13 - src/api/resources/tickets/types/TicketPart.ts | 109 - .../resources/tickets/types/TicketState.ts | 28 - .../tickets/types/TicketStateDetailed.ts | 44 - src/api/resources/tickets/types/TicketType.ts | 52 - .../tickets/types/TicketsReplyRequestBody.ts | 5 - src/api/resources/tickets/types/index.ts | 9 +- src/api/resources/tickets/types/types.ts | 282 + .../unstable/resources/admins/types/Admin.ts | 32 - .../unstable/resources/admins/types/index.ts | 1 - .../unstable/resources/aiAgent/types/index.ts | 1 - .../aiContent/types/ContentImportSource.ts | 39 - .../types/ContentImportSourcesList.ts | 16 - .../resources/aiContent/types/ExternalPage.ts | 35 - .../aiContent/types/ExternalPagesList.ts | 16 - .../resources/aiContent/types/index.ts | 4 - .../resources/aiContentSource/types/index.ts | 1 - .../articles/client/requests/index.ts | 3 - .../resources/articles/types/Article.ts | 10 - .../articles/types/ArticleListItem.ts | 49 - .../articles/types/ArticleSearchHighlights.ts | 61 - .../articles/types/ArticleSearchResponse.ts | 28 - .../articles/types/InternalArticle.ts | 8 - .../resources/articles/types/index.ts | 5 - .../resources/brands/types/BrandList.ts | 12 - .../unstable/resources/brands/types/index.ts | 2 - .../types/ListCallsWithTranscriptsResponse.ts | 21 - .../unstable/resources/calls/types/index.ts | 2 - .../resources/companies/types/index.ts | 1 - .../resources/contacts/client/Client.ts | 1251 -- .../client/requests/MergeContactsRequest.ts | 15 - .../ShowContactByExternalIdRequest.ts | 12 - .../contacts/client/requests/index.ts | 12 - .../resources/contacts/types/Contact.ts | 104 - .../contacts/types/CreateContactResponse.ts | 8 - .../contacts/types/MergeContactResponse.ts | 8 - .../types/ShowContactByExternalIdResponse.ts | 8 - .../contacts/types/ShowContactResponse.ts | 8 - .../contacts/types/UpdateContactResponse.ts | 8 - .../resources/contacts/types/index.ts | 6 - .../requests/ListConversationsRequest.ts | 15 - .../requests/RetrieveConversationRequest.ts | 18 - .../conversations/types/Conversation.ts | 69 - .../types/ManageConversationRequestBody.ts | 27 - .../resources/conversations/types/index.ts | 2 - .../customChannelEvents/client/Client.ts | 434 - .../NotifyAttributeCollectedRequest.ts | 24 - .../requests/NotifyNewMessageRequest.ts | 22 - .../NotifyQuickReplySelectedRequest.ts | 22 - .../client/requests/index.ts | 3 - ...ustomObjectInstancesByExternalIdRequest.ts | 14 - .../customObjectInstances/types/index.ts | 1 - .../types/LisDataAttributesRequestModel.ts | 9 - .../resources/dataAttributes/types/index.ts | 2 - .../types/LisDataEventsRequestFilter.ts | 12 - .../resources/dataEvents/types/index.ts | 2 - .../resources/dataExport/types/index.ts | 1 - .../resources/emails/types/EmailList.ts | 12 - .../unstable/resources/emails/types/index.ts | 2 - .../PostExportReportingDataEnqueueResponse.ts | 8 - .../unstable/resources/export/types/index.ts | 2 - .../resources/helpCenter/types/Collection.ts | 34 - .../resources/helpCenter/types/HelpCenter.ts | 25 - .../helpCenter/types/HelpCenterList.ts | 13 - .../resources/helpCenter/types/index.ts | 3 - .../requests/SearchInternalArticlesRequest.ts | 12 - .../UpdateInternalArticleRequestBody.ts | 29 - .../types/InternalArticleSearchResponse.ts | 26 - .../resources/internalArticles/types/index.ts | 2 - .../unstable/resources/jobs/types/index.ts | 1 - .../resources/macros/types/MacroList.ts | 39 - .../unstable/resources/macros/types/index.ts | 2 - .../messages/client/requests/index.ts | 1 - .../resources/messages/types/index.ts | 1 - .../unstable/resources/news/types/Newsfeed.ts | 19 - .../news/types/NewsfeedAssignment.ts | 11 - .../unstable/resources/news/types/index.ts | 3 - .../resources/notes/types/CompanyNote.ts | 33 - .../unstable/resources/notes/types/Note.ts | 33 - .../unstable/resources/notes/types/index.ts | 2 - .../resources/segments/types/index.ts | 1 - .../subscriptionTypes/types/index.ts | 1 - .../tags/types/CreateTagRequestBody.ts | 9 - .../unstable/resources/tags/types/Tag.ts | 18 - .../unstable/resources/tags/types/TagBasic.ts | 13 - .../unstable/resources/tags/types/index.ts | 3 - .../resources/teams/client/requests/index.ts | 1 - .../unstable/resources/teams/types/index.ts | 1 - .../client/requests/DeleteTicketRequest.ts | 12 - .../tickets/types/DeleteTicketResponse.ts | 13 - .../tickets/types/ReplyTicketRequestBody.ts | 7 - .../resources/tickets/types/Ticket.ts | 47 - .../resources/tickets/types/TicketContacts.ts | 13 - .../resources/tickets/types/TicketPart.ts | 109 - .../resources/tickets/types/TicketState.ts | 28 - .../tickets/types/TicketStateDetailed.ts | 44 - .../resources/tickets/types/TicketType.ts | 52 - .../unstable/resources/tickets/types/index.ts | 8 - .../resources/unstable/types/ActivityLog.ts | 107 - .../unstable/types/ActivityLogList.ts | 14 - .../unstable/types/ActivityLogMetadata.ts | 29 - .../unstable/types/AddressableList.ts | 13 - src/api/resources/unstable/types/AdminList.ts | 13 - .../unstable/types/AdminPriorityLevel.ts | 11 - .../types/AdminReplyConversationRequest.ts | 32 - .../unstable/types/AdminReplyTicketRequest.ts | 38 - .../resources/unstable/types/AdminWithApp.ts | 45 - .../unstable/types/AiCallResponse.ts | 27 - src/api/resources/unstable/types/App.ts | 21 - .../unstable/types/ArticleContent.ts | 34 - .../resources/unstable/types/ArticleList.ts | 16 - .../unstable/types/ArticleStatistics.ts | 21 - .../types/ArticleTranslatedContent.ts | 85 - .../types/AssignConversationRequest.ts | 22 - .../unstable/types/AwayStatusReason.ts | 19 - src/api/resources/unstable/types/CallList.ts | 16 - .../types/CloseConversationRequest.ts | 12 - .../unstable/types/CollectionList.ts | 16 - .../unstable/types/CompanyAttachedContacts.ts | 16 - .../unstable/types/CompanyAttachedSegments.ts | 13 - .../resources/unstable/types/CompanyData.ts | 13 - .../resources/unstable/types/CompanyList.ts | 16 - .../resources/unstable/types/CompanyScroll.ts | 17 - .../unstable/types/ContactArchived.ts | 11 - .../types/ContactAttachedCompanies.ts | 16 - .../unstable/types/ContactBlocked.ts | 11 - .../unstable/types/ContactCompanies.ts | 17 - .../unstable/types/ContactDeleted.ts | 11 - .../resources/unstable/types/ContactList.ts | 16 - .../unstable/types/ContactLocation.ts | 15 - .../resources/unstable/types/ContactNotes.ts | 17 - .../unstable/types/ContactReference.ts | 13 - .../unstable/types/ContactReplyBaseRequest.ts | 27 - .../types/ContactReplyConversationRequest.ts | 8 - .../types/ContactReplyEmailRequest.ts | 13 - .../ContactReplyIntercomUserIdRequest.ts | 13 - .../types/ContactReplyTicketEmailRequest.ts | 11 - ...ContactReplyTicketIntercomUserIdRequest.ts | 11 - .../types/ContactReplyTicketRequest.ts | 8 - .../types/ContactReplyTicketUserIdRequest.ts | 11 - .../types/ContactReplyUserIdRequest.ts | 13 - .../unstable/types/ContactSegments.ts | 13 - .../unstable/types/ContactSocialProfiles.ts | 11 - .../types/ContactSubscriptionTypes.ts | 17 - .../resources/unstable/types/ContactTags.ts | 17 - .../unstable/types/ContactUnarchived.ts | 11 - .../unstable/types/ContentSourcesList.ts | 11 - .../types/ConversationAttachmentFiles.ts | 13 - .../ConversationAttributeUpdatedByAdmin.ts | 23 - .../ConversationAttributeUpdatedByUser.ts | 23 - .../ConversationAttributeUpdatedByWorkflow.ts | 27 - .../unstable/types/ConversationContacts.ts | 13 - .../unstable/types/ConversationDeleted.ts | 13 - .../types/ConversationFirstContactReply.ts | 13 - .../unstable/types/ConversationList.ts | 16 - .../unstable/types/ConversationPart.ts | 51 - .../unstable/types/ConversationPartAuthor.ts | 19 - .../types/ConversationPartMetadata.ts | 24 - .../unstable/types/ConversationParts.ts | 15 - .../unstable/types/ConversationRating.ts | 19 - .../types/ConversationResponseTime.ts | 13 - .../types/ConversationSlaAppliedByRule.ts | 27 - .../types/ConversationSlaAppliedByWorkflow.ts | 27 - .../unstable/types/ConversationSlaPaused.ts | 33 - .../unstable/types/ConversationSlaRemoved.ts | 9 - .../types/ConversationSlaTargetMissed.ts | 55 - .../unstable/types/ConversationSlaUnpaused.ts | 9 - .../unstable/types/ConversationSource.ts | 43 - .../unstable/types/ConversationStatistics.ts | 55 - .../unstable/types/ConversationTagsUpdated.ts | 11 - .../unstable/types/ConversationTeammates.ts | 13 - .../unstable/types/CreateArticleRequest.ts | 33 - .../types/CreateDataAttributeRequest.ts | 15 - .../types/CreateInternalArticleRequest.ts | 15 - .../unstable/types/CreateMessageRequest.ts | 6 - .../types/CreateOrUpdateCompanyRequest.ts | 25 - .../types/CreateOrUpdateTagRequest.ts | 11 - .../types/CreatePhoneSwitchRequest.ts | 12 - .../CreateTicketReplyWithCommentRequest.ts | 7 - .../unstable/types/CreateTicketRequestBody.ts | 48 - .../unstable/types/CreateTicketTypeRequest.ts | 28 - .../resources/unstable/types/CursorPages.ts | 19 - .../unstable/types/CustomActionFinished.ts | 26 - .../unstable/types/CustomActionStarted.ts | 15 - .../unstable/types/CustomAttributes.ts | 12 - .../unstable/types/CustomChannelAttribute.ts | 8 - .../unstable/types/CustomChannelBaseEvent.ts | 11 - .../unstable/types/CustomChannelContact.ts | 21 - .../CustomChannelNotificationResponse.ts | 12 - .../types/CustomObjectInstanceDeleted.ts | 13 - .../types/CustomObjectInstanceList.ts | 12 - .../unstable/types/CustomerRequest.ts | 12 - .../unstable/types/DataAttributeList.ts | 13 - .../resources/unstable/types/DataEventList.ts | 25 - .../unstable/types/DataEventSummary.ts | 19 - .../unstable/types/DataEventSummaryItem.ts | 17 - .../resources/unstable/types/DataExportCsv.ts | 59 - src/api/resources/unstable/types/Datetime.ts | 9 - .../unstable/types/DeletedArticleObject.ts | 13 - .../unstable/types/DeletedCollectionObject.ts | 13 - .../unstable/types/DeletedCompanyObject.ts | 13 - .../types/DeletedInternalArticleObject.ts | 13 - .../resources/unstable/types/DeletedObject.ts | 13 - .../unstable/types/EmailAddressHeader.ts | 13 - .../unstable/types/EmailMessageMetadata.ts | 15 - src/api/resources/unstable/types/Error_.ts | 28 - .../resources/unstable/types/EventDetails.ts | 20 - .../resources/unstable/types/FileAttribute.ts | 20 - .../resources/unstable/types/GroupContent.ts | 13 - .../unstable/types/GroupTranslatedContent.ts | 85 - .../resources/unstable/types/HandlingEvent.ts | 25 - .../unstable/types/HandlingEventList.ts | 11 - .../unstable/types/InternalArticleList.ts | 16 - .../resources/unstable/types/LinkedObject.ts | 29 - .../unstable/types/LinkedObjectList.ts | 17 - .../types/MultipleFilterSearchRequest.ts | 28 - .../unstable/types/NewsItemRequest.ts | 34 - .../unstable/types/NotFoundErrorBody.ts | 23 - src/api/resources/unstable/types/NoteList.ts | 16 - .../unstable/types/OpenConversationRequest.ts | 9 - .../unstable/types/OperatorWorkflowEvent.ts | 23 - src/api/resources/unstable/types/PagesLink.ts | 15 - .../unstable/types/PaginatedResponse.ts | 25 - .../types/PaginatedResponseDataItem.ts | 17 - .../unstable/types/PartAttachment.ts | 21 - .../resources/unstable/types/PhoneSwitch.ts | 11 - .../unstable/types/PriorityChanged.ts | 26 - .../unstable/types/QuickReplyOption.ts | 8 - src/api/resources/unstable/types/Recipient.ts | 20 - .../types/RedactConversationRequest.ts | 29 - src/api/resources/unstable/types/Reference.ts | 11 - .../types/RegisterFinVoiceCallRequest.ts | 25 - .../types/ReplyConversationRequestBody.ts | 7 - .../resources/unstable/types/SearchRequest.ts | 15 - .../resources/unstable/types/SegmentList.ts | 15 - .../types/SingleFilterSearchRequest.ts | 30 - .../resources/unstable/types/SlaApplied.ts | 35 - .../types/SnoozeConversationRequest.ts | 11 - src/api/resources/unstable/types/Snoozed.ts | 11 - .../resources/unstable/types/SocialProfile.ts | 13 - .../unstable/types/StartingAfterPaging.ts | 8 - .../unstable/types/SubscriptionTypeList.ts | 13 - .../unstable/types/TagCompanyRequest.ts | 24 - src/api/resources/unstable/types/TagList.ts | 13 - .../unstable/types/TagMultipleUsersRequest.ts | 21 - src/api/resources/unstable/types/Tags.ts | 13 - src/api/resources/unstable/types/TeamList.ts | 13 - .../unstable/types/TeamPriorityLevel.ts | 11 - .../unstable/types/TeammateReference.ts | 25 - .../unstable/types/TicketCustomAttributes.ts | 12 - .../resources/unstable/types/TicketList.ts | 16 - .../unstable/types/TicketPartAuthor.ts | 26 - .../resources/unstable/types/TicketParts.ts | 15 - .../resources/unstable/types/TicketReply.ts | 36 - .../types/TicketRequestCustomAttributes.ts | 10 - .../unstable/types/TicketStateList.ts | 13 - .../unstable/types/TicketTypeAttribute.ts | 41 - .../unstable/types/TicketTypeAttributeList.ts | 13 - .../unstable/types/TicketTypeList.ts | 13 - .../resources/unstable/types/Translation.ts | 13 - .../unstable/types/UntagCompanyRequest.ts | 26 - .../types/UpdateDataAttributeRequestBody.ts | 12 - src/api/resources/unstable/types/Visitor.ts | 136 - .../unstable/types/VisitorDeletedObject.ts | 13 - .../types/WhatsappMessageStatusList.ts | 67 - .../unstable/types/WorkflowExport.ts | 59 - src/api/resources/unstable/types/index.ts | 168 - src/api/types/ActivityLog.ts | 137 - src/api/types/ActivityLogList.ts | 14 - src/api/types/ActivityLogMetadata.ts | 55 - src/api/types/AddressableList.ts | 13 - src/api/types/AdminList.ts | 13 - src/api/types/AdminPriorityLevel.ts | 11 - .../types/AdminReplyConversationRequest.ts | 32 - src/api/types/AdminReplyTicketRequest.ts | 38 - src/api/types/AdminWithApp.ts | 45 - src/api/types/App.ts | 21 - src/api/types/ArticleContent.ts | 34 - src/api/types/ArticleList.ts | 16 - src/api/types/ArticleStatistics.ts | 21 - src/api/types/ArticleTranslatedContent.ts | 85 - src/api/types/AssignConversationRequest.ts | 22 - src/api/types/AwayStatusReason.ts | 19 - src/api/types/CallList.ts | 16 - src/api/types/CloseConversationRequest.ts | 12 - src/api/types/CollectionList.ts | 16 - src/api/types/CompanyAttachedContacts.ts | 16 - src/api/types/CompanyAttachedSegments.ts | 13 - src/api/types/CompanyData.ts | 13 - src/api/types/CompanyList.ts | 16 - src/api/types/CompanyScroll.ts | 17 - src/api/types/ContactArchived.ts | 11 - src/api/types/ContactAttachedCompanies.ts | 16 - src/api/types/ContactBlocked.ts | 11 - src/api/types/ContactCompanies.ts | 17 - src/api/types/ContactDeleted.ts | 11 - src/api/types/ContactList.ts | 16 - src/api/types/ContactLocation.ts | 15 - src/api/types/ContactNotes.ts | 17 - src/api/types/ContactReference.ts | 13 - src/api/types/ContactReplyBaseRequest.ts | 27 - .../types/ContactReplyConversationRequest.ts | 8 - src/api/types/ContactReplyEmailRequest.ts | 13 - .../ContactReplyIntercomUserIdRequest.ts | 13 - .../types/ContactReplyTicketEmailRequest.ts | 11 - ...ContactReplyTicketIntercomUserIdRequest.ts | 11 - src/api/types/ContactReplyTicketRequest.ts | 8 - .../types/ContactReplyTicketUserIdRequest.ts | 11 - src/api/types/ContactReplyUserIdRequest.ts | 13 - src/api/types/ContactSegments.ts | 13 - src/api/types/ContactSocialProfiles.ts | 11 - src/api/types/ContactSubscriptionTypes.ts | 17 - src/api/types/ContactTags.ts | 17 - src/api/types/ContactUnarchived.ts | 11 - src/api/types/ContentSourcesList.ts | 11 - src/api/types/ConversationAttachmentFiles.ts | 13 - .../ConversationAttributeUpdatedByAdmin.ts | 21 - .../ConversationAttributeUpdatedByWorkflow.ts | 27 - src/api/types/ConversationContacts.ts | 13 - src/api/types/ConversationDeleted.ts | 13 - .../types/ConversationFirstContactReply.ts | 13 - src/api/types/ConversationList.ts | 16 - src/api/types/ConversationPart.ts | 51 - src/api/types/ConversationPartAuthor.ts | 19 - src/api/types/ConversationPartMetadata.ts | 24 - src/api/types/ConversationParts.ts | 15 - src/api/types/ConversationRating.ts | 19 - src/api/types/ConversationResponseTime.ts | 13 - src/api/types/ConversationSource.ts | 43 - src/api/types/ConversationStatistics.ts | 55 - src/api/types/ConversationTeammates.ts | 13 - src/api/types/CreateArticleRequest.ts | 39 - src/api/types/CreateContactRequest.ts | 39 - src/api/types/CreateContactRequestTwo.ts | 3 - src/api/types/CreateDataAttributeRequest.ts | 15 - src/api/types/CreateDataEventRequest.ts | 24 - src/api/types/CreateDataEventRequestTwo.ts | 3 - src/api/types/CreateInternalArticleRequest.ts | 15 - src/api/types/CreateMessageRequest.ts | 108 - src/api/types/CreateOrUpdateCompanyRequest.ts | 25 - src/api/types/CreateOrUpdateTagRequest.ts | 11 - src/api/types/CreatePhoneSwitchRequest.ts | 12 - .../CreateTicketReplyWithCommentRequest.ts | 5 - src/api/types/CreateTicketRequestBody.ts | 48 - src/api/types/CreateTicketTypeRequest.ts | 28 - src/api/types/CursorPages.ts | 19 - src/api/types/CustomActionFinished.ts | 26 - src/api/types/CustomActionStarted.ts | 15 - src/api/types/CustomAttributes.ts | 12 - src/api/types/CustomChannelAttribute.ts | 8 - src/api/types/CustomChannelBaseEvent.ts | 11 - src/api/types/CustomChannelContact.ts | 21 - .../CustomChannelNotificationResponse.ts | 12 - src/api/types/CustomObjectInstanceDeleted.ts | 13 - src/api/types/CustomObjectInstanceList.ts | 12 - src/api/types/CustomerRequest.ts | 12 - src/api/types/DataAttributeList.ts | 13 - src/api/types/DataEventList.ts | 25 - src/api/types/DataEventSummary.ts | 19 - src/api/types/DataEventSummaryItem.ts | 17 - src/api/types/DataExportCsv.ts | 59 - src/api/types/Datetime.ts | 9 - src/api/types/DeletedArticleObject.ts | 13 - src/api/types/DeletedCollectionObject.ts | 13 - src/api/types/DeletedCompanyObject.ts | 13 - src/api/types/DeletedInternalArticleObject.ts | 13 - src/api/types/DeletedObject.ts | 13 - src/api/types/EmailAddressHeader.ts | 13 - src/api/types/EmailMessageMetadata.ts | 13 - src/api/types/Error_.ts | 28 - src/api/types/EventDetails.ts | 10 - src/api/types/FileAttribute.ts | 20 - src/api/types/GroupContent.ts | 13 - src/api/types/GroupTranslatedContent.ts | 85 - src/api/types/InternalArticleList.ts | 16 - src/api/types/IpAllowlist.ts | 18 - src/api/types/LinkedObject.ts | 29 - src/api/types/LinkedObjectList.ts | 17 - src/api/types/Metadata.ts | 5 - src/api/types/MultipleFilterSearchRequest.ts | 28 - src/api/types/NewsItemRequest.ts | 34 - src/api/types/NotFoundErrorBody.ts | 23 - src/api/types/NoteList.ts | 15 - src/api/types/OffsetPages.ts | 13 - src/api/types/OpenConversationRequest.ts | 9 - src/api/types/OperatorWorkflowEvent.ts | 23 - src/api/types/PagesLink.ts | 15 - src/api/types/PaginatedResponse.ts | 25 - src/api/types/PaginatedResponseDataItem.ts | 17 - src/api/types/PartAttachment.ts | 21 - src/api/types/PhoneSwitch.ts | 11 - src/api/types/QuickReplyOption.ts | 8 - src/api/types/Recipient.ts | 20 - src/api/types/RedactConversationRequest.ts | 29 - src/api/types/Reference.ts | 11 - src/api/types/ReplyConversationRequest.ts | 7 - src/api/types/SearchRequest.ts | 15 - src/api/types/SegmentList.ts | 15 - src/api/types/SingleFilterSearchRequest.ts | 34 - src/api/types/SlaApplied.ts | 35 - src/api/types/SnoozeConversationRequest.ts | 11 - src/api/types/SocialProfile.ts | 13 - src/api/types/StartingAfterPaging.ts | 8 - src/api/types/SubscriptionTypeList.ts | 13 - src/api/types/TagCompanyRequest.ts | 24 - src/api/types/TagList.ts | 13 - src/api/types/TagMultipleUsersRequest.ts | 21 - src/api/types/Tags.ts | 13 - src/api/types/TeamList.ts | 13 - src/api/types/TeamPriorityLevel.ts | 11 - src/api/types/TicketCustomAttributes.ts | 6 - src/api/types/TicketList.ts | 16 - src/api/types/TicketPartAuthor.ts | 26 - src/api/types/TicketParts.ts | 15 - src/api/types/TicketReply.ts | 36 - .../types/TicketRequestCustomAttributes.ts | 6 - src/api/types/TicketStateList.ts | 13 - src/api/types/TicketTypeAttribute.ts | 55 - src/api/types/TicketTypeAttributeList.ts | 13 - src/api/types/TicketTypeList.ts | 13 - src/api/types/Translation.ts | 13 - src/api/types/UntagCompanyRequest.ts | 26 - src/api/types/UpdateArticleRequestBody.ts | 13 - src/api/types/UpdateCompanyRequestBody.ts | 21 - .../types/UpdateDataAttributeRequestBody.ts | 12 - src/api/types/UpdateVisitorRequest.ts | 16 - src/api/types/UpdateVisitorRequestOne.ts | 3 - src/api/types/Visitor.ts | 136 - src/api/types/VisitorDeletedObject.ts | 13 - src/api/types/WhatsappMessageStatusList.ts | 67 - src/api/types/index.ts | 164 +- src/api/types/types.ts | 3194 ++++ src/api/version.ts | 2 +- src/core/exports.ts | 1 + src/core/file/exports.ts | 1 + src/core/file/file.ts | 217 + src/core/file/index.ts | 2 + src/core/file/types.ts | 81 + src/core/form-data-utils/FormDataWrapper.ts | 140 + .../form-data-utils/encodeAsFormParameter.ts | 12 + src/core/form-data-utils/index.ts | 2 + src/core/index.ts | 2 + src/version.ts | 2 +- tests/unit/file/file.test.ts | 498 + .../encodeAsFormParameter.test.ts | 344 + .../form-data-utils/formDataWrapper.test.ts | 346 + tests/unit/test-file.txt | 1 + tests/wire/admins.test.ts | 42 +- tests/wire/aiContent.test.ts | 14 + tests/wire/articles.test.ts | 127 + tests/wire/awayStatusReasons.test.ts | 54 +- tests/wire/companies.test.ts | 150 +- tests/wire/contacts.test.ts | 39 +- tests/wire/conversations.test.ts | 2889 +--- tests/wire/customChannelEvents.test.ts | 790 - tests/wire/finAgent.test.ts | 973 ++ tests/wire/preview/admins.test.ts | 1296 ++ .../{unstable => preview}/aiContent.test.ts | 86 +- tests/wire/preview/articles.test.ts | 9186 +++++++++++ tests/wire/preview/audiences.test.ts | 542 + tests/wire/preview/authTokens.test.ts | 477 + .../awayStatusReasons.test.ts | 60 +- tests/wire/preview/banners.test.ts | 161 + .../wire/{unstable => preview}/brands.test.ts | 16 +- .../wire/{unstable => preview}/calls.test.ts | 175 +- .../{unstable => preview}/companies.test.ts | 1300 +- tests/wire/preview/contacts.test.ts | 5133 ++++++ tests/wire/preview/content.test.ts | 517 + tests/wire/preview/contentSnippets.test.ts | 711 + .../preview/conversationParticipants.test.ts | 405 + tests/wire/preview/conversationParts.test.ts | 1793 +++ .../conversations.test.ts | 13357 +++++++++------- .../preview/conversationsAttributes.test.ts | 990 ++ .../customObjectInstances.test.ts | 141 +- .../dataAttributes.test.ts | 51 +- tests/wire/preview/dataConnectors.test.ts | 1872 +++ .../{unstable => preview}/dataEvents.test.ts | 18 +- .../{unstable => preview}/dataExport.test.ts | 8 +- .../wire/{unstable => preview}/emails.test.ts | 16 +- tests/wire/preview/finAgent.test.ts | 2192 +++ tests/wire/preview/folders.test.ts | 477 + .../{unstable => preview}/helpCenter.test.ts | 606 +- .../identityVerificationSecrets.test.ts | 292 + .../internalArticles.test.ts | 474 +- tests/wire/{unstable => preview}/jobs.test.ts | 10 +- .../wire/{unstable => preview}/macros.test.ts | 44 +- .../{unstable => preview}/messages.test.ts | 217 +- tests/wire/{unstable => preview}/news.test.ts | 62 +- .../wire/{unstable => preview}/notes.test.ts | 493 +- tests/wire/preview/officeHours.test.ts | 1146 ++ tests/wire/preview/procedures.test.ts | 284 + .../reportingDataExport.test.ts} | 27 +- .../teams.test.ts => preview/roles.test.ts} | 86 +- .../{unstable => preview}/segments.test.ts | 16 +- .../subscriptionTypes.test.ts | 30 +- .../wire/{unstable => preview}/switch.test.ts | 14 +- tests/wire/{unstable => preview}/tags.test.ts | 365 +- tests/wire/preview/teams.test.ts | 449 + .../ticketStates.test.ts | 6 +- .../ticketTypeAttributes.test.ts | 12 +- .../{unstable => preview}/ticketTypes.test.ts | 18 +- .../{unstable => preview}/tickets.test.ts | 3727 ++++- .../{unstable => preview}/visitors.test.ts | 48 +- .../{unstable => preview}/workflows.test.ts | 10 +- ...rt.test.ts => reportingDataExport.test.ts} | 12 +- tests/wire/tags.test.ts | 149 +- tests/wire/tickets.test.ts | 146 +- tests/wire/unstable/admins.test.ts | 644 - tests/wire/unstable/articles.test.ts | 2141 --- tests/wire/unstable/contacts.test.ts | 2297 --- .../wire/unstable/customChannelEvents.test.ts | 796 - 1168 files changed, 89723 insertions(+), 33308 deletions(-) create mode 100644 .fern/replay.lock delete mode 100644 .github/workflows-disabled/ci.yml create mode 100644 src/api/resources/admins/client/requests/ListAdminsRequest.ts rename src/api/resources/admins/types/{Admin.ts => types.ts} (100%) rename src/api/resources/aiAgent/types/{AiAgent.ts => types.ts} (100%) delete mode 100644 src/api/resources/aiContent/types/ContentImportSource.ts delete mode 100644 src/api/resources/aiContent/types/ContentImportSourcesList.ts delete mode 100644 src/api/resources/aiContent/types/ExternalPage.ts delete mode 100644 src/api/resources/aiContent/types/ExternalPagesList.ts create mode 100644 src/api/resources/aiContent/types/types.ts rename src/api/resources/aiContentSource/types/{ContentSource.ts => types.ts} (100%) delete mode 100644 src/api/resources/articles/types/Article.ts delete mode 100644 src/api/resources/articles/types/ArticleListItem.ts delete mode 100644 src/api/resources/articles/types/ArticleSearchHighlights.ts delete mode 100644 src/api/resources/articles/types/ArticleSearchResponse.ts delete mode 100644 src/api/resources/articles/types/InternalArticle.ts create mode 100644 src/api/resources/articles/types/types.ts delete mode 100644 src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts rename src/api/resources/calls/types/{Call.ts => types.ts} (73%) delete mode 100644 src/api/resources/companies/types/CompaniesRetrieveResponse.ts rename src/api/resources/companies/types/{Company.ts => types.ts} (86%) delete mode 100644 src/api/resources/contacts/types/ContactsCreateResponse.ts delete mode 100644 src/api/resources/contacts/types/ContactsFindResponse.ts delete mode 100644 src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts delete mode 100644 src/api/resources/contacts/types/ContactsUpdateResponse.ts delete mode 100644 src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts rename src/api/resources/contacts/types/{Contact.ts => types.ts} (66%) delete mode 100644 src/api/resources/conversations/types/Conversation.ts delete mode 100644 src/api/resources/conversations/types/ConversationsManageRequestBody.ts create mode 100644 src/api/resources/conversations/types/types.ts delete mode 100644 src/api/resources/customChannelEvents/client/Client.ts delete mode 100644 src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts delete mode 100644 src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts delete mode 100644 src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts delete mode 100644 src/api/resources/customChannelEvents/client/requests/index.ts rename src/api/resources/customObjectInstances/types/{CustomObjectInstance.ts => types.ts} (100%) delete mode 100644 src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts rename src/api/resources/dataAttributes/types/{DataAttribute.ts => types.ts} (90%) rename src/api/resources/dataEvents/types/{DataEvent.ts => types.ts} (96%) delete mode 100644 src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts rename src/api/resources/dataExport/types/{DataExport.ts => types.ts} (59%) delete mode 100644 src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts delete mode 100644 src/api/resources/export/types/index.ts create mode 100644 src/api/resources/finAgent/client/Client.ts rename src/api/resources/{customChannelEvents => finAgent}/client/index.ts (100%) create mode 100644 src/api/resources/finAgent/client/requests/ReplyToFinRequest.ts create mode 100644 src/api/resources/finAgent/client/requests/StartFinConversationRequest.ts create mode 100644 src/api/resources/finAgent/client/requests/SubmitFinCsatRequest.ts create mode 100644 src/api/resources/finAgent/client/requests/index.ts rename src/api/resources/{export => finAgent}/index.ts (100%) create mode 100644 src/api/resources/finAgent/types/index.ts create mode 100644 src/api/resources/finAgent/types/types.ts delete mode 100644 src/api/resources/helpCenter/types/HelpCenter.ts delete mode 100644 src/api/resources/helpCenter/types/HelpCenterList.ts rename src/api/resources/helpCenter/types/{Collection.ts => types.ts} (60%) delete mode 100644 src/api/resources/internalArticles/types/InternalArticleListItem.ts delete mode 100644 src/api/resources/internalArticles/types/InternalArticleSearchResponse.ts rename src/api/resources/{unstable/resources/internalArticles/types/InternalArticleListItem.ts => internalArticles/types/types.ts} (53%) rename src/api/resources/jobs/types/{Jobs.ts => types.ts} (100%) rename src/api/resources/messages/types/{Message.ts => types.ts} (100%) delete mode 100644 src/api/resources/news/types/Newsfeed.ts delete mode 100644 src/api/resources/news/types/NewsfeedAssignment.ts rename src/api/resources/news/types/{NewsItem.ts => types.ts} (56%) rename src/api/resources/notes/types/{Note.ts => types.ts} (100%) rename src/api/resources/{unstable => preview}/client/Client.ts (63%) rename src/api/resources/{unstable => preview}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/errors/BadRequestError.ts (100%) rename src/api/resources/{unstable => preview}/errors/ConflictError.ts (86%) rename src/api/resources/{unstable => preview}/errors/ForbiddenError.ts (86%) create mode 100644 src/api/resources/preview/errors/GoneError.ts rename src/api/resources/{unstable => preview}/errors/InternalServerError.ts (86%) create mode 100644 src/api/resources/preview/errors/MethodNotAllowedError.ts rename src/api/resources/{unstable => preview}/errors/NotFoundError.ts (100%) create mode 100644 src/api/resources/preview/errors/ServiceUnavailableError.ts rename src/api/resources/{unstable => preview}/errors/TooManyRequestsError.ts (86%) rename src/api/resources/{unstable => preview}/errors/UnauthorizedError.ts (86%) rename src/api/resources/{unstable => preview}/errors/UnprocessableEntityError.ts (100%) rename src/api/resources/{unstable => preview}/errors/index.ts (72%) rename src/api/resources/{unstable => preview}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/admins/client/Client.ts rename src/api/resources/{export => preview/resources/admins}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/admins/client/requests/ListActivityLogsRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/admins/client/requests/ListAdminsRequest.ts create mode 100644 src/api/resources/preview/resources/admins/client/requests/RemoveAdminRequest.ts rename src/api/resources/{unstable => preview}/resources/admins/client/requests/RetrieveAdminRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/admins/client/requests/SearchActivityLogsRequest.ts rename src/api/resources/{unstable => preview}/resources/admins/client/requests/SetAwayAdminRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/admins/client/requests/index.ts (50%) rename src/api/resources/{unstable => preview}/resources/admins/index.ts (100%) create mode 100644 src/api/resources/preview/resources/admins/types/index.ts create mode 100644 src/api/resources/preview/resources/admins/types/types.ts rename src/api/resources/{unstable => preview}/resources/aiAgent/index.ts (100%) create mode 100644 src/api/resources/preview/resources/aiAgent/types/index.ts rename src/api/resources/{unstable/resources/aiAgent/types/AiAgent.ts => preview/resources/aiAgent/types/types.ts} (97%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/Client.ts (80%) rename src/api/resources/{unstable/resources/admins => preview/resources/aiContent}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts (60%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/CreateExternalPageRequest.ts (89%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/DeleteExternalPageRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/GetContentImportSourceRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/GetExternalPageRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts (67%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/UpdateExternalPageRequest.ts (76%) rename src/api/resources/{unstable => preview}/resources/aiContent/client/requests/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/aiContent/index.ts (100%) create mode 100644 src/api/resources/preview/resources/aiContent/types/index.ts create mode 100644 src/api/resources/preview/resources/aiContent/types/types.ts rename src/api/resources/{unstable => preview}/resources/aiContentSource/index.ts (100%) create mode 100644 src/api/resources/preview/resources/aiContentSource/types/index.ts rename src/api/resources/{unstable/resources/aiContentSource/types/ContentSource.ts => preview/resources/aiContentSource/types/types.ts} (95%) create mode 100644 src/api/resources/preview/resources/aiTopics/index.ts create mode 100644 src/api/resources/preview/resources/aiTopics/types/index.ts create mode 100644 src/api/resources/preview/resources/aiTopics/types/types.ts create mode 100644 src/api/resources/preview/resources/articles/client/Client.ts rename src/api/resources/{unstable/resources/aiContent => preview/resources/articles}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/articles/client/requests/AttachTagToArticleRequest.ts rename src/api/resources/{unstable => preview}/resources/articles/client/requests/DeleteArticleRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/articles/client/requests/DetachTagFromArticleRequest.ts create mode 100644 src/api/resources/preview/resources/articles/client/requests/FindArticleVersionRequest.ts create mode 100644 src/api/resources/preview/resources/articles/client/requests/ListArticleVersionsRequest.ts create mode 100644 src/api/resources/preview/resources/articles/client/requests/PublishArticleDraftRequest.ts create mode 100644 src/api/resources/preview/resources/articles/client/requests/RetrieveArticleDraftRequest.ts rename src/api/resources/{unstable => preview}/resources/articles/client/requests/RetrieveArticleRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/articles/client/requests/SearchArticlesRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/articles/client/requests/StageArticleDraftRequest.ts create mode 100644 src/api/resources/preview/resources/articles/client/requests/index.ts rename src/api/resources/{unstable => preview}/resources/articles/index.ts (100%) create mode 100644 src/api/resources/preview/resources/articles/types/index.ts create mode 100644 src/api/resources/preview/resources/articles/types/types.ts rename src/api/resources/{unstable/resources/admins => preview/resources/audiences}/client/Client.ts (52%) rename src/api/resources/{unstable/resources/articles => preview/resources/audiences}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/audiences/client/requests/CreateAudienceRequest.ts rename src/api/resources/{unstable/resources/contacts/client/requests/ShowContactRequest.ts => preview/resources/audiences/client/requests/DeleteAudienceRequest.ts} (51%) create mode 100644 src/api/resources/preview/resources/audiences/client/requests/ListAudiencesRequest.ts create mode 100644 src/api/resources/preview/resources/audiences/client/requests/RetrieveAudienceRequest.ts create mode 100644 src/api/resources/preview/resources/audiences/client/requests/UpdateAudienceRequest.ts create mode 100644 src/api/resources/preview/resources/audiences/client/requests/index.ts rename src/api/resources/{unstable/resources/brands => preview/resources/audiences}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/audiences/types/index.ts create mode 100644 src/api/resources/preview/resources/audiences/types/types.ts create mode 100644 src/api/resources/preview/resources/authTokens/client/Client.ts rename src/api/resources/{unstable/resources/brands => preview/resources/authTokens}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/authTokens/client/requests/CreateAuthTokenRequest.ts create mode 100644 src/api/resources/preview/resources/authTokens/client/requests/ListAuthTokensRequest.ts create mode 100644 src/api/resources/preview/resources/authTokens/client/requests/RetrieveAuthTokenRequest.ts create mode 100644 src/api/resources/preview/resources/authTokens/client/requests/UpdateAuthTokenRequest.ts create mode 100644 src/api/resources/preview/resources/authTokens/client/requests/index.ts rename src/api/resources/{unstable/resources/calls => preview/resources/authTokens}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/authTokens/types/index.ts create mode 100644 src/api/resources/preview/resources/authTokens/types/types.ts rename src/api/resources/{unstable => preview}/resources/awayStatusReasons/client/Client.ts (86%) rename src/api/resources/{unstable => preview}/resources/awayStatusReasons/client/index.ts (100%) rename src/api/resources/{customChannelEvents => preview/resources/awayStatusReasons}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/banners/client/Client.ts rename src/api/resources/{unstable/resources/calls => preview/resources/banners}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/banners/client/requests/DismissContactBannerRequest.ts rename src/api/resources/{unstable/resources/tickets/client/requests/GetTicketRequest.ts => preview/resources/banners/client/requests/ListContactBannersRequest.ts} (55%) create mode 100644 src/api/resources/preview/resources/banners/client/requests/index.ts rename src/api/resources/{unstable/resources/companies => preview/resources/banners}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/banners/types/index.ts create mode 100644 src/api/resources/preview/resources/banners/types/types.ts rename src/api/resources/{unstable => preview}/resources/brands/client/Client.ts (81%) rename src/api/resources/{unstable/resources/companies => preview/resources/brands}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/brands/client/requests/RetrieveBrandRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/brands/client/requests/index.ts (100%) rename src/api/resources/{unstable/resources/contacts => preview/resources/brands}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/brands/types/index.ts rename src/api/resources/{unstable/resources/brands/types/Brand.ts => preview/resources/brands/types/types.ts} (78%) rename src/api/resources/{unstable => preview}/resources/calls/client/Client.ts (71%) rename src/api/resources/{unstable/resources/contacts => preview/resources/calls}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/calls/client/requests/CollectFinVoiceCallByExternalIdRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/calls/client/requests/CollectFinVoiceCallByIdRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/calls/client/requests/CollectFinVoiceCallByPhoneNumberRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallsByConversationIdRequest.ts rename src/api/resources/{unstable => preview}/resources/calls/client/requests/ListCallsRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/calls/client/requests/ShowCallRecordingRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/calls/client/requests/ShowCallRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/calls/client/requests/ShowCallTranscriptRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/calls/client/requests/index.ts (85%) rename src/api/resources/{unstable/resources/conversations => preview/resources/calls}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/calls/types/index.ts rename src/api/resources/{unstable/resources/calls/types/Call.ts => preview/resources/calls/types/types.ts} (51%) create mode 100644 src/api/resources/preview/resources/companies/client/Client.ts rename src/api/resources/{unstable/resources/conversations => preview/resources/companies}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/AttachContactToACompanyRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/companies/client/requests/BulkCreateCompaniesRequest.ts create mode 100644 src/api/resources/preview/resources/companies/client/requests/BulkDeleteCompaniesRequest.ts create mode 100644 src/api/resources/preview/resources/companies/client/requests/BulkUpdateCompaniesRequest.ts create mode 100644 src/api/resources/preview/resources/companies/client/requests/CompanySearchRequest.ts rename src/api/resources/{unstable => preview}/resources/companies/client/requests/DeleteCompanyRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/DetachContactFromACompanyRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/ListAllCompaniesRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/ListAttachedContactsRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/RetrieveCompanyRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/companies/client/requests/ShowBulkCompaniesJobRequest.ts rename src/api/resources/{unstable => preview}/resources/companies/client/requests/UpdateCompanyRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/companies/client/requests/index.ts (67%) rename src/api/resources/{unstable/resources/customObjectInstances => preview/resources/companies}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/companies/types/index.ts rename src/api/resources/{unstable/resources/companies/types/Company.ts => preview/resources/companies/types/types.ts} (52%) create mode 100644 src/api/resources/preview/resources/contacts/client/Client.ts rename src/api/resources/{unstable/resources/customChannelEvents => preview/resources/contacts}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/ArchiveContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/BlockContactRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/contacts/client/requests/BulkCreateContactsRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/BulkDeleteContactsRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/BulkUpdateContactsRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ContactSearchRequest.ts rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/DeleteContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ListContactActivitiesRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ListContactMergeHistoryRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ListContactsRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ListDeletedContactsRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ListGrantedCompaniesForAContactRequest.ts rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/ListTagsForAContactRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/contacts/client/requests/MergeContactsRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/MergePreviewRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/RemoveGrantedCompanyFromAContactRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ReplaceGrantedCompaniesRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ShowBulkUpdateContactsJobRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts create mode 100644 src/api/resources/preview/resources/contacts/client/requests/ShowContactRequest.ts rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/UnarchiveContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/contacts/client/requests/UpdateContactRequest.ts (55%) create mode 100644 src/api/resources/preview/resources/contacts/client/requests/index.ts rename src/api/resources/{unstable/resources/dataAttributes => preview/resources/contacts}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/contacts/types/index.ts create mode 100644 src/api/resources/preview/resources/contacts/types/types.ts create mode 100644 src/api/resources/preview/resources/content/client/Client.ts rename src/api/resources/{unstable/resources/customObjectInstances => preview/resources/content}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/content/client/requests/ContentBulkActionRequest.ts create mode 100644 src/api/resources/preview/resources/content/client/requests/SearchContentRequest.ts create mode 100644 src/api/resources/preview/resources/content/client/requests/index.ts rename src/api/resources/{unstable/resources/dataEvents => preview/resources/content}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/content/types/index.ts create mode 100644 src/api/resources/preview/resources/content/types/types.ts rename src/api/resources/{unstable/resources/helpCenter => preview/resources/contentSnippets}/client/Client.ts (52%) rename src/api/resources/{unstable/resources/dataAttributes => preview/resources/contentSnippets}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/contentSnippets/client/requests/AttachTagToContentSnippetRequest.ts create mode 100644 src/api/resources/preview/resources/contentSnippets/client/requests/ContentSnippetCreateRequest.ts create mode 100644 src/api/resources/preview/resources/contentSnippets/client/requests/ContentSnippetUpdateRequest.ts create mode 100644 src/api/resources/preview/resources/contentSnippets/client/requests/DeleteContentSnippetRequest.ts create mode 100644 src/api/resources/preview/resources/contentSnippets/client/requests/DetachTagFromContentSnippetRequest.ts create mode 100644 src/api/resources/preview/resources/contentSnippets/client/requests/GetContentSnippetRequest.ts create mode 100644 src/api/resources/preview/resources/contentSnippets/client/requests/ListContentSnippetsRequest.ts create mode 100644 src/api/resources/preview/resources/contentSnippets/client/requests/index.ts rename src/api/resources/{unstable/resources/dataExport => preview/resources/contentSnippets}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/contentSnippets/types/index.ts create mode 100644 src/api/resources/preview/resources/contentSnippets/types/types.ts create mode 100644 src/api/resources/preview/resources/conversation/index.ts create mode 100644 src/api/resources/preview/resources/conversation/types/index.ts create mode 100644 src/api/resources/preview/resources/conversation/types/types.ts create mode 100644 src/api/resources/preview/resources/conversationParticipants/client/Client.ts rename src/api/resources/{unstable/resources/dataEvents => preview/resources/conversationParticipants}/client/index.ts (100%) rename src/api/resources/{unstable/resources/conversations => preview/resources/conversationParticipants}/client/requests/AttachContactToConversationRequest.ts (82%) rename src/api/resources/{unstable/resources/conversations => preview/resources/conversationParticipants}/client/requests/DetachContactFromConversationRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/conversationParticipants/client/requests/index.ts rename src/api/resources/{unstable/resources/awayStatusReasons => preview/resources/conversationParticipants}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/conversationParts/client/Client.ts rename src/api/resources/{unstable/resources/dataExport => preview/resources/conversationParts}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/conversationParts/client/requests/UpdateConversationPartRequest.ts create mode 100644 src/api/resources/preview/resources/conversationParts/client/requests/index.ts rename src/api/resources/{unstable/resources/customChannelEvents => preview/resources/conversationParts}/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/conversations/client/Client.ts (65%) rename src/api/resources/{unstable/resources/emails => preview/resources/conversations}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts (76%) rename src/api/resources/{unstable => preview}/resources/conversations/client/requests/CreateConversationRequest.ts (77%) create mode 100644 src/api/resources/preview/resources/conversations/client/requests/DeleteConversationRequest.ts create mode 100644 src/api/resources/preview/resources/conversations/client/requests/ListConversationsRequest.ts create mode 100644 src/api/resources/preview/resources/conversations/client/requests/ListDeletedConversationIdsRequest.ts rename src/api/resources/{unstable => preview}/resources/conversations/client/requests/ListHandlingEventsRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/conversations/client/requests/ListHitlEventsRequest.ts create mode 100644 src/api/resources/preview/resources/conversations/client/requests/ListSideConversationsRequest.ts rename src/api/resources/{unstable => preview}/resources/conversations/client/requests/ManageConversationRequest.ts (95%) create mode 100644 src/api/resources/preview/resources/conversations/client/requests/MergeConversationsRequestBody.ts rename src/api/resources/{unstable => preview}/resources/conversations/client/requests/ReplyConversationRequest.ts (97%) create mode 100644 src/api/resources/preview/resources/conversations/client/requests/RetrieveConversationRequest.ts create mode 100644 src/api/resources/preview/resources/conversations/client/requests/SearchConversationsRequest.ts rename src/api/resources/{unstable => preview}/resources/conversations/client/requests/UpdateConversationRequest.ts (50%) rename src/api/resources/{unstable => preview}/resources/conversations/client/requests/index.ts (63%) rename src/api/resources/{unstable/resources/emails => preview/resources/conversations}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/conversations/types/index.ts create mode 100644 src/api/resources/preview/resources/conversations/types/types.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/Client.ts rename src/api/resources/{unstable/resources/export => preview/resources/conversationsAttributes}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/requests/CreateConversationAttributeOptionRequest.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/requests/DeleteConversationAttributeOptionRequest.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/requests/DeleteConversationAttributeRequest.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/requests/GetConversationAttributeRequest.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/requests/ListConversationAttributesRequest.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/requests/UpdateConversationAttributeOptionRequest.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/requests/UpdateConversationAttributeRequest.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/client/requests/index.ts rename src/api/resources/{unstable/resources/export => preview/resources/conversationsAttributes}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/conversationsAttributes/types/index.ts create mode 100644 src/api/resources/preview/resources/conversationsAttributes/types/types.ts rename src/api/resources/{unstable => preview}/resources/customObjectInstances/client/Client.ts (71%) rename src/api/resources/{unstable/resources/helpCenter => preview/resources/customObjectInstances}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/customObjectInstances/client/requests/ListCustomObjectInstancesRequest.ts rename src/api/resources/{unstable => preview}/resources/customObjectInstances/client/requests/index.ts (79%) rename src/api/resources/{unstable/resources/helpCenter => preview/resources/customObjectInstances}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/customObjectInstances/types/index.ts rename src/api/resources/{unstable/resources/customObjectInstances/types/CustomObjectInstance.ts => preview/resources/customObjectInstances/types/types.ts} (73%) rename src/api/resources/{unstable => preview}/resources/dataAttributes/client/Client.ts (74%) rename src/api/resources/{unstable/resources/internalArticles => preview/resources/dataAttributes}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts (68%) rename src/api/resources/{unstable => preview}/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataAttributes/client/requests/index.ts (100%) rename src/api/resources/{unstable/resources/internalArticles => preview/resources/dataAttributes}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/dataAttributes/types/index.ts rename src/api/resources/{unstable/resources/dataAttributes/types/DataAttribute.ts => preview/resources/dataAttributes/types/types.ts} (80%) create mode 100644 src/api/resources/preview/resources/dataConnectors/client/Client.ts rename src/api/resources/{unstable/resources/jobs => preview/resources/dataConnectors}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/dataConnectors/client/requests/CreateDataConnectorRequest.ts create mode 100644 src/api/resources/preview/resources/dataConnectors/client/requests/DeleteDataConnectorRequest.ts create mode 100644 src/api/resources/preview/resources/dataConnectors/client/requests/ListDataConnectorExecutionResultsRequest.ts create mode 100644 src/api/resources/preview/resources/dataConnectors/client/requests/ListDataConnectorsRequest.ts create mode 100644 src/api/resources/preview/resources/dataConnectors/client/requests/RetrieveDataConnectorRequest.ts create mode 100644 src/api/resources/preview/resources/dataConnectors/client/requests/ShowDataConnectorExecutionResultRequest.ts create mode 100644 src/api/resources/preview/resources/dataConnectors/client/requests/UpdateDataConnectorRequest.ts create mode 100644 src/api/resources/preview/resources/dataConnectors/client/requests/index.ts rename src/api/resources/{unstable/resources/jobs => preview/resources/dataConnectors}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/dataConnectors/types/index.ts create mode 100644 src/api/resources/preview/resources/dataConnectors/types/types.ts rename src/api/resources/{unstable => preview}/resources/dataEvents/client/Client.ts (91%) rename src/api/resources/{unstable/resources/macros => preview/resources/dataEvents}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataEvents/client/requests/LisDataEventsRequest.ts (87%) rename src/api/resources/{unstable => preview}/resources/dataEvents/client/requests/index.ts (100%) rename src/api/resources/{unstable/resources/macros => preview/resources/dataEvents}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/dataEvents/types/index.ts rename src/api/resources/{unstable/resources/dataEvents/types/DataEvent.ts => preview/resources/dataEvents/types/types.ts} (81%) rename src/api/resources/{unstable => preview}/resources/dataExport/client/Client.ts (84%) rename src/api/resources/{unstable/resources/messages => preview/resources/dataExport}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataExport/client/requests/CancelDataExportRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataExport/client/requests/CreateDataExportsRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataExport/client/requests/DownloadDataExportRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataExport/client/requests/GetDataExportRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/dataExport/client/requests/index.ts (100%) rename src/api/resources/{unstable/resources/messages => preview/resources/dataExport}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/dataExport/types/index.ts rename src/api/resources/{unstable/resources/dataExport/types/DataExport.ts => preview/resources/dataExport/types/types.ts} (67%) create mode 100644 src/api/resources/preview/resources/ecommerceConnectors/client/Client.ts rename src/api/resources/{unstable/resources/news => preview/resources/ecommerceConnectors}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/ecommerceConnectors/client/requests/UploadEcommerceCatalogRequest.ts create mode 100644 src/api/resources/preview/resources/ecommerceConnectors/client/requests/index.ts rename src/api/resources/{unstable/resources/switch => preview/resources/ecommerceConnectors}/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/emails/client/Client.ts (81%) rename src/api/resources/{unstable/resources/notes => preview/resources/emails}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/emails/client/requests/RetrieveEmailRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/emails/client/requests/index.ts (100%) rename src/api/resources/{unstable/resources/news => preview/resources/emails}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/emails/types/index.ts rename src/api/resources/{unstable/resources/emails/types/EmailSetting.ts => preview/resources/emails/types/types.ts} (79%) create mode 100644 src/api/resources/preview/resources/finAgent/client/Client.ts rename src/api/resources/{unstable/resources/segments => preview/resources/finAgent}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/finAgent/client/requests/AskFinRequest.ts create mode 100644 src/api/resources/preview/resources/finAgent/client/requests/ListFinCapabilitiesRequest.ts create mode 100644 src/api/resources/preview/resources/finAgent/client/requests/ReplyToFinRequest.ts create mode 100644 src/api/resources/preview/resources/finAgent/client/requests/RunFinProcedureRequest.ts create mode 100644 src/api/resources/preview/resources/finAgent/client/requests/StartFinConversationRequest.ts create mode 100644 src/api/resources/preview/resources/finAgent/client/requests/SubmitFinCsatRequest.ts create mode 100644 src/api/resources/preview/resources/finAgent/client/requests/index.ts rename src/api/resources/{unstable/resources/notes => preview/resources/finAgent}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/finAgent/types/index.ts create mode 100644 src/api/resources/preview/resources/finAgent/types/types.ts rename src/api/resources/{unstable/resources/articles => preview/resources/folders}/client/Client.ts (56%) rename src/api/resources/{unstable/resources/subscriptionTypes => preview/resources/folders}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/folders/client/requests/CreateFolderRequest.ts create mode 100644 src/api/resources/preview/resources/folders/client/requests/DeleteFolderRequest.ts create mode 100644 src/api/resources/preview/resources/folders/client/requests/ListFoldersRequest.ts create mode 100644 src/api/resources/preview/resources/folders/client/requests/RetrieveFolderRequest.ts create mode 100644 src/api/resources/preview/resources/folders/client/requests/UpdateFolderRequest.ts create mode 100644 src/api/resources/preview/resources/folders/client/requests/index.ts rename src/api/resources/{unstable/resources/segments => preview/resources/folders}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/folders/types/index.ts create mode 100644 src/api/resources/preview/resources/folders/types/types.ts rename src/api/resources/{unstable/resources/companies => preview/resources/helpCenter}/client/Client.ts (51%) rename src/api/resources/{unstable/resources/tags => preview/resources/helpCenter}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/helpCenter/client/requests/CreateCollectionRequest.ts (93%) create mode 100644 src/api/resources/preview/resources/helpCenter/client/requests/CreateHelpCenterRedirectRequest.ts rename src/api/resources/{unstable => preview}/resources/helpCenter/client/requests/DeleteCollectionRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/helpCenter/client/requests/DeleteHelpCenterRedirectRequest.ts create mode 100644 src/api/resources/preview/resources/helpCenter/client/requests/ListHelpCenterRedirectsRequest.ts rename src/api/resources/{unstable => preview}/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/helpCenter/client/requests/RetrieveHelpCenterRedirectRequest.ts rename src/api/resources/{unstable => preview}/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/helpCenter/client/requests/UpdateCollectionRequest.ts (93%) rename src/api/resources/{unstable => preview}/resources/helpCenter/client/requests/index.ts (51%) rename src/api/resources/{unstable/resources/subscriptionTypes => preview/resources/helpCenter}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/helpCenter/types/index.ts create mode 100644 src/api/resources/preview/resources/helpCenter/types/types.ts create mode 100644 src/api/resources/preview/resources/identityVerificationSecrets/client/Client.ts rename src/api/resources/{unstable/resources/teams => preview/resources/identityVerificationSecrets}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/identityVerificationSecrets/client/requests/CreateIdentityVerificationSecretRequest.ts create mode 100644 src/api/resources/preview/resources/identityVerificationSecrets/client/requests/DeleteIdentityVerificationSecretRequest.ts create mode 100644 src/api/resources/preview/resources/identityVerificationSecrets/client/requests/index.ts rename src/api/resources/{unstable/resources/tags => preview/resources/identityVerificationSecrets}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/identityVerificationSecrets/types/index.ts create mode 100644 src/api/resources/preview/resources/identityVerificationSecrets/types/types.ts rename src/api/resources/{unstable => preview}/resources/index.ts (60%) rename src/api/resources/{unstable => preview}/resources/internalArticles/client/Client.ts (55%) rename src/api/resources/{unstable/resources/ticketTypeAttributes => preview/resources/internalArticles}/client/index.ts (100%) create mode 100644 src/api/resources/preview/resources/internalArticles/client/requests/AttachTagToInternalArticleRequest.ts rename src/api/resources/{unstable => preview}/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/internalArticles/client/requests/DetachTagFromInternalArticleRequest.ts rename src/api/resources/{unstable => preview}/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts create mode 100644 src/api/resources/preview/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts rename src/api/resources/{unstable => preview}/resources/internalArticles/client/requests/index.ts (64%) rename src/api/resources/{unstable/resources/teams => preview/resources/internalArticles}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/internalArticles/types/index.ts create mode 100644 src/api/resources/preview/resources/internalArticles/types/types.ts rename src/api/resources/{unstable => preview}/resources/jobs/client/Client.ts (81%) rename src/api/resources/{unstable/resources/ticketTypes => preview/resources/jobs}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/jobs/client/requests/JobsStatusRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/jobs/client/requests/index.ts (100%) rename src/api/resources/{unstable/resources/tickets => preview/resources/jobs}/index.ts (100%) create mode 100644 src/api/resources/preview/resources/jobs/types/index.ts rename src/api/resources/{unstable/resources/jobs/types/Jobs.ts => preview/resources/jobs/types/types.ts} (100%) rename src/api/resources/{unstable => preview}/resources/macros/client/Client.ts (79%) rename src/api/resources/{unstable/resources/tickets => preview/resources/macros}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/macros/client/requests/GetMacroRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/macros/client/requests/ListMacrosRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/macros/client/requests/index.ts (100%) create mode 100644 src/api/resources/preview/resources/macros/index.ts create mode 100644 src/api/resources/preview/resources/macros/types/index.ts rename src/api/resources/{unstable/resources/macros/types/Macro.ts => preview/resources/macros/types/types.ts} (64%) rename src/api/resources/{unstable => preview}/resources/messages/client/Client.ts (63%) rename src/api/resources/{unstable/resources/visitors => preview/resources/messages}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/messages/client/requests/RetrieveWhatsAppMessageStatusRequest.ts create mode 100644 src/api/resources/preview/resources/messages/client/requests/index.ts create mode 100644 src/api/resources/preview/resources/messages/index.ts create mode 100644 src/api/resources/preview/resources/messages/types/index.ts rename src/api/resources/{unstable/resources/messages/types/Message.ts => preview/resources/messages/types/types.ts} (100%) rename src/api/resources/{unstable => preview}/resources/news/client/Client.ts (79%) rename src/api/resources/{unstable/resources/workflows => preview/resources/news}/client/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/news/client/requests/DeleteNewsItemRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/news/client/requests/RetrieveNewsItemRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/news/client/requests/RetrieveNewsfeedRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/news/client/requests/UpdateNewsItemRequest.ts (95%) rename src/api/resources/{unstable => preview}/resources/news/client/requests/index.ts (100%) create mode 100644 src/api/resources/preview/resources/news/index.ts create mode 100644 src/api/resources/preview/resources/news/types/index.ts rename src/api/resources/{unstable/resources/news/types/NewsItem.ts => preview/resources/news/types/types.ts} (58%) create mode 100644 src/api/resources/preview/resources/notes/client/Client.ts create mode 100644 src/api/resources/preview/resources/notes/client/index.ts create mode 100644 src/api/resources/preview/resources/notes/client/requests/CreateCompanyNoteRequest.ts rename src/api/resources/{unstable => preview}/resources/notes/client/requests/CreateNoteRequest.ts (100%) rename src/api/resources/{unstable/resources/conversations/client/requests/DeleteConversationRequest.ts => preview/resources/notes/client/requests/DeleteNoteRequest.ts} (61%) rename src/api/resources/{unstable => preview}/resources/notes/client/requests/ListCompanyNotesRequest.ts (72%) rename src/api/resources/{unstable => preview}/resources/notes/client/requests/ListNotesRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/notes/client/requests/RetrieveNoteRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/notes/client/requests/index.ts (65%) create mode 100644 src/api/resources/preview/resources/notes/index.ts create mode 100644 src/api/resources/preview/resources/notes/types/index.ts create mode 100644 src/api/resources/preview/resources/notes/types/types.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/Client.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/index.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/CreateOfficeHoursExceptionRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/CreateOfficeHoursScheduleRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/DeleteOfficeHoursExceptionRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/DeleteOfficeHoursScheduleRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/GetOfficeHoursExceptionRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/GetOfficeHoursScheduleRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/ListOfficeHoursExceptionsRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/UpdateOfficeHoursExceptionRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/UpdateOfficeHoursScheduleRequest.ts create mode 100644 src/api/resources/preview/resources/officeHours/client/requests/index.ts create mode 100644 src/api/resources/preview/resources/officeHours/index.ts create mode 100644 src/api/resources/preview/resources/officeHours/types/index.ts create mode 100644 src/api/resources/preview/resources/officeHours/types/types.ts create mode 100644 src/api/resources/preview/resources/procedures/client/Client.ts create mode 100644 src/api/resources/preview/resources/procedures/client/index.ts create mode 100644 src/api/resources/preview/resources/procedures/client/requests/CollectAgentInputRequest.ts create mode 100644 src/api/resources/preview/resources/procedures/client/requests/index.ts rename src/api/resources/{unstable/resources/ticketStates => preview/resources/procedures}/index.ts (100%) rename src/api/resources/{unstable/resources/export => preview/resources/reportingDataExport}/client/Client.ts (69%) create mode 100644 src/api/resources/preview/resources/reportingDataExport/client/index.ts rename src/api/resources/{unstable/resources/export => preview/resources/reportingDataExport}/client/requests/PostExportReportingDataEnqueueRequest.ts (67%) rename src/api/resources/{export => preview/resources/reportingDataExport}/client/requests/index.ts (100%) create mode 100644 src/api/resources/preview/resources/reportingDataExport/index.ts create mode 100644 src/api/resources/preview/resources/reportingDataExport/types/index.ts rename src/api/resources/{unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts => preview/resources/reportingDataExport/types/types.ts} (57%) rename src/api/resources/{unstable/resources/teams => preview/resources/roles}/client/Client.ts (64%) create mode 100644 src/api/resources/preview/resources/roles/client/index.ts create mode 100644 src/api/resources/preview/resources/roles/client/requests/RetrieveRoleRequest.ts create mode 100644 src/api/resources/preview/resources/roles/client/requests/index.ts create mode 100644 src/api/resources/preview/resources/roles/index.ts create mode 100644 src/api/resources/preview/resources/roles/types/index.ts create mode 100644 src/api/resources/preview/resources/roles/types/types.ts create mode 100644 src/api/resources/preview/resources/salesAgent/index.ts create mode 100644 src/api/resources/preview/resources/salesAgent/types/index.ts create mode 100644 src/api/resources/preview/resources/salesAgent/types/types.ts rename src/api/resources/{unstable => preview}/resources/segments/client/Client.ts (80%) create mode 100644 src/api/resources/preview/resources/segments/client/index.ts rename src/api/resources/{unstable => preview}/resources/segments/client/requests/ListSegmentsRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/segments/client/requests/RetrieveSegmentRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/segments/client/requests/index.ts (100%) create mode 100644 src/api/resources/preview/resources/segments/index.ts create mode 100644 src/api/resources/preview/resources/segments/types/index.ts rename src/api/resources/{segments/types/Segment.ts => preview/resources/segments/types/types.ts} (100%) rename src/api/resources/{unstable => preview}/resources/subscriptionTypes/client/Client.ts (80%) create mode 100644 src/api/resources/preview/resources/subscriptionTypes/client/index.ts rename src/api/resources/{unstable => preview}/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/subscriptionTypes/client/requests/index.ts (100%) create mode 100644 src/api/resources/preview/resources/subscriptionTypes/index.ts create mode 100644 src/api/resources/preview/resources/subscriptionTypes/types/index.ts rename src/api/resources/{unstable/resources/subscriptionTypes/types/SubscriptionType.ts => preview/resources/subscriptionTypes/types/types.ts} (93%) rename src/api/resources/{unstable => preview}/resources/switch/client/Client.ts (83%) rename src/api/resources/{unstable => preview}/resources/switch/client/index.ts (100%) rename src/api/resources/{unstable/resources/ticketTypeAttributes => preview/resources/switch}/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/Client.ts (77%) create mode 100644 src/api/resources/preview/resources/tags/client/index.ts rename src/api/resources/{unstable => preview}/resources/tags/client/requests/AttachTagToContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/requests/AttachTagToConversationRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/requests/AttachTagToTicketRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/requests/DeleteTagRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/requests/DetachTagFromContactRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/requests/DetachTagFromConversationRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/requests/DetachTagFromTicketRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/requests/FindTagRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/tags/client/requests/index.ts (100%) create mode 100644 src/api/resources/preview/resources/tags/index.ts create mode 100644 src/api/resources/preview/resources/tags/types/index.ts create mode 100644 src/api/resources/preview/resources/tags/types/types.ts rename src/api/resources/{unstable/resources/notes => preview/resources/teams}/client/Client.ts (51%) create mode 100644 src/api/resources/preview/resources/teams/client/index.ts create mode 100644 src/api/resources/preview/resources/teams/client/requests/GetTeamMetricsRequest.ts rename src/api/resources/{unstable => preview}/resources/teams/client/requests/RetrieveTeamRequest.ts (100%) create mode 100644 src/api/resources/preview/resources/teams/client/requests/UpdateTeamMembersRequest.ts create mode 100644 src/api/resources/preview/resources/teams/client/requests/index.ts create mode 100644 src/api/resources/preview/resources/teams/index.ts create mode 100644 src/api/resources/preview/resources/teams/types/index.ts rename src/api/resources/{unstable/resources/teams/types/Team.ts => preview/resources/teams/types/types.ts} (57%) rename src/api/resources/{unstable => preview}/resources/ticketStates/client/Client.ts (87%) rename src/api/resources/{unstable => preview}/resources/ticketStates/client/index.ts (100%) rename src/api/resources/{unstable/resources/ticketTypes => preview/resources/ticketStates}/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/ticketTypeAttributes/client/Client.ts (82%) create mode 100644 src/api/resources/preview/resources/ticketTypeAttributes/client/index.ts rename src/api/resources/{unstable => preview}/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/ticketTypeAttributes/client/requests/index.ts (100%) rename src/api/resources/{unstable/resources/visitors => preview/resources/ticketTypeAttributes}/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/ticketTypes/client/Client.ts (84%) create mode 100644 src/api/resources/preview/resources/ticketTypes/client/index.ts rename src/api/resources/{unstable => preview}/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/ticketTypes/client/requests/index.ts (100%) rename src/api/resources/{unstable/resources/workflows => preview/resources/ticketTypes}/index.ts (100%) rename src/api/resources/{unstable => preview}/resources/tickets/client/Client.ts (56%) create mode 100644 src/api/resources/preview/resources/tickets/client/index.ts create mode 100644 src/api/resources/preview/resources/tickets/client/requests/ChangeTicketTypeRequest.ts create mode 100644 src/api/resources/preview/resources/tickets/client/requests/DeleteTicketRequest.ts rename src/api/resources/{unstable => preview}/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts (80%) create mode 100644 src/api/resources/preview/resources/tickets/client/requests/GetTicketRequest.ts create mode 100644 src/api/resources/preview/resources/tickets/client/requests/LinkConversationToTicketRequest.ts rename src/api/resources/{unstable => preview}/resources/tickets/client/requests/ReplyTicketRequest.ts (72%) create mode 100644 src/api/resources/preview/resources/tickets/client/requests/UnlinkConversationFromTicketRequest.ts rename src/api/resources/{unstable => preview}/resources/tickets/client/requests/UpdateTicketRequest.ts (53%) rename src/api/resources/{unstable => preview}/resources/tickets/client/requests/index.ts (56%) create mode 100644 src/api/resources/preview/resources/tickets/index.ts create mode 100644 src/api/resources/preview/resources/tickets/types/index.ts create mode 100644 src/api/resources/preview/resources/tickets/types/types.ts rename src/api/resources/{unstable => preview}/resources/visitors/client/Client.ts (80%) create mode 100644 src/api/resources/preview/resources/visitors/client/index.ts rename src/api/resources/{unstable => preview}/resources/visitors/client/requests/ConvertVisitorRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/visitors/client/requests/index.ts (100%) create mode 100644 src/api/resources/preview/resources/visitors/index.ts rename src/api/resources/{unstable => preview}/resources/workflows/client/Client.ts (78%) create mode 100644 src/api/resources/preview/resources/workflows/client/index.ts rename src/api/resources/{unstable => preview}/resources/workflows/client/requests/ExportWorkflowRequest.ts (100%) rename src/api/resources/{unstable => preview}/resources/workflows/client/requests/index.ts (100%) create mode 100644 src/api/resources/preview/resources/workflows/index.ts create mode 100644 src/api/resources/preview/types/index.ts create mode 100644 src/api/resources/preview/types/types.ts rename src/api/resources/{export => reportingDataExport}/client/Client.ts (89%) create mode 100644 src/api/resources/reportingDataExport/client/index.ts rename src/api/resources/{export => reportingDataExport}/client/requests/PostExportReportingDataEnqueueRequest.ts (100%) rename src/api/resources/{unstable/resources/export => reportingDataExport}/client/requests/index.ts (100%) create mode 100644 src/api/resources/reportingDataExport/index.ts create mode 100644 src/api/resources/reportingDataExport/types/index.ts rename src/api/resources/{export/types/GetExportReportingDataGetDatasetsResponse.ts => reportingDataExport/types/types.ts} (83%) rename src/api/resources/{unstable/resources/segments/types/Segment.ts => segments/types/types.ts} (85%) rename src/api/resources/subscriptionTypes/types/{SubscriptionType.ts => types.ts} (100%) delete mode 100644 src/api/resources/tags/types/Tag.ts delete mode 100644 src/api/resources/tags/types/TagBasic.ts delete mode 100644 src/api/resources/tags/types/TagsCreateRequestBody.ts create mode 100644 src/api/resources/tags/types/types.ts rename src/api/resources/teams/types/{Team.ts => types.ts} (89%) delete mode 100644 src/api/resources/tickets/types/DeleteTicketResponse.ts delete mode 100644 src/api/resources/tickets/types/Ticket.ts delete mode 100644 src/api/resources/tickets/types/TicketContacts.ts delete mode 100644 src/api/resources/tickets/types/TicketPart.ts delete mode 100644 src/api/resources/tickets/types/TicketState.ts delete mode 100644 src/api/resources/tickets/types/TicketStateDetailed.ts delete mode 100644 src/api/resources/tickets/types/TicketType.ts delete mode 100644 src/api/resources/tickets/types/TicketsReplyRequestBody.ts create mode 100644 src/api/resources/tickets/types/types.ts delete mode 100644 src/api/resources/unstable/resources/admins/types/Admin.ts delete mode 100644 src/api/resources/unstable/resources/admins/types/index.ts delete mode 100644 src/api/resources/unstable/resources/aiAgent/types/index.ts delete mode 100644 src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts delete mode 100644 src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts delete mode 100644 src/api/resources/unstable/resources/aiContent/types/ExternalPage.ts delete mode 100644 src/api/resources/unstable/resources/aiContent/types/ExternalPagesList.ts delete mode 100644 src/api/resources/unstable/resources/aiContent/types/index.ts delete mode 100644 src/api/resources/unstable/resources/aiContentSource/types/index.ts delete mode 100644 src/api/resources/unstable/resources/articles/client/requests/index.ts delete mode 100644 src/api/resources/unstable/resources/articles/types/Article.ts delete mode 100644 src/api/resources/unstable/resources/articles/types/ArticleListItem.ts delete mode 100644 src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts delete mode 100644 src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts delete mode 100644 src/api/resources/unstable/resources/articles/types/InternalArticle.ts delete mode 100644 src/api/resources/unstable/resources/articles/types/index.ts delete mode 100644 src/api/resources/unstable/resources/brands/types/BrandList.ts delete mode 100644 src/api/resources/unstable/resources/brands/types/index.ts delete mode 100644 src/api/resources/unstable/resources/calls/types/ListCallsWithTranscriptsResponse.ts delete mode 100644 src/api/resources/unstable/resources/calls/types/index.ts delete mode 100644 src/api/resources/unstable/resources/companies/types/index.ts delete mode 100644 src/api/resources/unstable/resources/contacts/client/Client.ts delete mode 100644 src/api/resources/unstable/resources/contacts/client/requests/MergeContactsRequest.ts delete mode 100644 src/api/resources/unstable/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts delete mode 100644 src/api/resources/unstable/resources/contacts/client/requests/index.ts delete mode 100644 src/api/resources/unstable/resources/contacts/types/Contact.ts delete mode 100644 src/api/resources/unstable/resources/contacts/types/CreateContactResponse.ts delete mode 100644 src/api/resources/unstable/resources/contacts/types/MergeContactResponse.ts delete mode 100644 src/api/resources/unstable/resources/contacts/types/ShowContactByExternalIdResponse.ts delete mode 100644 src/api/resources/unstable/resources/contacts/types/ShowContactResponse.ts delete mode 100644 src/api/resources/unstable/resources/contacts/types/UpdateContactResponse.ts delete mode 100644 src/api/resources/unstable/resources/contacts/types/index.ts delete mode 100644 src/api/resources/unstable/resources/conversations/client/requests/ListConversationsRequest.ts delete mode 100644 src/api/resources/unstable/resources/conversations/client/requests/RetrieveConversationRequest.ts delete mode 100644 src/api/resources/unstable/resources/conversations/types/Conversation.ts delete mode 100644 src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts delete mode 100644 src/api/resources/unstable/resources/conversations/types/index.ts delete mode 100644 src/api/resources/unstable/resources/customChannelEvents/client/Client.ts delete mode 100644 src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts delete mode 100644 src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts delete mode 100644 src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts delete mode 100644 src/api/resources/unstable/resources/customChannelEvents/client/requests/index.ts delete mode 100644 src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts delete mode 100644 src/api/resources/unstable/resources/customObjectInstances/types/index.ts delete mode 100644 src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts delete mode 100644 src/api/resources/unstable/resources/dataAttributes/types/index.ts delete mode 100644 src/api/resources/unstable/resources/dataEvents/types/LisDataEventsRequestFilter.ts delete mode 100644 src/api/resources/unstable/resources/dataEvents/types/index.ts delete mode 100644 src/api/resources/unstable/resources/dataExport/types/index.ts delete mode 100644 src/api/resources/unstable/resources/emails/types/EmailList.ts delete mode 100644 src/api/resources/unstable/resources/emails/types/index.ts delete mode 100644 src/api/resources/unstable/resources/export/types/PostExportReportingDataEnqueueResponse.ts delete mode 100644 src/api/resources/unstable/resources/export/types/index.ts delete mode 100644 src/api/resources/unstable/resources/helpCenter/types/Collection.ts delete mode 100644 src/api/resources/unstable/resources/helpCenter/types/HelpCenter.ts delete mode 100644 src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts delete mode 100644 src/api/resources/unstable/resources/helpCenter/types/index.ts delete mode 100644 src/api/resources/unstable/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts delete mode 100644 src/api/resources/unstable/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts delete mode 100644 src/api/resources/unstable/resources/internalArticles/types/InternalArticleSearchResponse.ts delete mode 100644 src/api/resources/unstable/resources/internalArticles/types/index.ts delete mode 100644 src/api/resources/unstable/resources/jobs/types/index.ts delete mode 100644 src/api/resources/unstable/resources/macros/types/MacroList.ts delete mode 100644 src/api/resources/unstable/resources/macros/types/index.ts delete mode 100644 src/api/resources/unstable/resources/messages/client/requests/index.ts delete mode 100644 src/api/resources/unstable/resources/messages/types/index.ts delete mode 100644 src/api/resources/unstable/resources/news/types/Newsfeed.ts delete mode 100644 src/api/resources/unstable/resources/news/types/NewsfeedAssignment.ts delete mode 100644 src/api/resources/unstable/resources/news/types/index.ts delete mode 100644 src/api/resources/unstable/resources/notes/types/CompanyNote.ts delete mode 100644 src/api/resources/unstable/resources/notes/types/Note.ts delete mode 100644 src/api/resources/unstable/resources/notes/types/index.ts delete mode 100644 src/api/resources/unstable/resources/segments/types/index.ts delete mode 100644 src/api/resources/unstable/resources/subscriptionTypes/types/index.ts delete mode 100644 src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts delete mode 100644 src/api/resources/unstable/resources/tags/types/Tag.ts delete mode 100644 src/api/resources/unstable/resources/tags/types/TagBasic.ts delete mode 100644 src/api/resources/unstable/resources/tags/types/index.ts delete mode 100644 src/api/resources/unstable/resources/teams/client/requests/index.ts delete mode 100644 src/api/resources/unstable/resources/teams/types/index.ts delete mode 100644 src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/ReplyTicketRequestBody.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/Ticket.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/TicketContacts.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/TicketPart.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/TicketState.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/TicketType.ts delete mode 100644 src/api/resources/unstable/resources/tickets/types/index.ts delete mode 100644 src/api/resources/unstable/types/ActivityLog.ts delete mode 100644 src/api/resources/unstable/types/ActivityLogList.ts delete mode 100644 src/api/resources/unstable/types/ActivityLogMetadata.ts delete mode 100644 src/api/resources/unstable/types/AddressableList.ts delete mode 100644 src/api/resources/unstable/types/AdminList.ts delete mode 100644 src/api/resources/unstable/types/AdminPriorityLevel.ts delete mode 100644 src/api/resources/unstable/types/AdminReplyConversationRequest.ts delete mode 100644 src/api/resources/unstable/types/AdminReplyTicketRequest.ts delete mode 100644 src/api/resources/unstable/types/AdminWithApp.ts delete mode 100644 src/api/resources/unstable/types/AiCallResponse.ts delete mode 100644 src/api/resources/unstable/types/App.ts delete mode 100644 src/api/resources/unstable/types/ArticleContent.ts delete mode 100644 src/api/resources/unstable/types/ArticleList.ts delete mode 100644 src/api/resources/unstable/types/ArticleStatistics.ts delete mode 100644 src/api/resources/unstable/types/ArticleTranslatedContent.ts delete mode 100644 src/api/resources/unstable/types/AssignConversationRequest.ts delete mode 100644 src/api/resources/unstable/types/AwayStatusReason.ts delete mode 100644 src/api/resources/unstable/types/CallList.ts delete mode 100644 src/api/resources/unstable/types/CloseConversationRequest.ts delete mode 100644 src/api/resources/unstable/types/CollectionList.ts delete mode 100644 src/api/resources/unstable/types/CompanyAttachedContacts.ts delete mode 100644 src/api/resources/unstable/types/CompanyAttachedSegments.ts delete mode 100644 src/api/resources/unstable/types/CompanyData.ts delete mode 100644 src/api/resources/unstable/types/CompanyList.ts delete mode 100644 src/api/resources/unstable/types/CompanyScroll.ts delete mode 100644 src/api/resources/unstable/types/ContactArchived.ts delete mode 100644 src/api/resources/unstable/types/ContactAttachedCompanies.ts delete mode 100644 src/api/resources/unstable/types/ContactBlocked.ts delete mode 100644 src/api/resources/unstable/types/ContactCompanies.ts delete mode 100644 src/api/resources/unstable/types/ContactDeleted.ts delete mode 100644 src/api/resources/unstable/types/ContactList.ts delete mode 100644 src/api/resources/unstable/types/ContactLocation.ts delete mode 100644 src/api/resources/unstable/types/ContactNotes.ts delete mode 100644 src/api/resources/unstable/types/ContactReference.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyBaseRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyConversationRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyEmailRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyIntercomUserIdRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyTicketEmailRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyTicketIntercomUserIdRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyTicketRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyTicketUserIdRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactReplyUserIdRequest.ts delete mode 100644 src/api/resources/unstable/types/ContactSegments.ts delete mode 100644 src/api/resources/unstable/types/ContactSocialProfiles.ts delete mode 100644 src/api/resources/unstable/types/ContactSubscriptionTypes.ts delete mode 100644 src/api/resources/unstable/types/ContactTags.ts delete mode 100644 src/api/resources/unstable/types/ContactUnarchived.ts delete mode 100644 src/api/resources/unstable/types/ContentSourcesList.ts delete mode 100644 src/api/resources/unstable/types/ConversationAttachmentFiles.ts delete mode 100644 src/api/resources/unstable/types/ConversationAttributeUpdatedByAdmin.ts delete mode 100644 src/api/resources/unstable/types/ConversationAttributeUpdatedByUser.ts delete mode 100644 src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts delete mode 100644 src/api/resources/unstable/types/ConversationContacts.ts delete mode 100644 src/api/resources/unstable/types/ConversationDeleted.ts delete mode 100644 src/api/resources/unstable/types/ConversationFirstContactReply.ts delete mode 100644 src/api/resources/unstable/types/ConversationList.ts delete mode 100644 src/api/resources/unstable/types/ConversationPart.ts delete mode 100644 src/api/resources/unstable/types/ConversationPartAuthor.ts delete mode 100644 src/api/resources/unstable/types/ConversationPartMetadata.ts delete mode 100644 src/api/resources/unstable/types/ConversationParts.ts delete mode 100644 src/api/resources/unstable/types/ConversationRating.ts delete mode 100644 src/api/resources/unstable/types/ConversationResponseTime.ts delete mode 100644 src/api/resources/unstable/types/ConversationSlaAppliedByRule.ts delete mode 100644 src/api/resources/unstable/types/ConversationSlaAppliedByWorkflow.ts delete mode 100644 src/api/resources/unstable/types/ConversationSlaPaused.ts delete mode 100644 src/api/resources/unstable/types/ConversationSlaRemoved.ts delete mode 100644 src/api/resources/unstable/types/ConversationSlaTargetMissed.ts delete mode 100644 src/api/resources/unstable/types/ConversationSlaUnpaused.ts delete mode 100644 src/api/resources/unstable/types/ConversationSource.ts delete mode 100644 src/api/resources/unstable/types/ConversationStatistics.ts delete mode 100644 src/api/resources/unstable/types/ConversationTagsUpdated.ts delete mode 100644 src/api/resources/unstable/types/ConversationTeammates.ts delete mode 100644 src/api/resources/unstable/types/CreateArticleRequest.ts delete mode 100644 src/api/resources/unstable/types/CreateDataAttributeRequest.ts delete mode 100644 src/api/resources/unstable/types/CreateInternalArticleRequest.ts delete mode 100644 src/api/resources/unstable/types/CreateMessageRequest.ts delete mode 100644 src/api/resources/unstable/types/CreateOrUpdateCompanyRequest.ts delete mode 100644 src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts delete mode 100644 src/api/resources/unstable/types/CreatePhoneSwitchRequest.ts delete mode 100644 src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts delete mode 100644 src/api/resources/unstable/types/CreateTicketRequestBody.ts delete mode 100644 src/api/resources/unstable/types/CreateTicketTypeRequest.ts delete mode 100644 src/api/resources/unstable/types/CursorPages.ts delete mode 100644 src/api/resources/unstable/types/CustomActionFinished.ts delete mode 100644 src/api/resources/unstable/types/CustomActionStarted.ts delete mode 100644 src/api/resources/unstable/types/CustomAttributes.ts delete mode 100644 src/api/resources/unstable/types/CustomChannelAttribute.ts delete mode 100644 src/api/resources/unstable/types/CustomChannelBaseEvent.ts delete mode 100644 src/api/resources/unstable/types/CustomChannelContact.ts delete mode 100644 src/api/resources/unstable/types/CustomChannelNotificationResponse.ts delete mode 100644 src/api/resources/unstable/types/CustomObjectInstanceDeleted.ts delete mode 100644 src/api/resources/unstable/types/CustomObjectInstanceList.ts delete mode 100644 src/api/resources/unstable/types/CustomerRequest.ts delete mode 100644 src/api/resources/unstable/types/DataAttributeList.ts delete mode 100644 src/api/resources/unstable/types/DataEventList.ts delete mode 100644 src/api/resources/unstable/types/DataEventSummary.ts delete mode 100644 src/api/resources/unstable/types/DataEventSummaryItem.ts delete mode 100644 src/api/resources/unstable/types/DataExportCsv.ts delete mode 100644 src/api/resources/unstable/types/Datetime.ts delete mode 100644 src/api/resources/unstable/types/DeletedArticleObject.ts delete mode 100644 src/api/resources/unstable/types/DeletedCollectionObject.ts delete mode 100644 src/api/resources/unstable/types/DeletedCompanyObject.ts delete mode 100644 src/api/resources/unstable/types/DeletedInternalArticleObject.ts delete mode 100644 src/api/resources/unstable/types/DeletedObject.ts delete mode 100644 src/api/resources/unstable/types/EmailAddressHeader.ts delete mode 100644 src/api/resources/unstable/types/EmailMessageMetadata.ts delete mode 100644 src/api/resources/unstable/types/Error_.ts delete mode 100644 src/api/resources/unstable/types/EventDetails.ts delete mode 100644 src/api/resources/unstable/types/FileAttribute.ts delete mode 100644 src/api/resources/unstable/types/GroupContent.ts delete mode 100644 src/api/resources/unstable/types/GroupTranslatedContent.ts delete mode 100644 src/api/resources/unstable/types/HandlingEvent.ts delete mode 100644 src/api/resources/unstable/types/HandlingEventList.ts delete mode 100644 src/api/resources/unstable/types/InternalArticleList.ts delete mode 100644 src/api/resources/unstable/types/LinkedObject.ts delete mode 100644 src/api/resources/unstable/types/LinkedObjectList.ts delete mode 100644 src/api/resources/unstable/types/MultipleFilterSearchRequest.ts delete mode 100644 src/api/resources/unstable/types/NewsItemRequest.ts delete mode 100644 src/api/resources/unstable/types/NotFoundErrorBody.ts delete mode 100644 src/api/resources/unstable/types/NoteList.ts delete mode 100644 src/api/resources/unstable/types/OpenConversationRequest.ts delete mode 100644 src/api/resources/unstable/types/OperatorWorkflowEvent.ts delete mode 100644 src/api/resources/unstable/types/PagesLink.ts delete mode 100644 src/api/resources/unstable/types/PaginatedResponse.ts delete mode 100644 src/api/resources/unstable/types/PaginatedResponseDataItem.ts delete mode 100644 src/api/resources/unstable/types/PartAttachment.ts delete mode 100644 src/api/resources/unstable/types/PhoneSwitch.ts delete mode 100644 src/api/resources/unstable/types/PriorityChanged.ts delete mode 100644 src/api/resources/unstable/types/QuickReplyOption.ts delete mode 100644 src/api/resources/unstable/types/Recipient.ts delete mode 100644 src/api/resources/unstable/types/RedactConversationRequest.ts delete mode 100644 src/api/resources/unstable/types/Reference.ts delete mode 100644 src/api/resources/unstable/types/RegisterFinVoiceCallRequest.ts delete mode 100644 src/api/resources/unstable/types/ReplyConversationRequestBody.ts delete mode 100644 src/api/resources/unstable/types/SearchRequest.ts delete mode 100644 src/api/resources/unstable/types/SegmentList.ts delete mode 100644 src/api/resources/unstable/types/SingleFilterSearchRequest.ts delete mode 100644 src/api/resources/unstable/types/SlaApplied.ts delete mode 100644 src/api/resources/unstable/types/SnoozeConversationRequest.ts delete mode 100644 src/api/resources/unstable/types/Snoozed.ts delete mode 100644 src/api/resources/unstable/types/SocialProfile.ts delete mode 100644 src/api/resources/unstable/types/StartingAfterPaging.ts delete mode 100644 src/api/resources/unstable/types/SubscriptionTypeList.ts delete mode 100644 src/api/resources/unstable/types/TagCompanyRequest.ts delete mode 100644 src/api/resources/unstable/types/TagList.ts delete mode 100644 src/api/resources/unstable/types/TagMultipleUsersRequest.ts delete mode 100644 src/api/resources/unstable/types/Tags.ts delete mode 100644 src/api/resources/unstable/types/TeamList.ts delete mode 100644 src/api/resources/unstable/types/TeamPriorityLevel.ts delete mode 100644 src/api/resources/unstable/types/TeammateReference.ts delete mode 100644 src/api/resources/unstable/types/TicketCustomAttributes.ts delete mode 100644 src/api/resources/unstable/types/TicketList.ts delete mode 100644 src/api/resources/unstable/types/TicketPartAuthor.ts delete mode 100644 src/api/resources/unstable/types/TicketParts.ts delete mode 100644 src/api/resources/unstable/types/TicketReply.ts delete mode 100644 src/api/resources/unstable/types/TicketRequestCustomAttributes.ts delete mode 100644 src/api/resources/unstable/types/TicketStateList.ts delete mode 100644 src/api/resources/unstable/types/TicketTypeAttribute.ts delete mode 100644 src/api/resources/unstable/types/TicketTypeAttributeList.ts delete mode 100644 src/api/resources/unstable/types/TicketTypeList.ts delete mode 100644 src/api/resources/unstable/types/Translation.ts delete mode 100644 src/api/resources/unstable/types/UntagCompanyRequest.ts delete mode 100644 src/api/resources/unstable/types/UpdateDataAttributeRequestBody.ts delete mode 100644 src/api/resources/unstable/types/Visitor.ts delete mode 100644 src/api/resources/unstable/types/VisitorDeletedObject.ts delete mode 100644 src/api/resources/unstable/types/WhatsappMessageStatusList.ts delete mode 100644 src/api/resources/unstable/types/WorkflowExport.ts delete mode 100644 src/api/resources/unstable/types/index.ts delete mode 100644 src/api/types/ActivityLog.ts delete mode 100644 src/api/types/ActivityLogList.ts delete mode 100644 src/api/types/ActivityLogMetadata.ts delete mode 100644 src/api/types/AddressableList.ts delete mode 100644 src/api/types/AdminList.ts delete mode 100644 src/api/types/AdminPriorityLevel.ts delete mode 100644 src/api/types/AdminReplyConversationRequest.ts delete mode 100644 src/api/types/AdminReplyTicketRequest.ts delete mode 100644 src/api/types/AdminWithApp.ts delete mode 100644 src/api/types/App.ts delete mode 100644 src/api/types/ArticleContent.ts delete mode 100644 src/api/types/ArticleList.ts delete mode 100644 src/api/types/ArticleStatistics.ts delete mode 100644 src/api/types/ArticleTranslatedContent.ts delete mode 100644 src/api/types/AssignConversationRequest.ts delete mode 100644 src/api/types/AwayStatusReason.ts delete mode 100644 src/api/types/CallList.ts delete mode 100644 src/api/types/CloseConversationRequest.ts delete mode 100644 src/api/types/CollectionList.ts delete mode 100644 src/api/types/CompanyAttachedContacts.ts delete mode 100644 src/api/types/CompanyAttachedSegments.ts delete mode 100644 src/api/types/CompanyData.ts delete mode 100644 src/api/types/CompanyList.ts delete mode 100644 src/api/types/CompanyScroll.ts delete mode 100644 src/api/types/ContactArchived.ts delete mode 100644 src/api/types/ContactAttachedCompanies.ts delete mode 100644 src/api/types/ContactBlocked.ts delete mode 100644 src/api/types/ContactCompanies.ts delete mode 100644 src/api/types/ContactDeleted.ts delete mode 100644 src/api/types/ContactList.ts delete mode 100644 src/api/types/ContactLocation.ts delete mode 100644 src/api/types/ContactNotes.ts delete mode 100644 src/api/types/ContactReference.ts delete mode 100644 src/api/types/ContactReplyBaseRequest.ts delete mode 100644 src/api/types/ContactReplyConversationRequest.ts delete mode 100644 src/api/types/ContactReplyEmailRequest.ts delete mode 100644 src/api/types/ContactReplyIntercomUserIdRequest.ts delete mode 100644 src/api/types/ContactReplyTicketEmailRequest.ts delete mode 100644 src/api/types/ContactReplyTicketIntercomUserIdRequest.ts delete mode 100644 src/api/types/ContactReplyTicketRequest.ts delete mode 100644 src/api/types/ContactReplyTicketUserIdRequest.ts delete mode 100644 src/api/types/ContactReplyUserIdRequest.ts delete mode 100644 src/api/types/ContactSegments.ts delete mode 100644 src/api/types/ContactSocialProfiles.ts delete mode 100644 src/api/types/ContactSubscriptionTypes.ts delete mode 100644 src/api/types/ContactTags.ts delete mode 100644 src/api/types/ContactUnarchived.ts delete mode 100644 src/api/types/ContentSourcesList.ts delete mode 100644 src/api/types/ConversationAttachmentFiles.ts delete mode 100644 src/api/types/ConversationAttributeUpdatedByAdmin.ts delete mode 100644 src/api/types/ConversationAttributeUpdatedByWorkflow.ts delete mode 100644 src/api/types/ConversationContacts.ts delete mode 100644 src/api/types/ConversationDeleted.ts delete mode 100644 src/api/types/ConversationFirstContactReply.ts delete mode 100644 src/api/types/ConversationList.ts delete mode 100644 src/api/types/ConversationPart.ts delete mode 100644 src/api/types/ConversationPartAuthor.ts delete mode 100644 src/api/types/ConversationPartMetadata.ts delete mode 100644 src/api/types/ConversationParts.ts delete mode 100644 src/api/types/ConversationRating.ts delete mode 100644 src/api/types/ConversationResponseTime.ts delete mode 100644 src/api/types/ConversationSource.ts delete mode 100644 src/api/types/ConversationStatistics.ts delete mode 100644 src/api/types/ConversationTeammates.ts delete mode 100644 src/api/types/CreateArticleRequest.ts delete mode 100644 src/api/types/CreateContactRequest.ts delete mode 100644 src/api/types/CreateContactRequestTwo.ts delete mode 100644 src/api/types/CreateDataAttributeRequest.ts delete mode 100644 src/api/types/CreateDataEventRequest.ts delete mode 100644 src/api/types/CreateDataEventRequestTwo.ts delete mode 100644 src/api/types/CreateInternalArticleRequest.ts delete mode 100644 src/api/types/CreateMessageRequest.ts delete mode 100644 src/api/types/CreateOrUpdateCompanyRequest.ts delete mode 100644 src/api/types/CreateOrUpdateTagRequest.ts delete mode 100644 src/api/types/CreatePhoneSwitchRequest.ts delete mode 100644 src/api/types/CreateTicketReplyWithCommentRequest.ts delete mode 100644 src/api/types/CreateTicketRequestBody.ts delete mode 100644 src/api/types/CreateTicketTypeRequest.ts delete mode 100644 src/api/types/CursorPages.ts delete mode 100644 src/api/types/CustomActionFinished.ts delete mode 100644 src/api/types/CustomActionStarted.ts delete mode 100644 src/api/types/CustomAttributes.ts delete mode 100644 src/api/types/CustomChannelAttribute.ts delete mode 100644 src/api/types/CustomChannelBaseEvent.ts delete mode 100644 src/api/types/CustomChannelContact.ts delete mode 100644 src/api/types/CustomChannelNotificationResponse.ts delete mode 100644 src/api/types/CustomObjectInstanceDeleted.ts delete mode 100644 src/api/types/CustomObjectInstanceList.ts delete mode 100644 src/api/types/CustomerRequest.ts delete mode 100644 src/api/types/DataAttributeList.ts delete mode 100644 src/api/types/DataEventList.ts delete mode 100644 src/api/types/DataEventSummary.ts delete mode 100644 src/api/types/DataEventSummaryItem.ts delete mode 100644 src/api/types/DataExportCsv.ts delete mode 100644 src/api/types/Datetime.ts delete mode 100644 src/api/types/DeletedArticleObject.ts delete mode 100644 src/api/types/DeletedCollectionObject.ts delete mode 100644 src/api/types/DeletedCompanyObject.ts delete mode 100644 src/api/types/DeletedInternalArticleObject.ts delete mode 100644 src/api/types/DeletedObject.ts delete mode 100644 src/api/types/EmailAddressHeader.ts delete mode 100644 src/api/types/EmailMessageMetadata.ts delete mode 100644 src/api/types/Error_.ts delete mode 100644 src/api/types/EventDetails.ts delete mode 100644 src/api/types/FileAttribute.ts delete mode 100644 src/api/types/GroupContent.ts delete mode 100644 src/api/types/GroupTranslatedContent.ts delete mode 100644 src/api/types/InternalArticleList.ts delete mode 100644 src/api/types/IpAllowlist.ts delete mode 100644 src/api/types/LinkedObject.ts delete mode 100644 src/api/types/LinkedObjectList.ts delete mode 100644 src/api/types/Metadata.ts delete mode 100644 src/api/types/MultipleFilterSearchRequest.ts delete mode 100644 src/api/types/NewsItemRequest.ts delete mode 100644 src/api/types/NotFoundErrorBody.ts delete mode 100644 src/api/types/NoteList.ts delete mode 100644 src/api/types/OffsetPages.ts delete mode 100644 src/api/types/OpenConversationRequest.ts delete mode 100644 src/api/types/OperatorWorkflowEvent.ts delete mode 100644 src/api/types/PagesLink.ts delete mode 100644 src/api/types/PaginatedResponse.ts delete mode 100644 src/api/types/PaginatedResponseDataItem.ts delete mode 100644 src/api/types/PartAttachment.ts delete mode 100644 src/api/types/PhoneSwitch.ts delete mode 100644 src/api/types/QuickReplyOption.ts delete mode 100644 src/api/types/Recipient.ts delete mode 100644 src/api/types/RedactConversationRequest.ts delete mode 100644 src/api/types/Reference.ts delete mode 100644 src/api/types/ReplyConversationRequest.ts delete mode 100644 src/api/types/SearchRequest.ts delete mode 100644 src/api/types/SegmentList.ts delete mode 100644 src/api/types/SingleFilterSearchRequest.ts delete mode 100644 src/api/types/SlaApplied.ts delete mode 100644 src/api/types/SnoozeConversationRequest.ts delete mode 100644 src/api/types/SocialProfile.ts delete mode 100644 src/api/types/StartingAfterPaging.ts delete mode 100644 src/api/types/SubscriptionTypeList.ts delete mode 100644 src/api/types/TagCompanyRequest.ts delete mode 100644 src/api/types/TagList.ts delete mode 100644 src/api/types/TagMultipleUsersRequest.ts delete mode 100644 src/api/types/Tags.ts delete mode 100644 src/api/types/TeamList.ts delete mode 100644 src/api/types/TeamPriorityLevel.ts delete mode 100644 src/api/types/TicketCustomAttributes.ts delete mode 100644 src/api/types/TicketList.ts delete mode 100644 src/api/types/TicketPartAuthor.ts delete mode 100644 src/api/types/TicketParts.ts delete mode 100644 src/api/types/TicketReply.ts delete mode 100644 src/api/types/TicketRequestCustomAttributes.ts delete mode 100644 src/api/types/TicketStateList.ts delete mode 100644 src/api/types/TicketTypeAttribute.ts delete mode 100644 src/api/types/TicketTypeAttributeList.ts delete mode 100644 src/api/types/TicketTypeList.ts delete mode 100644 src/api/types/Translation.ts delete mode 100644 src/api/types/UntagCompanyRequest.ts delete mode 100644 src/api/types/UpdateArticleRequestBody.ts delete mode 100644 src/api/types/UpdateCompanyRequestBody.ts delete mode 100644 src/api/types/UpdateDataAttributeRequestBody.ts delete mode 100644 src/api/types/UpdateVisitorRequest.ts delete mode 100644 src/api/types/UpdateVisitorRequestOne.ts delete mode 100644 src/api/types/Visitor.ts delete mode 100644 src/api/types/VisitorDeletedObject.ts delete mode 100644 src/api/types/WhatsappMessageStatusList.ts create mode 100644 src/api/types/types.ts create mode 100644 src/core/file/exports.ts create mode 100644 src/core/file/file.ts create mode 100644 src/core/file/index.ts create mode 100644 src/core/file/types.ts create mode 100644 src/core/form-data-utils/FormDataWrapper.ts create mode 100644 src/core/form-data-utils/encodeAsFormParameter.ts create mode 100644 src/core/form-data-utils/index.ts create mode 100644 tests/unit/file/file.test.ts create mode 100644 tests/unit/form-data-utils/encodeAsFormParameter.test.ts create mode 100644 tests/unit/form-data-utils/formDataWrapper.test.ts create mode 100644 tests/unit/test-file.txt delete mode 100644 tests/wire/customChannelEvents.test.ts create mode 100644 tests/wire/finAgent.test.ts create mode 100644 tests/wire/preview/admins.test.ts rename tests/wire/{unstable => preview}/aiContent.test.ts (89%) create mode 100644 tests/wire/preview/articles.test.ts create mode 100644 tests/wire/preview/audiences.test.ts create mode 100644 tests/wire/preview/authTokens.test.ts rename tests/wire/{unstable => preview}/awayStatusReasons.test.ts (55%) create mode 100644 tests/wire/preview/banners.test.ts rename tests/wire/{unstable => preview}/brands.test.ts (90%) rename tests/wire/{unstable => preview}/calls.test.ts (80%) rename tests/wire/{unstable => preview}/companies.test.ts (59%) create mode 100644 tests/wire/preview/contacts.test.ts create mode 100644 tests/wire/preview/content.test.ts create mode 100644 tests/wire/preview/contentSnippets.test.ts create mode 100644 tests/wire/preview/conversationParticipants.test.ts create mode 100644 tests/wire/preview/conversationParts.test.ts rename tests/wire/{unstable => preview}/conversations.test.ts (62%) create mode 100644 tests/wire/preview/conversationsAttributes.test.ts rename tests/wire/{unstable => preview}/customObjectInstances.test.ts (74%) rename tests/wire/{unstable => preview}/dataAttributes.test.ts (95%) create mode 100644 tests/wire/preview/dataConnectors.test.ts rename tests/wire/{unstable => preview}/dataEvents.test.ts (88%) rename tests/wire/{unstable => preview}/dataExport.test.ts (92%) rename tests/wire/{unstable => preview}/emails.test.ts (91%) create mode 100644 tests/wire/preview/finAgent.test.ts create mode 100644 tests/wire/preview/folders.test.ts rename tests/wire/{unstable => preview}/helpCenter.test.ts (79%) create mode 100644 tests/wire/preview/identityVerificationSecrets.test.ts rename tests/wire/{unstable => preview}/internalArticles.test.ts (52%) rename tests/wire/{unstable => preview}/jobs.test.ts (89%) rename tests/wire/{unstable => preview}/macros.test.ts (95%) rename tests/wire/{unstable => preview}/messages.test.ts (76%) rename tests/wire/{unstable => preview}/news.test.ts (93%) rename tests/wire/{unstable => preview}/notes.test.ts (60%) create mode 100644 tests/wire/preview/officeHours.test.ts create mode 100644 tests/wire/preview/procedures.test.ts rename tests/wire/{unstable/export.test.ts => preview/reportingDataExport.test.ts} (85%) rename tests/wire/{unstable/teams.test.ts => preview/roles.test.ts} (52%) rename tests/wire/{unstable => preview}/segments.test.ts (90%) rename tests/wire/{unstable => preview}/subscriptionTypes.test.ts (91%) rename tests/wire/{unstable => preview}/switch.test.ts (87%) rename tests/wire/{unstable => preview}/tags.test.ts (77%) create mode 100644 tests/wire/preview/teams.test.ts rename tests/wire/{unstable => preview}/ticketStates.test.ts (99%) rename tests/wire/{unstable => preview}/ticketTypeAttributes.test.ts (93%) rename tests/wire/{unstable => preview}/ticketTypes.test.ts (96%) rename tests/wire/{unstable => preview}/tickets.test.ts (57%) rename tests/wire/{unstable => preview}/visitors.test.ts (95%) rename tests/wire/{unstable => preview}/workflows.test.ts (92%) rename tests/wire/{export.test.ts => reportingDataExport.test.ts} (93%) delete mode 100644 tests/wire/unstable/admins.test.ts delete mode 100644 tests/wire/unstable/articles.test.ts delete mode 100644 tests/wire/unstable/contacts.test.ts delete mode 100644 tests/wire/unstable/customChannelEvents.test.ts diff --git a/.fern/metadata.json b/.fern/metadata.json index ef3f5299..86617e34 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -10,6 +10,7 @@ "noSerdeLayer": true, "enableInlineTypes": true, "inlinePathParameters": true, + "consolidateTypeFiles": true, "timeoutInSeconds": 20, "packageJson": { "license": "Apache-2.0", diff --git a/.fern/replay.lock b/.fern/replay.lock new file mode 100644 index 00000000..c3d107b8 --- /dev/null +++ b/.fern/replay.lock @@ -0,0 +1,10 @@ +# DO NOT EDIT MANUALLY - Managed by Fern Replay +version: "1.0" +generations: + - commit_sha: d8a05dee0314b74d6d0bbd49caccdd680a635c1a + tree_hash: ffc0c6cfa12f6acaf88e5bce53c17f5e51d284d8 + timestamp: 2026-09-24T07:06:01.484Z + cli_version: unknown + generator_versions: {} +current_generation: d8a05dee0314b74d6d0bbd49caccdd680a635c1a +patches: [] diff --git a/.fernignore b/.fernignore index 7d2c0c45..b6c5c18d 100644 --- a/.fernignore +++ b/.fernignore @@ -6,4 +6,6 @@ LICENSE REPO_OWNER tests/integration .github/workflows/ci.yml -.github/workflows/publish.yml \ No newline at end of file +.github/workflows/publish.yml +.fern/replay.lock +.fern/replay.yml diff --git a/.gitattributes b/.gitattributes index 176a458f..a9f730d8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ * text=auto +.fern/replay.lock linguist-generated=true diff --git a/.github/workflows-disabled/ci.yml b/.github/workflows-disabled/ci.yml deleted file mode 100644 index 268fb922..00000000 --- a/.github/workflows-disabled/ci.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: ci - -on: [push] - -jobs: - compile: - runs-on: ubuntu-latest - - steps: - - name: Checkout repo - uses: actions/checkout@v6 - - - name: Set up node - uses: actions/setup-node@v6 - - - name: Install pnpm - uses: pnpm/action-setup@v4 - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Compile - run: pnpm build - - test: - runs-on: ubuntu-latest - - steps: - - name: Checkout repo - uses: actions/checkout@v6 - - - name: Set up node - uses: actions/setup-node@v6 - - - name: Install pnpm - uses: pnpm/action-setup@v4 - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Test - run: pnpm test - env: - INTERCOM_API_KEY: ${{ secrets.INTERCOM_API_KEY }} - API_TOKEN: ${{ secrets.INTERCOM_API_KEY }} - - publish: - needs: [ compile, test ] - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ubuntu-latest - permissions: - id-token: write - steps: - - name: Checkout repo - uses: actions/checkout@v6 - - name: Set up node - uses: actions/setup-node@v6 - - name: Install pnpm - uses: pnpm/action-setup@v4 - - name: Install dependencies - run: pnpm install - - name: Build - run: pnpm build - - - name: Publish to npm - run: | - publish() { - npx -y npm@latest publish "$@" - } - if [[ ${GITHUB_REF} == *alpha* ]]; then - publish --access public --tag alpha - elif [[ ${GITHUB_REF} == *beta* ]]; then - publish --access public --tag beta - else - publish --access public - fi \ No newline at end of file diff --git a/README.md b/README.md index 753ab107..10254735 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,49 @@ try { } ``` +## File Uploads + +You can upload files using the client: + +```typescript +import { createReadStream } from "fs"; +import { IntercomClient } from "intercom-client"; + +const client = new IntercomClient({ token: "YOUR_TOKEN" }); +await client.preview.ecommerceConnectors.uploadEcommerceCatalog({ + id: "42939" +}); +``` +The client accepts a variety of types for file upload parameters: +* Stream types: `fs.ReadStream`, `stream.Readable`, and `ReadableStream` +* Buffered types: `Buffer`, `Blob`, `File`, `ArrayBuffer`, `ArrayBufferView`, and `Uint8Array` + +### Metadata + +You can configure metadata when uploading a file: +```typescript +const file: Uploadable.WithMetadata = { + data: createReadStream("path/to/file"), + filename: "my-file", // optional + contentType: "audio/mpeg", // optional + contentLength: 1949, // optional +}; +``` + +Alternatively, you can upload a file directly from a file path: +```typescript +const file : Uploadable.FromPath = { + path: "path/to/file", + filename: "my-file", // optional + contentType: "audio/mpeg", // optional + contentLength: 1949, // optional +}; +``` + +The metadata is used to set the `Content-Length`, `Content-Type`, and `Content-Disposition` headers. If not provided, the client will attempt to determine them automatically. +For example, `fs.ReadStream` has a `path` property which the SDK uses to retrieve the file size from the filesystem without loading it into memory. + + ## Pagination List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items: diff --git a/package.json b/package.json index 4e22c764..d5824c3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "intercom-client", - "version": "7.0.3", + "version": "7.0.5-beta.0", "private": false, "repository": "github:intercom/intercom-node", "type": "commonjs", @@ -46,7 +46,7 @@ "devDependencies": { "webpack": "^5.97.1", "ts-loader": "^9.5.1", - "vitest": "^4.1.0", + "vitest": "^3.2.4", "msw": "2.11.2", "@types/node": "^18.19.70", "typescript": "~5.7.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 114ce476..7a489b0d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,16 +19,16 @@ importers: version: 2.11.2(@types/node@18.19.130)(typescript@5.7.3) ts-loader: specifier: ^9.5.1 - version: 9.5.4(typescript@5.7.3)(webpack@5.104.1) + version: 9.5.4(typescript@5.7.3)(webpack@5.103.0) typescript: specifier: ~5.7.2 version: 5.7.3 vitest: - specifier: ^4.1.0 - version: 4.1.0(@types/node@18.19.130)(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(vite@7.2.6(@types/node@18.19.130)(terser@5.46.0)) + specifier: ^3.2.4 + version: 3.2.4(@types/node@18.19.130)(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(terser@5.44.1) webpack: specifier: ^5.97.1 - version: 5.104.1 + version: 5.103.0 packages: @@ -54,28 +54,24 @@ packages: engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - libc: [musl] '@biomejs/cli-linux-arm64@2.3.1': resolution: {integrity: sha512-td5O8pFIgLs8H1sAZsD6v+5quODihyEw4nv2R8z7swUfIK1FKk+15e4eiYVLcAE4jUqngvh4j3JCNgg0Y4o4IQ==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - libc: [glibc] '@biomejs/cli-linux-x64-musl@2.3.1': resolution: {integrity: sha512-Y3Ob4nqgv38Mh+6EGHltuN+Cq8aj/gyMTJYzkFZV2AEj+9XzoXB9VNljz9pjfFNHUxvLEV4b55VWyxozQTBaUQ==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - libc: [musl] '@biomejs/cli-linux-x64@2.3.1': resolution: {integrity: sha512-PYWgEO7up7XYwSAArOpzsVCiqxBCXy53gsReAb1kKYIyXaoAlhBaBMvxR/k2Rm9aTuZ662locXUmPk/Aj+Xu+Q==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - libc: [glibc] '@biomejs/cli-win32-arm64@2.3.1': resolution: {integrity: sha512-RHIG/zgo+69idUqVvV3n8+j58dKYABRpMyDmfWu2TITC+jwGPiEaT0Q3RKD+kQHiS80mpBrST0iUGeEXT0bU9A==} @@ -315,147 +311,116 @@ packages: '@open-draft/until@2.1.0': resolution: {integrity: sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==} - '@rollup/rollup-android-arm-eabi@4.61.0': - resolution: {integrity: sha512-dnxczajOqt0gesZlN5pGQ1s1imQVrsmCw5G2Ci4oM+0WvNz3pyRnlWrT7McoZIb8VlFwCawdmbWRmxRn7HI+VQ==} + '@rollup/rollup-android-arm-eabi@4.53.3': + resolution: {integrity: sha512-mRSi+4cBjrRLoaal2PnqH82Wqyb+d3HsPUN/W+WslCXsZsyHa9ZeQQX/pQsZaVIWDkPcpV6jJ+3KLbTbgnwv8w==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.61.0': - resolution: {integrity: sha512-Bp3JpGP00Vu3f238ivRrjf7z3xSzVPXqCmaJYA9t2c+c8vKYvOzmXF7LkkeUalTEGd6cZcSWe+PFIP3Vy48fRg==} + '@rollup/rollup-android-arm64@4.53.3': + resolution: {integrity: sha512-CbDGaMpdE9sh7sCmTrTUyllhrg65t6SwhjlMJsLr+J8YjFuPmCEjbBSx4Z/e4SmDyH3aB5hGaJUP2ltV/vcs4w==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.61.0': - resolution: {integrity: sha512-zaYIpr670mUmmZ1tVzUFplbQbG7h3Gugx3L5FoqhsC2m/YnLlR1a7zVLmXNPy+iY1tFPEbNG+HHBXZGyId0G5w==} + '@rollup/rollup-darwin-arm64@4.53.3': + resolution: {integrity: sha512-Nr7SlQeqIBpOV6BHHGZgYBuSdanCXuw09hon14MGOLGmXAFYjx1wNvquVPmpZnl0tLjg25dEdr4IQ6GgyToCUA==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.61.0': - resolution: {integrity: sha512-+P49fvkv2dSoeevUW+lgZ/I2JHSsJCK1Lyjj7Cu6E4UHG4tS9XIefzIjo5qhgELjAclnen1rLzK2PMKJdo+Dyg==} + '@rollup/rollup-darwin-x64@4.53.3': + resolution: {integrity: sha512-DZ8N4CSNfl965CmPktJ8oBnfYr3F8dTTNBQkRlffnUarJ2ohudQD17sZBa097J8xhQ26AwhHJ5mvUyQW8ddTsQ==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.61.0': - resolution: {integrity: sha512-l3FAAOyKJXH2ea6KNFN+MMgC/rnE94YGLXs2ehYqDcCoHt1DpvgWX75BhUJxN38XojP7Ul+4H8PRn7EdyqSDrw==} + '@rollup/rollup-freebsd-arm64@4.53.3': + resolution: {integrity: sha512-yMTrCrK92aGyi7GuDNtGn2sNW+Gdb4vErx4t3Gv/Tr+1zRb8ax4z8GWVRfr3Jw8zJWvpGHNpss3vVlbF58DZ4w==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.61.0': - resolution: {integrity: sha512-VokPN3TSctKj65cyCNPaUh4vMFA8awxOot/0sp+4J7ZlNRKQEhXhawqPwajoi8H5ZFt61i0ugZJuTKXBjGJ17Q==} + '@rollup/rollup-freebsd-x64@4.53.3': + resolution: {integrity: sha512-lMfF8X7QhdQzseM6XaX0vbno2m3hlyZFhwcndRMw8fbAGUGL3WFMBdK0hbUBIUYcEcMhVLr1SIamDeuLBnXS+Q==} cpu: [x64] os: [freebsd] - '@rollup/rollup-linux-arm-gnueabihf@4.61.0': - resolution: {integrity: sha512-DxH0P3wxm+Yzs/p3zrk9dw1rURu8p0Nv5+MRK/L7OtnLNg5rLZraSBFZ8iUXOd9f2BlhJyEpIZUH/emjq4UJ4g==} + '@rollup/rollup-linux-arm-gnueabihf@4.53.3': + resolution: {integrity: sha512-k9oD15soC/Ln6d2Wv/JOFPzZXIAIFLp6B+i14KhxAfnq76ajt0EhYc5YPeX6W1xJkAdItcVT+JhKl1QZh44/qw==} cpu: [arm] os: [linux] - libc: [glibc] - '@rollup/rollup-linux-arm-musleabihf@4.61.0': - resolution: {integrity: sha512-T6ZvMNe84kAz6TBWHC7hGAoEtzP1LWYw/AqayGWEF6uISt3Abk/st06LqRD9THd7Xz3NxzurUpzAuEAUbZf+nw==} + '@rollup/rollup-linux-arm-musleabihf@4.53.3': + resolution: {integrity: sha512-vTNlKq+N6CK/8UktsrFuc+/7NlEYVxgaEgRXVUVK258Z5ymho29skzW1sutgYjqNnquGwVUObAaxae8rZ6YMhg==} cpu: [arm] os: [linux] - libc: [musl] - '@rollup/rollup-linux-arm64-gnu@4.61.0': - resolution: {integrity: sha512-q/4hzvQkDs8b4jIBab1pnLiiM0ayTZsN2amBFPDzuyZxjEd4wDwx0UJFYM3cOZzSf5Kw8fnWSprJzIBMkcR44Q==} + '@rollup/rollup-linux-arm64-gnu@4.53.3': + resolution: {integrity: sha512-RGrFLWgMhSxRs/EWJMIFM1O5Mzuz3Xy3/mnxJp/5cVhZ2XoCAxJnmNsEyeMJtpK+wu0FJFWz+QF4mjCA7AUQ3w==} cpu: [arm64] os: [linux] - libc: [glibc] - '@rollup/rollup-linux-arm64-musl@4.61.0': - resolution: {integrity: sha512-vvYWX3akdEAY6km+9wAqFDnk6pQsbJKVnj7xawcvs/+fdlYBGp+U+Qq/lLfpIxYIZvZLHMAKD9HLdacSx/r3dw==} + '@rollup/rollup-linux-arm64-musl@4.53.3': + resolution: {integrity: sha512-kASyvfBEWYPEwe0Qv4nfu6pNkITLTb32p4yTgzFCocHnJLAHs+9LjUu9ONIhvfT/5lv4YS5muBHyuV84epBo/A==} cpu: [arm64] os: [linux] - libc: [musl] - '@rollup/rollup-linux-loong64-gnu@4.61.0': - resolution: {integrity: sha512-DePa5cqOxDP/Zp0VOXpeWaGew5iIv5DXp9NYbzkX5PFQyWVX9184WCTh3hvr/7lhXo8ZVlbFLkz8+o/q1dU6gA==} + '@rollup/rollup-linux-loong64-gnu@4.53.3': + resolution: {integrity: sha512-JiuKcp2teLJwQ7vkJ95EwESWkNRFJD7TQgYmCnrPtlu50b4XvT5MOmurWNrCj3IFdyjBQ5p9vnrX4JM6I8OE7g==} cpu: [loong64] os: [linux] - libc: [glibc] - '@rollup/rollup-linux-loong64-musl@4.61.0': - resolution: {integrity: sha512-LV8aWMB8UChglMCEzs7RkN0GsH29RJaLLqwm9fCIjlqwxQTiWAqNcc7wjBkH31hV0PU/yVxGYvrYsgfea2qw6g==} - cpu: [loong64] - os: [linux] - libc: [musl] - - '@rollup/rollup-linux-ppc64-gnu@4.61.0': - resolution: {integrity: sha512-QoNSnwQtaeNu5grdBbsL0tt1uyl5EnS8DA8Mr3nluMXbhdQNyhN+G4tBax7VCdxLKj8YJ0/4OO9Ho84jMnJtKA==} - cpu: [ppc64] - os: [linux] - libc: [glibc] - - '@rollup/rollup-linux-ppc64-musl@4.61.0': - resolution: {integrity: sha512-/zZp5MKapIIApE8trN8qLGNSiRN9TUoaUZ1cmVu4XnVdd5LQLOXTtyi+vtfUbNnT3iyjzpPqYeKXmvJ+gJGYWw==} + '@rollup/rollup-linux-ppc64-gnu@4.53.3': + resolution: {integrity: sha512-EoGSa8nd6d3T7zLuqdojxC20oBfNT8nexBbB/rkxgKj5T5vhpAQKKnD+h3UkoMuTyXkP5jTjK/ccNRmQrPNDuw==} cpu: [ppc64] os: [linux] - libc: [musl] - '@rollup/rollup-linux-riscv64-gnu@4.61.0': - resolution: {integrity: sha512-RbrzcD3aJ1k3UbtMRRBNwojdVVyXjuVAFTfn/xPa6EEl6GE9Sm/akPgFTb9aAC9pMKGJ6CtWxaGrqWcabH+ySg==} + '@rollup/rollup-linux-riscv64-gnu@4.53.3': + resolution: {integrity: sha512-4s+Wped2IHXHPnAEbIB0YWBv7SDohqxobiiPA1FIWZpX+w9o2i4LezzH/NkFUl8LRci/8udci6cLq+jJQlh+0g==} cpu: [riscv64] os: [linux] - libc: [glibc] - '@rollup/rollup-linux-riscv64-musl@4.61.0': - resolution: {integrity: sha512-ZF+onDsBso8PJf1XaG9lB+O9RnBpKGnY6OrzC4CSHrtC1jb6jWLTKK4bRqdoCXHd22gyr2hiYmEAm8Wns/BOCw==} + '@rollup/rollup-linux-riscv64-musl@4.53.3': + resolution: {integrity: sha512-68k2g7+0vs2u9CxDt5ktXTngsxOQkSEV/xBbwlqYcUrAVh6P9EgMZvFsnHy4SEiUl46Xf0IObWVbMvPrr2gw8A==} cpu: [riscv64] os: [linux] - libc: [musl] - '@rollup/rollup-linux-s390x-gnu@4.61.0': - resolution: {integrity: sha512-Atk0aSIk5Zx2Wuh9dgRQgLP0Koc8hOeYpbWryMXyk8G8/HmPkwPPkMqIIDhrXHHYqfUzSJA/I7IWSBv8xSmRBA==} + '@rollup/rollup-linux-s390x-gnu@4.53.3': + resolution: {integrity: sha512-VYsFMpULAz87ZW6BVYw3I6sWesGpsP9OPcyKe8ofdg9LHxSbRMd7zrVrr5xi/3kMZtpWL/wC+UIJWJYVX5uTKg==} cpu: [s390x] os: [linux] - libc: [glibc] - '@rollup/rollup-linux-x64-gnu@4.61.0': - resolution: {integrity: sha512-0uMOcf3eZ5K+K4cYHkdxShFMPlPXCOdfDFEFn9dNYAEEd2cVvmOfH7zFgRVoDgmtQ1m9k5q7qfrHzyMAubKYUA==} + '@rollup/rollup-linux-x64-gnu@4.53.3': + resolution: {integrity: sha512-3EhFi1FU6YL8HTUJZ51imGJWEX//ajQPfqWLI3BQq4TlvHy4X0MOr5q3D2Zof/ka0d5FNdPwZXm3Yyib/UEd+w==} cpu: [x64] os: [linux] - libc: [glibc] - '@rollup/rollup-linux-x64-musl@4.61.0': - resolution: {integrity: sha512-mvFtE4A/t/7hRJ7X8Ozmu8FsIkAUat2nzl12pgU337BRmq87AQUJztwHz2Zv5/tjo9/C95E66CK03SI/ToEDJw==} + '@rollup/rollup-linux-x64-musl@4.53.3': + resolution: {integrity: sha512-eoROhjcc6HbZCJr+tvVT8X4fW3/5g/WkGvvmwz/88sDtSJzO7r/blvoBDgISDiCjDRZmHpwud7h+6Q9JxFwq1Q==} cpu: [x64] os: [linux] - libc: [musl] - '@rollup/rollup-openbsd-x64@4.61.0': - resolution: {integrity: sha512-z9b9+aTxvt8n2rNltMPvyaUfB8NJ+CVyOrGK/MdIKHx7B+lXmZpm/XbRsU7Rpf3fRqJ2uS6mBJiJveCtq8LHDg==} - cpu: [x64] - os: [openbsd] - - '@rollup/rollup-openharmony-arm64@4.61.0': - resolution: {integrity: sha512-jXaXFqKMehsOc+g8R6oo33RRC6w07G9jDBxAE5eAKX7mOcCbZloYIPNhfG9Wl+P9O9IWHFO4OJgPi1Ml2qkt7w==} + '@rollup/rollup-openharmony-arm64@4.53.3': + resolution: {integrity: sha512-OueLAWgrNSPGAdUdIjSWXw+u/02BRTcnfw9PN41D2vq/JSEPnJnVuBgw18VkN8wcd4fjUs+jFHVM4t9+kBSNLw==} cpu: [arm64] os: [openharmony] - '@rollup/rollup-win32-arm64-msvc@4.61.0': - resolution: {integrity: sha512-OXNWVFocS2IA4+QplhTZZ2a+8hPZR7T8KuozsNmJKK8y7cp83StHvGksfHzPG3wczWTczyWHVQuqeiTUbjiyBg==} + '@rollup/rollup-win32-arm64-msvc@4.53.3': + resolution: {integrity: sha512-GOFuKpsxR/whszbF/bzydebLiXIHSgsEUp6M0JI8dWvi+fFa1TD6YQa4aSZHtpmh2/uAlj/Dy+nmby3TJ3pkTw==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.61.0': - resolution: {integrity: sha512-AlAbNtBO637LxSldqV43z0FfXoGfl2TW1DgAg/bs7aQswFbDewz2SJm3BUhiGfbOVtW571xbc9p+REdxhyN/Eg==} + '@rollup/rollup-win32-ia32-msvc@4.53.3': + resolution: {integrity: sha512-iah+THLcBJdpfZ1TstDFbKNznlzoxa8fmnFYK4V67HvmuNYkVdAywJSoteUszvBQ9/HqN2+9AZghbajMsFT+oA==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-gnu@4.61.0': - resolution: {integrity: sha512-QRSrQXyJ1M4tjNXdR0/G/IgV6lzfQQJYBjlWIEYkY2Xs86DRl/iEpQ4blMDjJxSl7n19eDKKXMg0AmuBVYy8pQ==} + '@rollup/rollup-win32-x64-gnu@4.53.3': + resolution: {integrity: sha512-J9QDiOIZlZLdcot5NXEepDkstocktoVjkaKUtqzgzpt2yWjGlbYiKyp05rWwk4nypbYUNoFAztEgixoLaSETkg==} cpu: [x64] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.61.0': - resolution: {integrity: sha512-tkuFxhvKO/HlGd0VsINF6vHSYH8AF8W0TcNxKDK6JZmrehngFj78pToc8iemtnvwilDjs2G/qSzYFhe9U8q+fw==} + '@rollup/rollup-win32-x64-msvc@4.53.3': + resolution: {integrity: sha512-UhTd8u31dXadv0MopwGgNOBpUVROFKWVQgAg5N1ESyCz8AuBcMqm4AuTjrwgQKGDfoFuz02EuMRHQIw/frmYKQ==} cpu: [x64] os: [win32] - '@standard-schema/spec@1.1.0': - resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} - '@types/chai@5.2.3': resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} @@ -474,9 +439,6 @@ packages: '@types/estree@1.0.8': resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} - '@types/estree@1.0.9': - resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} - '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} @@ -486,34 +448,34 @@ packages: '@types/statuses@2.0.6': resolution: {integrity: sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==} - '@vitest/expect@4.1.0': - resolution: {integrity: sha512-EIxG7k4wlWweuCLG9Y5InKFwpMEOyrMb6ZJ1ihYu02LVj/bzUwn2VMU+13PinsjRW75XnITeFrQBMH5+dLvCDA==} + '@vitest/expect@3.2.4': + resolution: {integrity: sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==} - '@vitest/mocker@4.1.0': - resolution: {integrity: sha512-evxREh+Hork43+Y4IOhTo+h5lGmVRyjqI739Rz4RlUPqwrkFFDF6EMvOOYjTx4E8Tl6gyCLRL8Mu7Ry12a13Tw==} + '@vitest/mocker@3.2.4': + resolution: {integrity: sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==} peerDependencies: msw: ^2.4.9 - vite: ^6.0.0 || ^7.0.0 || ^8.0.0-0 + vite: ^5.0.0 || ^6.0.0 || ^7.0.0-0 peerDependenciesMeta: msw: optional: true vite: optional: true - '@vitest/pretty-format@4.1.0': - resolution: {integrity: sha512-3RZLZlh88Ib0J7NQTRATfc/3ZPOnSUn2uDBUoGNn5T36+bALixmzphN26OUD3LRXWkJu4H0s5vvUeqBiw+kS0A==} + '@vitest/pretty-format@3.2.4': + resolution: {integrity: sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==} - '@vitest/runner@4.1.0': - resolution: {integrity: sha512-Duvx2OzQ7d6OjchL+trw+aSrb9idh7pnNfxrklo14p3zmNL4qPCDeIJAK+eBKYjkIwG96Bc6vYuxhqDXQOWpoQ==} + '@vitest/runner@3.2.4': + resolution: {integrity: sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==} - '@vitest/snapshot@4.1.0': - resolution: {integrity: sha512-0Vy9euT1kgsnj1CHttwi9i9o+4rRLEaPRSOJ5gyv579GJkNpgJK+B4HSv/rAWixx2wdAFci1X4CEPjiu2bXIMg==} + '@vitest/snapshot@3.2.4': + resolution: {integrity: sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==} - '@vitest/spy@4.1.0': - resolution: {integrity: sha512-pz77k+PgNpyMDv2FV6qmk5ZVau6c3R8HC8v342T2xlFxQKTrSeYw9waIJG8KgV9fFwAtTu4ceRzMivPTH6wSxw==} + '@vitest/spy@3.2.4': + resolution: {integrity: sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==} - '@vitest/utils@4.1.0': - resolution: {integrity: sha512-XfPXT6a8TZY3dcGY8EdwsBulFCIw+BeeX0RZn2x/BtiY/75YGh8FeWGG8QISN/WhaqSrE2OrlDgtF8q5uhOTmw==} + '@vitest/utils@3.2.4': + resolution: {integrity: sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==} '@webassemblyjs/ast@1.14.1': resolution: {integrity: sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==} @@ -605,33 +567,41 @@ packages: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} - baseline-browser-mapping@2.9.19: - resolution: {integrity: sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg==} + baseline-browser-mapping@2.8.32: + resolution: {integrity: sha512-OPz5aBThlyLFgxyhdwf/s2+8ab3OvT7AdTNvKHBwpXomIYeXqpUUuT8LrdtxZSsWJ4R4CU1un4XGh5Ez3nlTpw==} hasBin: true braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} - browserslist@4.28.1: - resolution: {integrity: sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==} + browserslist@4.28.0: + resolution: {integrity: sha512-tbydkR/CxfMwelN0vwdP/pLkDwyAASZ+VfWm4EOwlB6SWhx1sYnWLqo8N5j0rAzPfzfRaxt0mM/4wPU/Su84RQ==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - caniuse-lite@1.0.30001769: - resolution: {integrity: sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg==} + cac@6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + + caniuse-lite@1.0.30001757: + resolution: {integrity: sha512-r0nnL/I28Zi/yjk1el6ilj27tKcdjLsNqAOZr0yVjWPrSQyHgKI2INaEWw21bAQSv2LXRt1XuCS/GomNpWOxsQ==} - chai@6.2.2: - resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==} + chai@5.3.3: + resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==} engines: {node: '>=18'} chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} + check-error@2.1.1: + resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} + engines: {node: '>= 16'} + chrome-trace-event@1.0.4: resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==} engines: {node: '>=6.0'} @@ -654,15 +624,25 @@ packages: commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} - convert-source-map@2.0.0: - resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} - cookie@0.7.2: resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} engines: {node: '>= 0.6'} - electron-to-chromium@1.5.286: - resolution: {integrity: sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A==} + debug@4.4.3: + resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + deep-eql@5.0.2: + resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} + engines: {node: '>=6'} + + electron-to-chromium@1.5.263: + resolution: {integrity: sha512-DrqJ11Knd+lo+dv+lltvfMDLU27g14LMdH2b0O3Pio4uk0x+z7OR+JrmyacTPN2M8w3BrZ7/RTwG3R9B7irPlg==} emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -671,15 +651,8 @@ packages: resolution: {integrity: sha512-d4lC8xfavMeBjzGr2vECC3fsGXziXZQyJxD868h2M/mBI3PwAuODxAkLkq5HYuvrPYcUtiLzsTo8U3PgX3Ocww==} engines: {node: '>=10.13.0'} - enhanced-resolve@5.19.0: - resolution: {integrity: sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg==} - engines: {node: '>=10.13.0'} - - es-module-lexer@2.0.0: - resolution: {integrity: sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==} - - es-module-lexer@2.1.0: - resolution: {integrity: sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==} + es-module-lexer@1.7.0: + resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==} esbuild@0.25.12: resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==} @@ -713,8 +686,8 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} - expect-type@1.3.0: - resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==} + expect-type@1.2.2: + resolution: {integrity: sha512-JhFGDVJ7tmDJItKhYgJCGLOWjuK9vPxiXoUFLwLDc99NlmklilbiQJwoctZtt13+xMw91MCk/REan6MWHqDjyA==} engines: {node: '>=12.0.0'} fast-deep-equal@3.1.3: @@ -777,6 +750,9 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} + js-tokens@9.0.1: + resolution: {integrity: sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==} + json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} @@ -787,6 +763,9 @@ packages: resolution: {integrity: sha512-IWqP2SCPhyVFTBtRcgMHdzlf9ul25NwaFx4wCEH/KjAXuuHY4yNjvPXsBokp8jCB936PyWRaPKUNh8NvylLp2Q==} engines: {node: '>=6.11.5'} + loupe@3.2.1: + resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==} + magic-string@0.30.21: resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} @@ -805,6 +784,9 @@ packages: resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} engines: {node: '>= 0.6'} + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + msw@2.11.2: resolution: {integrity: sha512-MI54hLCsrMwiflkcqlgYYNJJddY5/+S0SnONvhv1owOplvqohKSQyGejpNdUGyCwgs4IH7PqaNbPw/sKOEze9Q==} engines: {node: '>=18'} @@ -819,8 +801,8 @@ packages: resolution: {integrity: sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==} engines: {node: ^18.17.0 || >=20.5.0} - nanoid@3.3.12: - resolution: {integrity: sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==} + nanoid@3.3.11: + resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true @@ -830,9 +812,6 @@ packages: node-releases@2.0.27: resolution: {integrity: sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==} - obug@2.1.1: - resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==} - outvariant@1.4.3: resolution: {integrity: sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==} @@ -842,6 +821,10 @@ packages: pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + pathval@2.0.1: + resolution: {integrity: sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==} + engines: {node: '>= 14.16'} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -849,12 +832,12 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - picomatch@4.0.4: - resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} + picomatch@4.0.3: + resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} engines: {node: '>=12'} - postcss@8.5.15: - resolution: {integrity: sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==} + postcss@8.5.6: + resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} engines: {node: ^10 || ^12 || >=14} randombytes@2.1.0: @@ -871,8 +854,8 @@ packages: rettime@0.7.0: resolution: {integrity: sha512-LPRKoHnLKd/r3dVxcwO7vhCW+orkOGj9ViueosEBK6ie89CijnfRlhaDhHq/3Hxu4CkWQtxwlBG0mzTQY6uQjw==} - rollup@4.61.0: - resolution: {integrity: sha512-T9mWdbWfQtp0B5lv/HX+wrhYsmXRlcWnXXmJbXqKJhlRaoS6KMhq0gpyzW4UJfclcxrEdLnTgjT2NjruLONu0g==} + rollup@4.53.3: + resolution: {integrity: sha512-w8GmOxZfBmKknvdXU1sdM9NHcoQejwF/4mNgj2JuEEdRaHwwF12K7e9eXn1nLZ07ad+du76mkVsyeb2rKGllsA==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -920,8 +903,8 @@ packages: resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==} engines: {node: '>= 0.8'} - std-env@4.1.0: - resolution: {integrity: sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==} + std-env@3.10.0: + resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} strict-event-emitter@0.5.1: resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==} @@ -934,6 +917,9 @@ packages: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} + strip-literal@3.1.0: + resolution: {integrity: sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==} + supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -946,8 +932,8 @@ packages: resolution: {integrity: sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==} engines: {node: '>=6'} - terser-webpack-plugin@5.3.16: - resolution: {integrity: sha512-h9oBFCWrq78NyWWVcSwZarJkZ01c2AyGrzs1crmHZO3QUg9D61Wu4NPjBy69n7JqylFF5y+CsUZYmYEIZ3mR+Q==} + terser-webpack-plugin@5.3.14: + resolution: {integrity: sha512-vkZjpUjb6OMS7dhV+tILUW6BhpDR7P2L/aQSAv+Uwk+m8KATX9EccViHTJR2qDtACKPIYndLGCyl3FMo+r2LMw==} engines: {node: '>= 10.13.0'} peerDependencies: '@swc/core': '*' @@ -962,24 +948,31 @@ packages: uglify-js: optional: true - terser@5.46.0: - resolution: {integrity: sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==} + terser@5.44.1: + resolution: {integrity: sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==} engines: {node: '>=10'} hasBin: true tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} - tinyexec@1.2.4: - resolution: {integrity: sha512-SHf/r48b7vOrjve9PxJo3MN5v5yuyjHvdUcrQffT3WXMUfnGmHDVbC4k3sHJaJTgZCwpUplIaAo5ANtMyp3YHg==} - engines: {node: '>=18'} + tinyexec@0.3.2: + resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} - tinyglobby@0.2.17: - resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + tinyglobby@0.2.15: + resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} - tinyrainbow@3.1.0: - resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==} + tinypool@1.1.1: + resolution: {integrity: sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==} + engines: {node: ^18.0.0 || >=20.0.0} + + tinyrainbow@2.0.0: + resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==} + engines: {node: '>=14.0.0'} + + tinyspy@4.0.4: + resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==} engines: {node: '>=14.0.0'} tldts-core@7.0.19: @@ -1016,12 +1009,17 @@ packages: undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - update-browserslist-db@1.2.3: - resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==} + update-browserslist-db@1.1.4: + resolution: {integrity: sha512-q0SPT4xyU84saUX+tomz1WLkxUbuaJnR1xWt17M7fJtEJigJeWUNGUqrauFXsHnqev9y9JTRGwk13tFBuKby4A==} hasBin: true peerDependencies: browserslist: '>= 4.21.0' + vite-node@3.2.4: + resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} + hasBin: true + vite@7.2.6: resolution: {integrity: sha512-tI2l/nFHC5rLh7+5+o7QjKjSR04ivXDF4jcgV0f/bTQ+OJiITy5S6gaynVsEM+7RqzufMnVbIon6Sr5x1SDYaQ==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1062,33 +1060,26 @@ packages: yaml: optional: true - vitest@4.1.0: - resolution: {integrity: sha512-YbDrMF9jM2Lqc++2530UourxZHmkKLxrs4+mYhEwqWS97WJ7wOYEkcr+QfRgJ3PW9wz3odRijLZjHEaRLTNbqw==} - engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} + vitest@3.2.4: + resolution: {integrity: sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' - '@opentelemetry/api': ^1.9.0 - '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0 - '@vitest/browser-playwright': 4.1.0 - '@vitest/browser-preview': 4.1.0 - '@vitest/browser-webdriverio': 4.1.0 - '@vitest/ui': 4.1.0 + '@types/debug': ^4.1.12 + '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0 + '@vitest/browser': 3.2.4 + '@vitest/ui': 3.2.4 happy-dom: '*' jsdom: '*' - vite: ^6.0.0 || ^7.0.0 || ^8.0.0-0 peerDependenciesMeta: '@edge-runtime/vm': optional: true - '@opentelemetry/api': + '@types/debug': optional: true '@types/node': optional: true - '@vitest/browser-playwright': - optional: true - '@vitest/browser-preview': - optional: true - '@vitest/browser-webdriverio': + '@vitest/browser': optional: true '@vitest/ui': optional: true @@ -1097,16 +1088,16 @@ packages: jsdom: optional: true - watchpack@2.5.1: - resolution: {integrity: sha512-Zn5uXdcFNIA1+1Ei5McRd+iRzfhENPCe7LeABkJtNulSxjma+l7ltNx55BWZkRlwRnpOgHqxnjyaDgJnNXnqzg==} + watchpack@2.4.4: + resolution: {integrity: sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==} engines: {node: '>=10.13.0'} webpack-sources@3.3.3: resolution: {integrity: sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg==} engines: {node: '>=10.13.0'} - webpack@5.104.1: - resolution: {integrity: sha512-Qphch25abbMNtekmEGJmeRUhLDbe+QfiWTiqpKYkpCOWY64v9eyl+KRRLmqOFA2AvKPpc9DC6+u2n76tQLBoaA==} + webpack@5.103.0: + resolution: {integrity: sha512-HU1JOuV1OavsZ+mfigY0j8d1TgQgbZ6M+J75zDkpEAwYeXjWSqrGJtgnPblJjd/mAyTNQ7ygw0MiKOn6etz8yw==} engines: {node: '>=10.13.0'} hasBin: true peerDependencies: @@ -1332,83 +1323,72 @@ snapshots: '@open-draft/until@2.1.0': {} - '@rollup/rollup-android-arm-eabi@4.61.0': - optional: true - - '@rollup/rollup-android-arm64@4.61.0': - optional: true - - '@rollup/rollup-darwin-arm64@4.61.0': - optional: true - - '@rollup/rollup-darwin-x64@4.61.0': + '@rollup/rollup-android-arm-eabi@4.53.3': optional: true - '@rollup/rollup-freebsd-arm64@4.61.0': + '@rollup/rollup-android-arm64@4.53.3': optional: true - '@rollup/rollup-freebsd-x64@4.61.0': + '@rollup/rollup-darwin-arm64@4.53.3': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.61.0': + '@rollup/rollup-darwin-x64@4.53.3': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.61.0': + '@rollup/rollup-freebsd-arm64@4.53.3': optional: true - '@rollup/rollup-linux-arm64-gnu@4.61.0': + '@rollup/rollup-freebsd-x64@4.53.3': optional: true - '@rollup/rollup-linux-arm64-musl@4.61.0': + '@rollup/rollup-linux-arm-gnueabihf@4.53.3': optional: true - '@rollup/rollup-linux-loong64-gnu@4.61.0': + '@rollup/rollup-linux-arm-musleabihf@4.53.3': optional: true - '@rollup/rollup-linux-loong64-musl@4.61.0': + '@rollup/rollup-linux-arm64-gnu@4.53.3': optional: true - '@rollup/rollup-linux-ppc64-gnu@4.61.0': + '@rollup/rollup-linux-arm64-musl@4.53.3': optional: true - '@rollup/rollup-linux-ppc64-musl@4.61.0': + '@rollup/rollup-linux-loong64-gnu@4.53.3': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.61.0': + '@rollup/rollup-linux-ppc64-gnu@4.53.3': optional: true - '@rollup/rollup-linux-riscv64-musl@4.61.0': + '@rollup/rollup-linux-riscv64-gnu@4.53.3': optional: true - '@rollup/rollup-linux-s390x-gnu@4.61.0': + '@rollup/rollup-linux-riscv64-musl@4.53.3': optional: true - '@rollup/rollup-linux-x64-gnu@4.61.0': + '@rollup/rollup-linux-s390x-gnu@4.53.3': optional: true - '@rollup/rollup-linux-x64-musl@4.61.0': + '@rollup/rollup-linux-x64-gnu@4.53.3': optional: true - '@rollup/rollup-openbsd-x64@4.61.0': + '@rollup/rollup-linux-x64-musl@4.53.3': optional: true - '@rollup/rollup-openharmony-arm64@4.61.0': + '@rollup/rollup-openharmony-arm64@4.53.3': optional: true - '@rollup/rollup-win32-arm64-msvc@4.61.0': + '@rollup/rollup-win32-arm64-msvc@4.53.3': optional: true - '@rollup/rollup-win32-ia32-msvc@4.61.0': + '@rollup/rollup-win32-ia32-msvc@4.53.3': optional: true - '@rollup/rollup-win32-x64-gnu@4.61.0': + '@rollup/rollup-win32-x64-gnu@4.53.3': optional: true - '@rollup/rollup-win32-x64-msvc@4.61.0': + '@rollup/rollup-win32-x64-msvc@4.53.3': optional: true - '@standard-schema/spec@1.1.0': {} - '@types/chai@5.2.3': dependencies: '@types/deep-eql': 4.0.2 @@ -1430,8 +1410,6 @@ snapshots: '@types/estree@1.0.8': {} - '@types/estree@1.0.9': {} - '@types/json-schema@7.0.15': {} '@types/node@18.19.130': @@ -1440,47 +1418,48 @@ snapshots: '@types/statuses@2.0.6': {} - '@vitest/expect@4.1.0': + '@vitest/expect@3.2.4': dependencies: - '@standard-schema/spec': 1.1.0 '@types/chai': 5.2.3 - '@vitest/spy': 4.1.0 - '@vitest/utils': 4.1.0 - chai: 6.2.2 - tinyrainbow: 3.1.0 + '@vitest/spy': 3.2.4 + '@vitest/utils': 3.2.4 + chai: 5.3.3 + tinyrainbow: 2.0.0 - '@vitest/mocker@4.1.0(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(vite@7.2.6(@types/node@18.19.130)(terser@5.46.0))': + '@vitest/mocker@3.2.4(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(vite@7.2.6(@types/node@18.19.130)(terser@5.44.1))': dependencies: - '@vitest/spy': 4.1.0 + '@vitest/spy': 3.2.4 estree-walker: 3.0.3 magic-string: 0.30.21 optionalDependencies: msw: 2.11.2(@types/node@18.19.130)(typescript@5.7.3) - vite: 7.2.6(@types/node@18.19.130)(terser@5.46.0) + vite: 7.2.6(@types/node@18.19.130)(terser@5.44.1) - '@vitest/pretty-format@4.1.0': + '@vitest/pretty-format@3.2.4': dependencies: - tinyrainbow: 3.1.0 + tinyrainbow: 2.0.0 - '@vitest/runner@4.1.0': + '@vitest/runner@3.2.4': dependencies: - '@vitest/utils': 4.1.0 + '@vitest/utils': 3.2.4 pathe: 2.0.3 + strip-literal: 3.1.0 - '@vitest/snapshot@4.1.0': + '@vitest/snapshot@3.2.4': dependencies: - '@vitest/pretty-format': 4.1.0 - '@vitest/utils': 4.1.0 + '@vitest/pretty-format': 3.2.4 magic-string: 0.30.21 pathe: 2.0.3 - '@vitest/spy@4.1.0': {} + '@vitest/spy@3.2.4': + dependencies: + tinyspy: 4.0.4 - '@vitest/utils@4.1.0': + '@vitest/utils@3.2.4': dependencies: - '@vitest/pretty-format': 4.1.0 - convert-source-map: 2.0.0 - tinyrainbow: 3.1.0 + '@vitest/pretty-format': 3.2.4 + loupe: 3.2.1 + tinyrainbow: 2.0.0 '@webassemblyjs/ast@1.14.1': dependencies: @@ -1592,31 +1571,41 @@ snapshots: assertion-error@2.0.1: {} - baseline-browser-mapping@2.9.19: {} + baseline-browser-mapping@2.8.32: {} braces@3.0.3: dependencies: fill-range: 7.1.1 - browserslist@4.28.1: + browserslist@4.28.0: dependencies: - baseline-browser-mapping: 2.9.19 - caniuse-lite: 1.0.30001769 - electron-to-chromium: 1.5.286 + baseline-browser-mapping: 2.8.32 + caniuse-lite: 1.0.30001757 + electron-to-chromium: 1.5.263 node-releases: 2.0.27 - update-browserslist-db: 1.2.3(browserslist@4.28.1) + update-browserslist-db: 1.1.4(browserslist@4.28.0) buffer-from@1.1.2: {} - caniuse-lite@1.0.30001769: {} + cac@6.7.14: {} - chai@6.2.2: {} + caniuse-lite@1.0.30001757: {} + + chai@5.3.3: + dependencies: + assertion-error: 2.0.1 + check-error: 2.1.1 + deep-eql: 5.0.2 + loupe: 3.2.1 + pathval: 2.0.1 chalk@4.1.2: dependencies: ansi-styles: 4.3.0 supports-color: 7.2.0 + check-error@2.1.1: {} + chrome-trace-event@1.0.4: {} cli-width@4.1.0: {} @@ -1635,11 +1624,15 @@ snapshots: commander@2.20.3: {} - convert-source-map@2.0.0: {} - cookie@0.7.2: {} - electron-to-chromium@1.5.286: {} + debug@4.4.3: + dependencies: + ms: 2.1.3 + + deep-eql@5.0.2: {} + + electron-to-chromium@1.5.263: {} emoji-regex@8.0.0: {} @@ -1648,14 +1641,7 @@ snapshots: graceful-fs: 4.2.11 tapable: 2.3.0 - enhanced-resolve@5.19.0: - dependencies: - graceful-fs: 4.2.11 - tapable: 2.3.0 - - es-module-lexer@2.0.0: {} - - es-module-lexer@2.1.0: {} + es-module-lexer@1.7.0: {} esbuild@0.25.12: optionalDependencies: @@ -1703,19 +1689,19 @@ snapshots: estree-walker@3.0.3: dependencies: - '@types/estree': 1.0.9 + '@types/estree': 1.0.8 events@3.3.0: {} - expect-type@1.3.0: {} + expect-type@1.2.2: {} fast-deep-equal@3.1.3: {} fast-uri@3.1.0: {} - fdir@6.5.0(picomatch@4.0.4): + fdir@6.5.0(picomatch@4.0.3): optionalDependencies: - picomatch: 4.0.4 + picomatch: 4.0.3 fill-range@7.1.1: dependencies: @@ -1748,12 +1734,16 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 + js-tokens@9.0.1: {} + json-parse-even-better-errors@2.3.1: {} json-schema-traverse@1.0.0: {} loader-runner@4.3.1: {} + loupe@3.2.1: {} + magic-string@0.30.21: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 @@ -1771,6 +1761,8 @@ snapshots: dependencies: mime-db: 1.52.0 + ms@2.1.3: {} + msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3): dependencies: '@bundled-es-modules/cookie': 2.0.1 @@ -1799,29 +1791,29 @@ snapshots: mute-stream@2.0.0: {} - nanoid@3.3.12: {} + nanoid@3.3.11: {} neo-async@2.6.2: {} node-releases@2.0.27: {} - obug@2.1.1: {} - outvariant@1.4.3: {} path-to-regexp@6.3.0: {} pathe@2.0.3: {} + pathval@2.0.1: {} + picocolors@1.1.1: {} picomatch@2.3.1: {} - picomatch@4.0.4: {} + picomatch@4.0.3: {} - postcss@8.5.15: + postcss@8.5.6: dependencies: - nanoid: 3.3.12 + nanoid: 3.3.11 picocolors: 1.1.1 source-map-js: 1.2.1 @@ -1835,35 +1827,32 @@ snapshots: rettime@0.7.0: {} - rollup@4.61.0: + rollup@4.53.3: dependencies: - '@types/estree': 1.0.9 + '@types/estree': 1.0.8 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.61.0 - '@rollup/rollup-android-arm64': 4.61.0 - '@rollup/rollup-darwin-arm64': 4.61.0 - '@rollup/rollup-darwin-x64': 4.61.0 - '@rollup/rollup-freebsd-arm64': 4.61.0 - '@rollup/rollup-freebsd-x64': 4.61.0 - '@rollup/rollup-linux-arm-gnueabihf': 4.61.0 - '@rollup/rollup-linux-arm-musleabihf': 4.61.0 - '@rollup/rollup-linux-arm64-gnu': 4.61.0 - '@rollup/rollup-linux-arm64-musl': 4.61.0 - '@rollup/rollup-linux-loong64-gnu': 4.61.0 - '@rollup/rollup-linux-loong64-musl': 4.61.0 - '@rollup/rollup-linux-ppc64-gnu': 4.61.0 - '@rollup/rollup-linux-ppc64-musl': 4.61.0 - '@rollup/rollup-linux-riscv64-gnu': 4.61.0 - '@rollup/rollup-linux-riscv64-musl': 4.61.0 - '@rollup/rollup-linux-s390x-gnu': 4.61.0 - '@rollup/rollup-linux-x64-gnu': 4.61.0 - '@rollup/rollup-linux-x64-musl': 4.61.0 - '@rollup/rollup-openbsd-x64': 4.61.0 - '@rollup/rollup-openharmony-arm64': 4.61.0 - '@rollup/rollup-win32-arm64-msvc': 4.61.0 - '@rollup/rollup-win32-ia32-msvc': 4.61.0 - '@rollup/rollup-win32-x64-gnu': 4.61.0 - '@rollup/rollup-win32-x64-msvc': 4.61.0 + '@rollup/rollup-android-arm-eabi': 4.53.3 + '@rollup/rollup-android-arm64': 4.53.3 + '@rollup/rollup-darwin-arm64': 4.53.3 + '@rollup/rollup-darwin-x64': 4.53.3 + '@rollup/rollup-freebsd-arm64': 4.53.3 + '@rollup/rollup-freebsd-x64': 4.53.3 + '@rollup/rollup-linux-arm-gnueabihf': 4.53.3 + '@rollup/rollup-linux-arm-musleabihf': 4.53.3 + '@rollup/rollup-linux-arm64-gnu': 4.53.3 + '@rollup/rollup-linux-arm64-musl': 4.53.3 + '@rollup/rollup-linux-loong64-gnu': 4.53.3 + '@rollup/rollup-linux-ppc64-gnu': 4.53.3 + '@rollup/rollup-linux-riscv64-gnu': 4.53.3 + '@rollup/rollup-linux-riscv64-musl': 4.53.3 + '@rollup/rollup-linux-s390x-gnu': 4.53.3 + '@rollup/rollup-linux-x64-gnu': 4.53.3 + '@rollup/rollup-linux-x64-musl': 4.53.3 + '@rollup/rollup-openharmony-arm64': 4.53.3 + '@rollup/rollup-win32-arm64-msvc': 4.53.3 + '@rollup/rollup-win32-ia32-msvc': 4.53.3 + '@rollup/rollup-win32-x64-gnu': 4.53.3 + '@rollup/rollup-win32-x64-msvc': 4.53.3 fsevents: 2.3.3 safe-buffer@5.2.1: {} @@ -1900,7 +1889,7 @@ snapshots: statuses@2.0.2: {} - std-env@4.1.0: {} + std-env@3.10.0: {} strict-event-emitter@0.5.1: {} @@ -1914,6 +1903,10 @@ snapshots: dependencies: ansi-regex: 5.0.1 + strip-literal@3.1.0: + dependencies: + js-tokens: 9.0.1 + supports-color@7.2.0: dependencies: has-flag: 4.0.0 @@ -1924,16 +1917,16 @@ snapshots: tapable@2.3.0: {} - terser-webpack-plugin@5.3.16(webpack@5.104.1): + terser-webpack-plugin@5.3.14(webpack@5.103.0): dependencies: '@jridgewell/trace-mapping': 0.3.31 jest-worker: 27.5.1 schema-utils: 4.3.3 serialize-javascript: 6.0.2 - terser: 5.46.0 - webpack: 5.104.1 + terser: 5.44.1 + webpack: 5.103.0 - terser@5.46.0: + terser@5.44.1: dependencies: '@jridgewell/source-map': 0.3.11 acorn: 8.15.0 @@ -1942,14 +1935,18 @@ snapshots: tinybench@2.9.0: {} - tinyexec@1.2.4: {} + tinyexec@0.3.2: {} - tinyglobby@0.2.17: + tinyglobby@0.2.15: dependencies: - fdir: 6.5.0(picomatch@4.0.4) - picomatch: 4.0.4 + fdir: 6.5.0(picomatch@4.0.3) + picomatch: 4.0.3 - tinyrainbow@3.1.0: {} + tinypool@1.1.1: {} + + tinyrainbow@2.0.0: {} + + tinyspy@4.0.4: {} tldts-core@7.0.19: {} @@ -1965,7 +1962,7 @@ snapshots: dependencies: tldts: 7.0.19 - ts-loader@9.5.4(typescript@5.7.3)(webpack@5.104.1): + ts-loader@9.5.4(typescript@5.7.3)(webpack@5.103.0): dependencies: chalk: 4.1.2 enhanced-resolve: 5.18.3 @@ -1973,7 +1970,7 @@ snapshots: semver: 7.7.3 source-map: 0.7.6 typescript: 5.7.3 - webpack: 5.104.1 + webpack: 5.103.0 type-fest@4.41.0: {} @@ -1981,60 +1978,95 @@ snapshots: undici-types@5.26.5: {} - update-browserslist-db@1.2.3(browserslist@4.28.1): + update-browserslist-db@1.1.4(browserslist@4.28.0): dependencies: - browserslist: 4.28.1 + browserslist: 4.28.0 escalade: 3.2.0 picocolors: 1.1.1 - vite@7.2.6(@types/node@18.19.130)(terser@5.46.0): + vite-node@3.2.4(@types/node@18.19.130)(terser@5.44.1): + dependencies: + cac: 6.7.14 + debug: 4.4.3 + es-module-lexer: 1.7.0 + pathe: 2.0.3 + vite: 7.2.6(@types/node@18.19.130)(terser@5.44.1) + transitivePeerDependencies: + - '@types/node' + - jiti + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - yaml + + vite@7.2.6(@types/node@18.19.130)(terser@5.44.1): dependencies: esbuild: 0.25.12 - fdir: 6.5.0(picomatch@4.0.4) - picomatch: 4.0.4 - postcss: 8.5.15 - rollup: 4.61.0 - tinyglobby: 0.2.17 + fdir: 6.5.0(picomatch@4.0.3) + picomatch: 4.0.3 + postcss: 8.5.6 + rollup: 4.53.3 + tinyglobby: 0.2.15 optionalDependencies: '@types/node': 18.19.130 fsevents: 2.3.3 - terser: 5.46.0 - - vitest@4.1.0(@types/node@18.19.130)(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(vite@7.2.6(@types/node@18.19.130)(terser@5.46.0)): - dependencies: - '@vitest/expect': 4.1.0 - '@vitest/mocker': 4.1.0(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(vite@7.2.6(@types/node@18.19.130)(terser@5.46.0)) - '@vitest/pretty-format': 4.1.0 - '@vitest/runner': 4.1.0 - '@vitest/snapshot': 4.1.0 - '@vitest/spy': 4.1.0 - '@vitest/utils': 4.1.0 - es-module-lexer: 2.1.0 - expect-type: 1.3.0 + terser: 5.44.1 + + vitest@3.2.4(@types/node@18.19.130)(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(terser@5.44.1): + dependencies: + '@types/chai': 5.2.3 + '@vitest/expect': 3.2.4 + '@vitest/mocker': 3.2.4(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(vite@7.2.6(@types/node@18.19.130)(terser@5.44.1)) + '@vitest/pretty-format': 3.2.4 + '@vitest/runner': 3.2.4 + '@vitest/snapshot': 3.2.4 + '@vitest/spy': 3.2.4 + '@vitest/utils': 3.2.4 + chai: 5.3.3 + debug: 4.4.3 + expect-type: 1.2.2 magic-string: 0.30.21 - obug: 2.1.1 pathe: 2.0.3 - picomatch: 4.0.4 - std-env: 4.1.0 + picomatch: 4.0.3 + std-env: 3.10.0 tinybench: 2.9.0 - tinyexec: 1.2.4 - tinyglobby: 0.2.17 - tinyrainbow: 3.1.0 - vite: 7.2.6(@types/node@18.19.130)(terser@5.46.0) + tinyexec: 0.3.2 + tinyglobby: 0.2.15 + tinypool: 1.1.1 + tinyrainbow: 2.0.0 + vite: 7.2.6(@types/node@18.19.130)(terser@5.44.1) + vite-node: 3.2.4(@types/node@18.19.130)(terser@5.44.1) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 18.19.130 transitivePeerDependencies: + - jiti + - less + - lightningcss - msw + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - yaml - watchpack@2.5.1: + watchpack@2.4.4: dependencies: glob-to-regexp: 0.4.1 graceful-fs: 4.2.11 webpack-sources@3.3.3: {} - webpack@5.104.1: + webpack@5.103.0: dependencies: '@types/eslint-scope': 3.7.7 '@types/estree': 1.0.8 @@ -2044,10 +2076,10 @@ snapshots: '@webassemblyjs/wasm-parser': 1.14.1 acorn: 8.15.0 acorn-import-phases: 1.0.4(acorn@8.15.0) - browserslist: 4.28.1 + browserslist: 4.28.0 chrome-trace-event: 1.0.4 - enhanced-resolve: 5.19.0 - es-module-lexer: 2.0.0 + enhanced-resolve: 5.18.3 + es-module-lexer: 1.7.0 eslint-scope: 5.1.1 events: 3.3.0 glob-to-regexp: 0.4.1 @@ -2058,8 +2090,8 @@ snapshots: neo-async: 2.6.2 schema-utils: 4.3.3 tapable: 2.3.0 - terser-webpack-plugin: 5.3.16(webpack@5.104.1) - watchpack: 2.5.1 + terser-webpack-plugin: 5.3.14(webpack@5.103.0) + watchpack: 2.4.4 webpack-sources: 3.3.3 transitivePeerDependencies: - '@swc/core' diff --git a/reference.md b/reference.md index 224ae271..ebb436eb 100644 --- a/reference.md +++ b/reference.md @@ -194,7 +194,7 @@ await client.admins.listAllActivityLogs({ -
client.admins.list() -> Intercom.AdminList +
client.admins.list({ ...params }) -> Intercom.AdminList
@@ -221,7 +221,9 @@ You can fetch a list of admins for a given workspace.
```typescript -await client.admins.list(); +await client.admins.list({ + display_avatar: true +}); ```
@@ -237,6 +239,14 @@ await client.admins.list();
+**request:** `Intercom.ListAdminsRequest` + +
+
+ +
+
+ **requestOptions:** `AdminsClient.RequestOptions`
@@ -1035,6 +1045,10 @@ const response = page.response;
You can create a new article by making a POST request to `https://api.intercom.io/articles`. + +> 📘 Tags cannot be managed via the Articles API +> +> Article tags are read-only in responses. To create, update, or delete tags, use the Intercom UI or the Tags API endpoints.
@@ -1180,6 +1194,10 @@ await client.articles.find({
You can update the details of a single article by making a PUT request to `https://api.intercom.io/articles/`. + +> 📘 Tags cannot be managed via the Articles API +> +> Article tags are read-only in responses. To create, update, or delete tags, use the Intercom UI or the Tags API endpoints.
@@ -1368,7 +1386,7 @@ await client.articles.search({
## Away Status Reasons -
client.awayStatusReasons.listAwayStatusReasons() -> Intercom.AwayStatusReason[] +
client.awayStatusReasons.listAwayStatusReasons() -> Intercom.AwayStatusReasonList
@@ -1423,8 +1441,8 @@ await client.awayStatusReasons.listAwayStatusReasons();
-## Export -
client.export.enqueueANewReportingDataExportJob({ ...params }) -> Intercom.PostExportReportingDataEnqueueResponse +## ReportingDataExport +
client.reportingDataExport.enqueueANewReportingDataExportJob({ ...params }) -> Intercom.PostExportReportingDataEnqueueResponse
@@ -1437,7 +1455,7 @@ await client.awayStatusReasons.listAwayStatusReasons();
```typescript -await client.export.enqueueANewReportingDataExportJob({ +await client.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "conversation", attribute_ids: ["conversation_id", "conversation_started_at"], start_time: 1717490000, @@ -1466,7 +1484,7 @@ await client.export.enqueueANewReportingDataExportJob({
-**requestOptions:** `ExportClient.RequestOptions` +**requestOptions:** `ReportingDataExportClient.RequestOptions`
@@ -1478,7 +1496,7 @@ await client.export.enqueueANewReportingDataExportJob({
-
client.export.listAvailableDatasetsAndAttributes() -> Intercom.GetExportReportingDataGetDatasetsResponse +
client.reportingDataExport.listAvailableDatasetsAndAttributes() -> Intercom.GetExportReportingDataGetDatasetsResponse
@@ -1491,7 +1509,7 @@ await client.export.enqueueANewReportingDataExportJob({
```typescript -await client.export.listAvailableDatasetsAndAttributes(); +await client.reportingDataExport.listAvailableDatasetsAndAttributes(); ```
@@ -1507,7 +1525,7 @@ await client.export.listAvailableDatasetsAndAttributes();
-**requestOptions:** `ExportClient.RequestOptions` +**requestOptions:** `ReportingDataExportClient.RequestOptions`
@@ -1657,6 +1675,8 @@ await client.dataExport.downloadReportingDataExport({ To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. +This endpoint exports **message delivery and engagement data** for outbound content (Emails, Posts, Custom Bots, Surveys, Tours, Series, and more). The exported data includes who received each message, when they received it, and how they engaged with it (opens, clicks, replies, completions, dismissals, unsubscribes, and bounces). It does not export raw message or conversation content. + The only parameters you need to provide are the range of dates that you want exported. >🚧 Limit of one active job @@ -1924,6 +1944,255 @@ await client.dataExport.download({
+ + +
+ +## Fin Agent +
client.finAgent.startFinConversation({ ...params }) -> Intercom.StartFinConversationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Initialize Fin by passing it the user's message along with conversation history and user details. + +These additional pieces of context will be used by Fin to provide a better and more contextual answer to the user. + +{% admonition type="warning" %} +Please reach out to your accounts team to discuss access. +{% /admonition %} + +Once Fin is initialized, it progresses through a series of statuses such as *thinking*, *awaiting_user_reply*, or *resolved* before ending with a status of *complete*. + +During this workflow, the client should allow Fin to continue uninterrupted until a final *complete* status is returned via webhook, at which point control of the conversation passes back to the client. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z" + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.StartFinConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `FinAgentClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.finAgent.replyToFin({ ...params }) -> Intercom.ReplyToFinResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Once Fin has returned a response to a user's message, its status will be `awaiting_user_reply`. + +If a user replies, use this endpoint to send this response to Fin. + +{% admonition type="warning" %} +Please reach out to your accounts team to discuss access. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.finAgent.replyToFin({ + conversation_id: "123456", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z" + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.ReplyToFinRequest` + +
+
+ +
+
+ +**requestOptions:** `FinAgentClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.finAgent.submitFinCsat({ ...params }) -> Intercom.SubmitFinCsatResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Record a customer's satisfaction rating for a conversation, with an optional free-text +remark. + +Fin decides *when* to ask for a rating — this reuses the CSAT settings on your Fin +workflow, not this API. When Fin asks, it fires a `csat_requested` event over webhooks or +SSE carrying the rating options to show the user. Present those options, then submit the +user's choice here. + +Submitting the same rating again, with no new remark, is a no-op and stays successful, +so an at-least-once client can safely retry. Submitting a *different* rating updates the +stored rating while the update window is still open, and a first remark can be added to +an already-rated survey. Once a remark has been recorded the rating is locked and can no +longer be changed. + +{% admonition type="warning" %} +Please reach out to your accounts team to discuss access. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.finAgent.submitFinCsat({ + conversation_id: "ext-123", + rating: "amazing" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.SubmitFinCsatRequest` + +
+
+ +
+
+ +**requestOptions:** `FinAgentClient.RequestOptions` + +
+
+
+
+ +
@@ -2887,7 +3156,15 @@ await client.companies.update({
-You can delete a single company. +Delete a single company. + +This endpoint does not permanently remove the company. It archives the company record and detaches any contacts attached to it; the contacts themselves are not deleted. A `company.deleted` webhook is sent once archival completes. + +The endpoint returns `200` with `"deleted": true` as soon as the request is accepted — archival is processed asynchronously. + +{% admonition type="warning" %} +Third-party integrations that sync companies into Intercom (for example, Salesforce or Chargebee) will recreate any company deleted through this endpoint on their next sync. To prevent recreation, remove or filter the company at the source integration before deleting it via the API. +{% /admonition %}
@@ -3554,6 +3831,8 @@ The data property will show a combined list of: 1.Opt-out subscription types that the user has opted-out from. 2.Opt-in subscription types that the user has opted-in to receiving. + +**Note:** This endpoint only returns subscriptions where the contact has explicitly configured their preference. Subscriptions that are in the default state — where the contact has not made an explicit opt-in or opt-out choice — are not included in the response. @@ -3823,6 +4102,10 @@ await client.contacts.listAttachedTags({
You can fetch the details of a single contact. + +{% admonition type="warning" name="Merged contacts" %} + If a contact has been merged into another contact via the Merge endpoint (POST /contacts/merge), requesting it by its original ID will return a `404 Not Found` error. Use the merged-into contact's ID instead. +{% /admonition %}
@@ -4026,6 +4309,15 @@ await client.contacts.delete({
You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. + +{% admonition type="warning" name="Merged contacts are not retrievable via the API" %} + Once a merge is completed, the source contact (`from`) is permanently removed from the active contact list. This means: + - **GET /contacts/{id}** — Requesting the source contact by its original ID will return a `404 Not Found` error. + - **POST /contacts/search** — The source contact will not appear in search results, including queries filtered by `updated_at`. + - **GET /contacts** — The source contact will not appear in list results. + + Only the target contact (`into`) remains accessible. If your application stores contact IDs, update them to use the target contact's ID after a merge. +{% /admonition %}
@@ -4103,6 +4395,10 @@ This will accept a query object in the body which will define your filters in or pagination to limit the number of results returned. The default is `50` results per page. See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. {% /admonition %} +### Merged Contacts + +Contacts that have been merged (via POST /contacts/merge) are excluded from search results. If a contact was recently merged into another, it will no longer appear in queries filtered by `updated_at` or any other field. Only the target contact from the merge remains searchable. + ### Contact Creation Delay If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. @@ -4116,10 +4412,23 @@ There are some limitations to the amount of multiple's there can be: ### Searching for Timestamp Fields -All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. -For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. -If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). -This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly. +Timestamp fields (`created_at`, `updated_at` etc.) and Date custom attributes are matched by calendar day. Sub-day precision (hour, minute, second) is not supported. + +The day boundary uses **your workspace's timezone**, so the same query can return different results on two workspaces in different timezones. + +Because the value is truncated to a day: + +* `=` matches the whole day. +* `>` matches from the start of the *next* day, not from the instant you passed. +* `<` matches everything before the start of that day. + +The `!=`, `>=`, `<=`, `IN` and `NIN` operators are not supported on Date fields and return an error. + +**Example**, on a workspace set to UTC. Searching for `created_at` greater than `1577869200` (January 1st, 2020 9:00 AM UTC) truncates that value to `1577836800` (January 1st, 2020 12:00 AM UTC). Because `>` starts at the next day, the results begin from January 2nd, 2020 12:00 AM UTC - not from 9:00 AM on January 1st. On a workspace in another timezone, the boundaries fall on that timezone's midnight instead. + +To get contacts created on January 1st, 2020, search for `created_at` equal to `1577836800`. + +Only search queries behave this way. Responses still carry the full UNIX timestamp, and sorting uses the full value. ### Accepted Fields @@ -4172,24 +4481,26 @@ Most key listed as part of the Contacts Model are searchable, whether writeable ### Accepted Operators -{% admonition type="warning" name="Searching based on `created_at`" %} - You cannot use the `<=` or `>=` operators to search by `created_at`. +{% admonition type="warning" name="Operators not supported on Date fields" %} + Date fields (`created_at`, `updated_at`, and any Date custom attribute) do not support the `!=`, `>=`, or `<=` operators. Using them returns an error. {% /admonition %} -The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). Which operators are valid depends on the field's type - see the "Valid Types" column below. Searching by `tag_id` supports only the `=` and `!=` operators. -| Operator | Valid Types | Description | -| :------- | :------------------------------- | :--------------------------------------------------------------- | -| = | All | Equals | -| != | All | Doesn't Equal | -| IN | All | In
Shortcut for `OR` queries
Values must be in Array | -| NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | -| > | Integer
Date (UNIX Timestamp) | Greater than | -| < | Integer
Date (UNIX Timestamp) | Lower than | -| ~ | String | Contains | -| !~ | String | Doesn't Contain | -| ^ | String | Starts With | -| $ | String | Ends With | +| Operator | Valid Types | Description | +| :------- | :---------------------------------- | :----------------------------------------------------------------------| +| = | All | Equals | +| != | All except Date | Doesn't Equal | +| IN | All except Date and tag_id | In
Shortcut for `OR` queries
Values must be in Array | +| NIN | All except Date and tag_id | Not In
Shortcut for `OR !` queries
Values must be in Array | +| > | Integer
Date | Greater than
On Date fields, matches from the start of the next day | +| < | Integer
Date | Lower than
On Date fields, matches before the start of the day | +| >= | Integer | Greater than or equal to
Not supported on Date fields | +| <= | Integer | Lower than or equal to
Not supported on Date fields | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | @@ -4289,8 +4600,11 @@ const response = page.response;
You can fetch a list of all contacts (ie. users or leads) in your workspace. +{% admonition type="info" name="Merged contacts" %} + Contacts that have been merged (via POST /contacts/merge) will not appear in list results. Only the target contact from the merge remains accessible. +{% /admonition %} {% admonition type="warning" name="Pagination" %} - You can use pagination to limit the number of results returned. The default is `50` results per page. + You can use pagination to limit the number of results returned. The default is `10` results per page, with a maximum of `150`. See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. {% /admonition %}
@@ -5215,7 +5529,7 @@ await client.tags.list();
-
client.tags.create({ ...params }) -> Intercom.Tag +
client.tags.create({ ...params }) -> Intercom.TagBasic
@@ -5292,7 +5606,7 @@ await client.tags.create({
-
client.tags.find({ ...params }) -> Intercom.Tag +
client.tags.find({ ...params }) -> Intercom.TagBasic
@@ -5558,7 +5872,7 @@ await client.tags.untagTicket({
## Conversations -
client.conversations.list({ ...params }) -> core.Page +
client.conversations.list({ ...params }) -> core.Page
@@ -5824,6 +6138,10 @@ If you want to reply to a coveration or take an action such as assign, unassign, See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. {% /admonition %} +{% admonition type="danger" name="Breaking change: duplicate custom attribute names" %} +The `PUT /conversations/{id}` endpoint now returns a `400 INVALID_PARAMETER` error when the request includes `custom_attributes` and your workspace contains multiple non-archived conversation custom attributes with the same name. Previously, the update would silently apply to a non-deterministic attribute. To resolve, rename or archive the duplicate attribute in your workspace settings, then retry the request. +{% /admonition %} +
@@ -5895,7 +6213,11 @@ await client.conversations.update({
-You can delete a single conversation. +{% admonition type="warning" name="Irreversible operation" %} +Deleting a conversation is permanent and cannot be reversed. +{% /admonition %} + +Deleting a conversation permanently removes it from the inbox. All sensitive data is deleted, including admin and user replies, conversation attributes, uploads, and related content. The conversation will still appear in reporting, though some data may be incomplete due to the deletion.
@@ -5948,7 +6270,7 @@ await client.conversations.deleteConversation({
-
client.conversations.search({ ...params }) -> core.Page +
client.conversations.search({ ...params }) -> core.Page
@@ -6001,8 +6323,8 @@ The `source.body` field is unique as the search will not be performed against th | source.url | String | | contact_ids | String | | teammate_ids | String | -| admin_assignee_id | String | -| team_assignee_id | String | +| admin_assignee_id | Integer | +| team_assignee_id | Integer | | channel_initiated | String | | open | Boolean | | read | Boolean | @@ -6158,6 +6480,12 @@ const response = page.response;
You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + +{% admonition type="warning" name="Bot replies to inbound email" %} +By default, bot or Operator replies to an inbound email conversation aren't sent to your customer. The reply is stored as an unnotifiable bot comment, and no `seen` receipt is generated until an email is actually delivered. + +To send these replies as outbound emails, reach out to your accounts team to enable the email-reply feature flag for your workspace. +{% /admonition %}
@@ -6290,7 +6618,7 @@ await client.conversations.manage({
-
client.conversations.attachContactAsAdmin({ ...params }) -> Intercom.Conversation +
client.conversations.attachContactAsAdmin({ ...params }) -> Intercom.ConversationParticipantsResponse
@@ -6364,7 +6692,7 @@ await client.conversations.attachContactAsAdmin({
-
client.conversations.detachContactAsAdmin({ ...params }) -> Intercom.Conversation +
client.conversations.detachContactAsAdmin({ ...params }) -> Intercom.ConversationParticipantsResponse
@@ -6376,10 +6704,10 @@ await client.conversations.attachContactAsAdmin({
-You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. +You can remove participants who are contacts from a group conversation, on behalf of an admin. -{% admonition type="warning" name="Contacts without an email" %} -If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. +{% admonition type="warning" name="Removing the last participant" %} +You cannot remove the last remaining contact from a conversation. {% /admonition %}
@@ -6645,8 +6973,8 @@ await client.conversations.runAssignmentRules({
-## Custom Channel Events -
client.customChannelEvents.notifyNewConversation({ ...params }) -> Intercom.CustomChannelNotificationResponse +## Custom Object Instances +
client.customObjectInstances.getCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstance | undefined
@@ -6658,8 +6986,7 @@ await client.conversations.runAssignmentRules({
-Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. -> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +Fetch a Custom Object Instance by external_id.
@@ -6674,301 +7001,9 @@ Notifies Intercom that a new conversation was created in your custom channel/pla
```typescript -await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id" - } -}); - -``` -
-
- - - -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CustomChannelBaseEvent` - -
-
- -
-
- -**requestOptions:** `CustomChannelEventsClient.RequestOptions` - -
-
-
-
- - - - -
- -
client.customChannelEvents.notifyNewMessage({ ...params }) -> Intercom.CustomChannelNotificationResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. -> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.NotifyNewMessageRequest` - -
-
- -
-
- -**requestOptions:** `CustomChannelEventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.customChannelEvents.notifyQuickReplySelected({ ...params }) -> Intercom.CustomChannelNotificationResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. -> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyQuickReplySelected({ - event_id: "evt_67890", - external_conversation_id: "conv_13579", - contact: { - type: "user", - external_id: "user_003", - name: "Alice Example", - email: "alice@example.com" - }, - quick_reply_option_id: "1234" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.NotifyQuickReplySelectedRequest` - -
-
- -
-
- -**requestOptions:** `CustomChannelEventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.customChannelEvents.notifyAttributeCollected({ ...params }) -> Intercom.CustomChannelNotificationResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. -> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value" - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.NotifyAttributeCollectedRequest` - -
-
- -
-
- -**requestOptions:** `CustomChannelEventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Custom Object Instances -
client.customObjectInstances.getCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstance | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -Fetch a Custom Object Instance by external_id. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - external_id: "external_id" +await client.customObjectInstances.getCustomObjectInstancesByExternalId({ + custom_object_type_identifier: "Order", + external_id: "external_id" }); ``` @@ -9269,7 +9304,7 @@ await client.tickets.update({
-
client.tickets.deleteTicket({ ...params }) -> Intercom.DeleteTicketResponse +
client.tickets.deleteTicket({ ...params }) -> Intercom.TicketDeleted
@@ -9281,7 +9316,11 @@ await client.tickets.update({
-You can delete a ticket using the Intercom provided ID. +{% admonition type="warning" name="Irreversible operation" %} +Deleting a ticket is permanent and cannot be reversed. +{% /admonition %} + +Deleting a ticket permanently removes it from the inbox. All sensitive data is deleted, including admin and user replies, ticket attributes, uploads, and related content. The ticket will still appear in reporting, though some data may be incomplete due to the deletion.
@@ -10556,8 +10595,8 @@ await client.news.feeds.find({
-## TicketTypes Attributes -
client.ticketTypes.attributes.create({ ...params }) -> Intercom.TicketTypeAttribute | undefined +## Admins +
client.preview.admins.identifyAdmin() -> Intercom.AdminWithApp | undefined
@@ -10569,8 +10608,13 @@ await client.news.feeds.find({
-You can create a new attribute for a ticket type. -
+ +You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + +> 🚧 Single Sign On +> +> If you are building a custom "Log in with Intercom" flow for your site, and you call the `/me` endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk. +
@@ -10584,13 +10628,7 @@ You can create a new attribute for a ticket type.
```typescript -await client.ticketTypes.attributes.create({ - ticket_type_id: "ticket_type_id", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - required_to_create: false -}); +await client.preview.admins.identifyAdmin(); ```
@@ -10606,15 +10644,7 @@ await client.ticketTypes.attributes.create({
-**request:** `Intercom.ticketTypes.CreateTicketTypeAttributeRequest` - -
-
- -
-
- -**requestOptions:** `AttributesClient.RequestOptions` +**requestOptions:** `AdminsClient.RequestOptions`
@@ -10626,7 +10656,7 @@ await client.ticketTypes.attributes.create({
-
client.ticketTypes.attributes.update({ ...params }) -> Intercom.TicketTypeAttribute | undefined +
client.preview.admins.setAwayAdmin({ ...params }) -> Intercom.Admin | undefined
@@ -10638,7 +10668,7 @@ await client.ticketTypes.attributes.create({
-You can update an existing attribute for a ticket type. +You can set an Admin as away for the Inbox.
@@ -10653,10 +10683,11 @@ You can update an existing attribute for a ticket type.
```typescript -await client.ticketTypes.attributes.update({ - ticket_type_id: "ticket_type_id", - attribute_id: "attribute_id", - description: "New Attribute Description" +await client.preview.admins.setAwayAdmin({ + id: 1, + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345 }); ``` @@ -10673,7 +10704,7 @@ await client.ticketTypes.attributes.update({
-**request:** `Intercom.ticketTypes.UpdateTicketTypeAttributeRequest` +**request:** `Intercom.preview.SetAwayAdminRequest`
@@ -10681,7 +10712,7 @@ await client.ticketTypes.attributes.update({
-**requestOptions:** `AttributesClient.RequestOptions` +**requestOptions:** `AdminsClient.RequestOptions`
@@ -10693,8 +10724,7 @@ await client.ticketTypes.attributes.update({
-## Admins -
client.unstable.admins.identifyAdmin() -> Intercom.AdminWithApp | undefined +
client.preview.admins.listActivityLogs({ ...params }) -> Intercom.ActivityLogList
@@ -10706,12 +10736,7 @@ await client.ticketTypes.attributes.update({
- -You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). - -> 🚧 Single Sign On -> -> If you are building a custom "Log in with Intercom" flow for your site, and you call the `/me` endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk. +You can get a log of activities by all admins in an app.
@@ -10726,7 +10751,10 @@ You can view the currently authorised admin along with the embedded app object (
```typescript -await client.unstable.admins.identifyAdmin(); +await client.preview.admins.listActivityLogs({ + created_at_after: "1677253093", + created_at_before: "1677861493" +}); ```
@@ -10742,6 +10770,14 @@ await client.unstable.admins.identifyAdmin();
+**request:** `Intercom.preview.ListActivityLogsRequest` + +
+
+ +
+
+ **requestOptions:** `AdminsClient.RequestOptions`
@@ -10754,7 +10790,7 @@ await client.unstable.admins.identifyAdmin();
-
client.unstable.admins.setAwayAdmin({ ...params }) -> Intercom.Admin | undefined +
client.preview.admins.searchActivityLogs({ ...params }) -> Intercom.ActivityLogList
@@ -10766,7 +10802,7 @@ await client.unstable.admins.identifyAdmin();
-You can set an Admin as away for the Inbox. +Search and filter admin activity logs using a POST request with event type filter in the request body. You can find more details about the available event types in the List all activity log event types endpoint.
@@ -10781,11 +10817,10 @@ You can set an Admin as away for the Inbox.
```typescript -await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345 +await client.preview.admins.searchActivityLogs({ + created_at_after: 1677253093, + created_at_before: 1677861493, + event_types: ["app_name_change", "message_state_change"] }); ``` @@ -10802,7 +10837,7 @@ await client.unstable.admins.setAwayAdmin({
-**request:** `Intercom.unstable.SetAwayAdminRequest` +**request:** `Intercom.preview.SearchActivityLogsRequest`
@@ -10822,7 +10857,7 @@ await client.unstable.admins.setAwayAdmin({
-
client.unstable.admins.listActivityLogs({ ...params }) -> Intercom.ActivityLogList +
client.preview.admins.listActivityLogEventTypes() -> Intercom.ActivityLogEventTypeList
@@ -10834,7 +10869,7 @@ await client.unstable.admins.setAwayAdmin({
-You can get a log of activities by all admins in an app. +You can get a list of all activity log event types. This is useful for discovering valid values to use with the `event_types` filter on the List all activity logs endpoint.
@@ -10849,9 +10884,63 @@ You can get a log of activities by all admins in an app.
```typescript -await client.unstable.admins.listActivityLogs({ - created_at_after: "1677253093", - created_at_before: "1677861493" +await client.preview.admins.listActivityLogEventTypes(); + +``` +
+
+ + + +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `AdminsClient.RequestOptions` + +
+
+
+
+ + + + +
+ +
client.preview.admins.listAdmins({ ...params }) -> Intercom.AdminList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of admins for a given workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.admins.listAdmins({ + display_avatar: true }); ``` @@ -10868,7 +10957,7 @@ await client.unstable.admins.listActivityLogs({
-**request:** `Intercom.unstable.ListActivityLogsRequest` +**request:** `Intercom.preview.ListAdminsRequest`
@@ -10888,7 +10977,7 @@ await client.unstable.admins.listActivityLogs({
-
client.unstable.admins.listAdmins() -> Intercom.AdminList +
client.preview.admins.retrieveAdmin({ ...params }) -> Intercom.Admin | undefined
@@ -10900,7 +10989,7 @@ await client.unstable.admins.listActivityLogs({
-You can fetch a list of admins for a given workspace. +You can retrieve the details of a single admin.
@@ -10915,7 +11004,9 @@ You can fetch a list of admins for a given workspace.
```typescript -await client.unstable.admins.listAdmins(); +await client.preview.admins.retrieveAdmin({ + id: 1 +}); ```
@@ -10931,6 +11022,14 @@ await client.unstable.admins.listAdmins();
+**request:** `Intercom.preview.RetrieveAdminRequest` + +
+
+ +
+
+ **requestOptions:** `AdminsClient.RequestOptions`
@@ -10943,7 +11042,7 @@ await client.unstable.admins.listAdmins();
-
client.unstable.admins.retrieveAdmin({ ...params }) -> Intercom.Admin | undefined +
client.preview.admins.removeAdmin({ ...params }) -> Intercom.RemoveAdminResponse
@@ -10955,7 +11054,12 @@ await client.unstable.admins.listAdmins();
-You can retrieve the details of a single admin. +You can remove a single admin (teammate) from your workspace. +Requires the `remove_admins` OAuth scope. + +This removes the admin's access to the workspace and reassigns their +work — auto-messages, ownership, article authorship, and conversation +replies — to the admins named by the `reassign_*` parameters.
@@ -10970,8 +11074,12 @@ You can retrieve the details of a single admin.
```typescript -await client.unstable.admins.retrieveAdmin({ - id: 1 +await client.preview.admins.removeAdmin({ + admin_id: 1, + reassign_messages_admin_id: 1, + reassign_owner_admin_id: 1, + reassign_articles_author_id: 1, + reassign_conversations_admin_id: 1 }); ``` @@ -10988,7 +11096,7 @@ await client.unstable.admins.retrieveAdmin({
-**request:** `Intercom.unstable.RetrieveAdminRequest` +**request:** `Intercom.preview.RemoveAdminRequest`
@@ -11009,7 +11117,7 @@ await client.unstable.admins.retrieveAdmin({
## AI Content -
client.unstable.aiContent.listContentImportSources() -> Intercom.ContentImportSourcesList +
client.preview.aiContent.listContentImportSources() -> Intercom.ContentImportSourcesList
@@ -11036,7 +11144,7 @@ You can retrieve a list of all content import sources for a workspace.
```typescript -await client.unstable.aiContent.listContentImportSources(); +await client.preview.aiContent.listContentImportSources(); ```
@@ -11064,7 +11172,7 @@ await client.unstable.aiContent.listContentImportSources();
-
client.unstable.aiContent.createContentImportSource({ ...params }) -> Intercom.ContentImportSource +
client.preview.aiContent.createContentImportSource({ ...params }) -> Intercom.ContentImportSource
@@ -11091,7 +11199,7 @@ You can create a new content import source by sending a POST request to this end
```typescript -await client.unstable.aiContent.createContentImportSource({ +await client.preview.aiContent.createContentImportSource({ url: "https://www.example.com" }); @@ -11109,7 +11217,7 @@ await client.unstable.aiContent.createContentImportSource({
-**request:** `Intercom.unstable.CreateContentImportSourceRequest` +**request:** `Intercom.preview.CreateContentImportSourceRequest`
@@ -11129,7 +11237,7 @@ await client.unstable.aiContent.createContentImportSource({
-
client.unstable.aiContent.getContentImportSource({ ...params }) -> Intercom.ContentImportSource +
client.preview.aiContent.getContentImportSource({ ...params }) -> Intercom.ContentImportSource
@@ -11142,7 +11250,7 @@ await client.unstable.aiContent.createContentImportSource({
```typescript -await client.unstable.aiContent.getContentImportSource({ +await client.preview.aiContent.getContentImportSource({ id: "id" }); @@ -11160,7 +11268,7 @@ await client.unstable.aiContent.getContentImportSource({
-**request:** `Intercom.unstable.GetContentImportSourceRequest` +**request:** `Intercom.preview.GetContentImportSourceRequest`
@@ -11180,7 +11288,7 @@ await client.unstable.aiContent.getContentImportSource({
-
client.unstable.aiContent.updateContentImportSource({ ...params }) -> Intercom.ContentImportSource +
client.preview.aiContent.updateContentImportSource({ ...params }) -> Intercom.ContentImportSource
@@ -11207,7 +11315,7 @@ You can update an existing content import source.
```typescript -await client.unstable.aiContent.updateContentImportSource({ +await client.preview.aiContent.updateContentImportSource({ id: "id", sync_behavior: "api", url: "https://www.example.com" @@ -11227,7 +11335,7 @@ await client.unstable.aiContent.updateContentImportSource({
-**request:** `Intercom.unstable.UpdateContentImportSourceRequest` +**request:** `Intercom.preview.UpdateContentImportSourceRequest`
@@ -11247,7 +11355,7 @@ await client.unstable.aiContent.updateContentImportSource({
-
client.unstable.aiContent.deleteContentImportSource({ ...params }) -> void +
client.preview.aiContent.deleteContentImportSource({ ...params }) -> void
@@ -11274,7 +11382,7 @@ You can delete a content import source by making a DELETE request this endpoint.
```typescript -await client.unstable.aiContent.deleteContentImportSource({ +await client.preview.aiContent.deleteContentImportSource({ id: "id" }); @@ -11292,7 +11400,7 @@ await client.unstable.aiContent.deleteContentImportSource({
-**request:** `Intercom.unstable.DeleteContentImportSourceRequest` +**request:** `Intercom.preview.DeleteContentImportSourceRequest`
@@ -11312,7 +11420,7 @@ await client.unstable.aiContent.deleteContentImportSource({
-
client.unstable.aiContent.listExternalPages() -> Intercom.ExternalPagesList +
client.preview.aiContent.listExternalPages() -> Intercom.ExternalPagesList
@@ -11339,7 +11447,7 @@ You can retrieve a list of all external pages for a workspace.
```typescript -await client.unstable.aiContent.listExternalPages(); +await client.preview.aiContent.listExternalPages(); ```
@@ -11367,7 +11475,7 @@ await client.unstable.aiContent.listExternalPages();
-
client.unstable.aiContent.createExternalPage({ ...params }) -> Intercom.ExternalPage +
client.preview.aiContent.createExternalPage({ ...params }) -> Intercom.ExternalPage
@@ -11394,7 +11502,7 @@ You can create a new external page by sending a POST request to this endpoint. I
```typescript -await client.unstable.aiContent.createExternalPage({ +await client.preview.aiContent.createExternalPage({ title: "Test", html: "

Test

", url: "https://www.example.com", @@ -11416,7 +11524,7 @@ await client.unstable.aiContent.createExternalPage({
-**request:** `Intercom.unstable.CreateExternalPageRequest` +**request:** `Intercom.preview.CreateExternalPageRequest`
@@ -11436,7 +11544,7 @@ await client.unstable.aiContent.createExternalPage({
-
client.unstable.aiContent.getExternalPage({ ...params }) -> Intercom.ExternalPage +
client.preview.aiContent.getExternalPage({ ...params }) -> Intercom.ExternalPage
@@ -11463,7 +11571,7 @@ You can retrieve an external page.
```typescript -await client.unstable.aiContent.getExternalPage({ +await client.preview.aiContent.getExternalPage({ id: "id" }); @@ -11481,7 +11589,7 @@ await client.unstable.aiContent.getExternalPage({
-**request:** `Intercom.unstable.GetExternalPageRequest` +**request:** `Intercom.preview.GetExternalPageRequest`
@@ -11501,7 +11609,7 @@ await client.unstable.aiContent.getExternalPage({
-
client.unstable.aiContent.updateExternalPage({ ...params }) -> Intercom.ExternalPage +
client.preview.aiContent.updateExternalPage({ ...params }) -> Intercom.ExternalPage
@@ -11528,7 +11636,7 @@ You can update an existing external page (if it was created via the API).
```typescript -await client.unstable.aiContent.updateExternalPage({ +await client.preview.aiContent.updateExternalPage({ id: "id", title: "Test", html: "

Test

", @@ -11551,7 +11659,7 @@ await client.unstable.aiContent.updateExternalPage({
-**request:** `Intercom.unstable.UpdateExternalPageRequest` +**request:** `Intercom.preview.UpdateExternalPageRequest`
@@ -11571,7 +11679,7 @@ await client.unstable.aiContent.updateExternalPage({
-
client.unstable.aiContent.deleteExternalPage({ ...params }) -> Intercom.ExternalPage +
client.preview.aiContent.deleteExternalPage({ ...params }) -> Intercom.ExternalPage
@@ -11598,7 +11706,7 @@ Sending a DELETE request for an external page will remove it from the content li
```typescript -await client.unstable.aiContent.deleteExternalPage({ +await client.preview.aiContent.deleteExternalPage({ id: "id" }); @@ -11616,7 +11724,7 @@ await client.unstable.aiContent.deleteExternalPage({
-**request:** `Intercom.unstable.DeleteExternalPageRequest` +**request:** `Intercom.preview.DeleteExternalPageRequest`
@@ -11637,7 +11745,7 @@ await client.unstable.aiContent.deleteExternalPage({
## Articles -
client.unstable.articles.listArticles() -> Intercom.ArticleList +
client.preview.articles.listArticles() -> Intercom.ArticleList
@@ -11668,7 +11776,7 @@ You can fetch a list of all articles by making a GET request to `https://api.int
```typescript -await client.unstable.articles.listArticles(); +await client.preview.articles.listArticles(); ```
@@ -11696,7 +11804,7 @@ await client.unstable.articles.listArticles();
-
client.unstable.articles.createArticle({ ...params }) -> Intercom.Article +
client.preview.articles.createArticle({ ...params }) -> Intercom.Article
@@ -11709,6 +11817,10 @@ await client.unstable.articles.listArticles();
You can create a new article by making a POST request to `https://api.intercom.io/articles`. + +> 📘 Tags cannot be managed via the Articles API +> +> Article tags are read-only in responses. To create, update, or delete tags, use the Intercom UI or the Tags API endpoints.
@@ -11723,7 +11835,7 @@ You can create a new article by making a POST request to `https://api.intercom.i
```typescript -await client.unstable.articles.createArticle({ +await client.preview.articles.createArticle({ "key": "value" }); @@ -11761,7 +11873,7 @@ await client.unstable.articles.createArticle({
-
client.unstable.articles.retrieveArticle({ ...params }) -> Intercom.Article +
client.preview.articles.retrieveArticle({ ...params }) -> Intercom.Article
@@ -11788,7 +11900,7 @@ You can fetch the details of a single article by making a GET request to `https:
```typescript -await client.unstable.articles.retrieveArticle({ +await client.preview.articles.retrieveArticle({ id: 1 }); @@ -11806,7 +11918,7 @@ await client.unstable.articles.retrieveArticle({
-**request:** `Intercom.unstable.RetrieveArticleRequest` +**request:** `Intercom.preview.RetrieveArticleRequest`
@@ -11826,7 +11938,7 @@ await client.unstable.articles.retrieveArticle({
-
client.unstable.articles.deleteArticle({ ...params }) -> Intercom.DeletedArticleObject +
client.preview.articles.deleteArticle({ ...params }) -> Intercom.DeletedArticleObject
@@ -11853,7 +11965,7 @@ You can delete a single article by making a DELETE request to `https://api.inter
```typescript -await client.unstable.articles.deleteArticle({ +await client.preview.articles.deleteArticle({ id: 1 }); @@ -11871,7 +11983,7 @@ await client.unstable.articles.deleteArticle({
-**request:** `Intercom.unstable.DeleteArticleRequest` +**request:** `Intercom.preview.DeleteArticleRequest`
@@ -11891,7 +12003,7 @@ await client.unstable.articles.deleteArticle({
-
client.unstable.articles.searchArticles({ ...params }) -> Intercom.ArticleSearchResponse +
client.preview.articles.retrieveArticleDraft({ ...params }) -> Intercom.Article
@@ -11903,7 +12015,14 @@ await client.unstable.articles.deleteArticle({
-You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. +Fetch the staged draft of a published article by making a GET request to +`https://api.intercom.io/articles//draft`. The response is the article +rendered with its draft content, leaving the live article untouched. + +A draft exists only when a published article has unpublished changes staged +on top of it. Returns `404` when the article has no staged draft. + +Requires the `read_articles_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -11918,11 +12037,8 @@ You can search for articles by making a GET request to `https://api.intercom.io/
```typescript -await client.unstable.articles.searchArticles({ - phrase: "Getting started", - state: "published", - help_center_id: 1, - highlight: true +await client.preview.articles.retrieveArticleDraft({ + id: 1 }); ``` @@ -11939,7 +12055,7 @@ await client.unstable.articles.searchArticles({
-**request:** `Intercom.unstable.SearchArticlesRequest` +**request:** `Intercom.preview.RetrieveArticleDraftRequest`
@@ -11959,8 +12075,7 @@ await client.unstable.articles.searchArticles({
-## Away Status Reasons -
client.unstable.awayStatusReasons.listAwayStatusReasons() -> Intercom.AwayStatusReason[] +
client.preview.articles.stageArticleDraft({ ...params }) -> Intercom.Article
@@ -11972,7 +12087,18 @@ await client.unstable.articles.searchArticles({
-Returns a list of all away status reasons configured for the workspace, including deleted ones. +Stage changes to a published article as a draft by making a PUT request to +`https://api.intercom.io/articles//draft`. The live article remains +unchanged until the draft is published. + +The article must already be published; staging a draft on an article that +has never been published returns `422`. + +Only versioned text content (such as `title` and `body`) is staged. +Non-versioned fields like AI availability are ignored, leaving the live +values untouched. + +Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -11987,7 +12113,13 @@ Returns a list of all away status reasons configured for the workspace, includin
```typescript -await client.unstable.awayStatusReasons.listAwayStatusReasons(); +await client.preview.articles.stageArticleDraft({ + id: 1, + body: { + title: "Christmas is here!", + body: "

New gifts in store for the jolly season

" + } +}); ```
@@ -12003,7 +12135,15 @@ await client.unstable.awayStatusReasons.listAwayStatusReasons();
-**requestOptions:** `AwayStatusReasonsClient.RequestOptions` +**request:** `Intercom.preview.StageArticleDraftRequest` + +
+
+ +
+
+ +**requestOptions:** `ArticlesClient.RequestOptions`
@@ -12015,11 +12155,33 @@ await client.unstable.awayStatusReasons.listAwayStatusReasons();
-## Unstable Export -
client.unstable.export.enqueueANewReportingDataExportJob({ ...params }) -> Intercom.PostExportReportingDataEnqueueResponse +
client.preview.articles.publishArticleDraft({ ...params }) -> Intercom.Article +
+
+ +#### 📝 Description + +
+
+
+Publish a staged draft by making a POST request to +`https://api.intercom.io/articles//draft/publish`, promoting the draft +content to live. + +On a single-language workspace no body is required. On a multilingual +workspace you must list which locales to publish via the `locales` array; +omitting it returns `422`. Returns `422` when there is no staged draft to +publish, or when a requested locale has no pending changes. + +Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. +
+
+
+
+ #### 🔌 Usage
@@ -12029,11 +12191,11 @@ await client.unstable.awayStatusReasons.listAwayStatusReasons();
```typescript -await client.unstable.export.enqueueANewReportingDataExportJob({ - dataset_id: "conversation", - attribute_ids: ["conversation_id", "conversation_started_at"], - start_time: 1717490000, - end_time: 1717510000 +await client.preview.articles.publishArticleDraft({ + id: 1, + body: { + locales: ["en", "fr"] + } }); ``` @@ -12050,7 +12212,7 @@ await client.unstable.export.enqueueANewReportingDataExportJob({
-**request:** `Intercom.unstable.PostExportReportingDataEnqueueRequest` +**request:** `Intercom.preview.PublishArticleDraftRequest`
@@ -12058,7 +12220,7 @@ await client.unstable.export.enqueueANewReportingDataExportJob({
-**requestOptions:** `ExportClient.RequestOptions` +**requestOptions:** `ArticlesClient.RequestOptions`
@@ -12070,10 +12232,30 @@ await client.unstable.export.enqueueANewReportingDataExportJob({
-
client.unstable.export.listAvailableDatasetsAndAttributes() -> Intercom.GetExportReportingDataGetDatasetsResponse +
client.preview.articles.listVersions({ ...params }) -> core.Page +
+
+ +#### 📝 Description + +
+
+
+Fetch the version history of an article by making a GET request to +`https://api.intercom.io/articles//versions`. Versions are +returned newest-first as a paginated list of metadata. Use +`GET /articles/{article_id}/versions/{id}` to retrieve a single version +with its full content. + +Requires the `read_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. +
+
+
+
+ #### 🔌 Usage
@@ -12083,7 +12265,29 @@ await client.unstable.export.enqueueANewReportingDataExportJob({
```typescript -await client.unstable.export.listAvailableDatasetsAndAttributes(); +const pageableResponse = await client.preview.articles.listVersions({ + article_id: 1, + page: 1, + per_page: 1, + locale: "en" +}); +for await (const item of pageableResponse) { + console.log(item); +} + +// Or you can manually iterate page-by-page +let page = await client.preview.articles.listVersions({ + article_id: 1, + page: 1, + per_page: 1, + locale: "en" +}); +while (page.hasNextPage()) { + page = page.getNextPage(); +} + +// You can also access the underlying response +const response = page.response; ```
@@ -12099,7 +12303,15 @@ await client.unstable.export.listAvailableDatasetsAndAttributes();
-**requestOptions:** `ExportClient.RequestOptions` +**request:** `Intercom.preview.ListArticleVersionsRequest` + +
+
+ +
+
+ +**requestOptions:** `ArticlesClient.RequestOptions`
@@ -12111,8 +12323,7 @@ await client.unstable.export.listAvailableDatasetsAndAttributes();
-## Help Center -
client.unstable.helpCenter.listAllCollections() -> Intercom.CollectionList +
client.preview.articles.findVersion({ ...params }) -> Intercom.ArticleVersion
@@ -12124,9 +12335,12 @@ await client.unstable.export.listAvailableDatasetsAndAttributes();
-You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. +Fetch a single prior version of an article, including its body content, +by making a GET request to +`https://api.intercom.io/articles//versions/`. Returns +the version's full content; the live article remains untouched. -Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first. +Requires the `read_articles_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -12141,7 +12355,11 @@ Collections will be returned in descending order on the `updated_at` attribute.
```typescript -await client.unstable.helpCenter.listAllCollections(); +await client.preview.articles.findVersion({ + article_id: 1, + id: "301", + locale: "en" +}); ```
@@ -12157,7 +12375,15 @@ await client.unstable.helpCenter.listAllCollections();
-**requestOptions:** `HelpCenterClient.RequestOptions` +**request:** `Intercom.preview.FindArticleVersionRequest` + +
+
+ +
+
+ +**requestOptions:** `ArticlesClient.RequestOptions`
@@ -12169,7 +12395,7 @@ await client.unstable.helpCenter.listAllCollections();
-
client.unstable.helpCenter.createCollection({ ...params }) -> Intercom.Collection +
client.preview.articles.attachTagToArticle({ ...params }) -> Intercom.Tag
@@ -12181,7 +12407,13 @@ await client.unstable.helpCenter.listAllCollections();
-You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` +Apply an existing tag to an article. Returns the tag that was applied. + +The tag must already exist in the workspace (create tags with the Tags API), +and the authenticating teammate must have the `manage_knowledge_base_content` +permission. + +Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -12196,8 +12428,9 @@ You can create a new collection by making a POST request to `https://api.interco
```typescript -await client.unstable.helpCenter.createCollection({ - name: "Thanks for everything" +await client.preview.articles.attachTagToArticle({ + article_id: 1, + id: "7522907" }); ``` @@ -12214,7 +12447,7 @@ await client.unstable.helpCenter.createCollection({
-**request:** `Intercom.unstable.CreateCollectionRequest` +**request:** `Intercom.preview.AttachTagToArticleRequest`
@@ -12222,7 +12455,7 @@ await client.unstable.helpCenter.createCollection({
-**requestOptions:** `HelpCenterClient.RequestOptions` +**requestOptions:** `ArticlesClient.RequestOptions`
@@ -12234,7 +12467,7 @@ await client.unstable.helpCenter.createCollection({
-
client.unstable.helpCenter.retrieveCollection({ ...params }) -> Intercom.Collection +
client.preview.articles.detachTagFromArticle({ ...params }) -> Intercom.Tag
@@ -12246,7 +12479,13 @@ await client.unstable.helpCenter.createCollection({
-You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. +Remove a tag from an article. Returns the tag that was removed, with null +`applied_at` and `applied_by`. + +The authenticating teammate must have the `manage_knowledge_base_content` +permission. + +Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -12261,8 +12500,9 @@ You can fetch the details of a single collection by making a GET request to `htt
```typescript -await client.unstable.helpCenter.retrieveCollection({ - id: 1 +await client.preview.articles.detachTagFromArticle({ + article_id: 1, + id: "7522907" }); ``` @@ -12279,7 +12519,7 @@ await client.unstable.helpCenter.retrieveCollection({
-**request:** `Intercom.unstable.RetrieveCollectionRequest` +**request:** `Intercom.preview.DetachTagFromArticleRequest`
@@ -12287,7 +12527,7 @@ await client.unstable.helpCenter.retrieveCollection({
-**requestOptions:** `HelpCenterClient.RequestOptions` +**requestOptions:** `ArticlesClient.RequestOptions`
@@ -12299,7 +12539,7 @@ await client.unstable.helpCenter.retrieveCollection({
-
client.unstable.helpCenter.updateCollection({ ...params }) -> Intercom.Collection +
client.preview.articles.searchArticles({ ...params }) -> Intercom.ArticleSearchResponse
@@ -12311,7 +12551,7 @@ await client.unstable.helpCenter.retrieveCollection({
-You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. +You can search for articles by making a GET request to `https://api.intercom.io/articles/search`.
@@ -12326,9 +12566,11 @@ You can update the details of a single collection by making a PUT request to `ht
```typescript -await client.unstable.helpCenter.updateCollection({ - id: 1, - name: "Update collection name" +await client.preview.articles.searchArticles({ + phrase: "Getting started", + state: "published", + help_center_id: 1, + highlight: true }); ``` @@ -12345,7 +12587,7 @@ await client.unstable.helpCenter.updateCollection({
-**request:** `Intercom.unstable.UpdateCollectionRequest` +**request:** `Intercom.preview.SearchArticlesRequest`
@@ -12353,7 +12595,7 @@ await client.unstable.helpCenter.updateCollection({
-**requestOptions:** `HelpCenterClient.RequestOptions` +**requestOptions:** `ArticlesClient.RequestOptions`
@@ -12365,7 +12607,8 @@ await client.unstable.helpCenter.updateCollection({
-
client.unstable.helpCenter.deleteCollection({ ...params }) -> Intercom.DeletedCollectionObject +## Away Status Reasons +
client.preview.awayStatusReasons.listAwayStatusReasons() -> Intercom.AwayStatusReasonList
@@ -12377,7 +12620,7 @@ await client.unstable.helpCenter.updateCollection({
-You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. +Returns a list of all away status reasons configured for the workspace, including deleted ones.
@@ -12392,9 +12635,7 @@ You can delete a single collection by making a DELETE request to `https://api.in
```typescript -await client.unstable.helpCenter.deleteCollection({ - id: 1 -}); +await client.preview.awayStatusReasons.listAwayStatusReasons(); ```
@@ -12410,15 +12651,7 @@ await client.unstable.helpCenter.deleteCollection({
-**request:** `Intercom.unstable.DeleteCollectionRequest` - -
-
- -
-
- -**requestOptions:** `HelpCenterClient.RequestOptions` +**requestOptions:** `AwayStatusReasonsClient.RequestOptions`
@@ -12430,7 +12663,8 @@ await client.unstable.helpCenter.deleteCollection({
-
client.unstable.helpCenter.retrieveHelpCenter({ ...params }) -> Intercom.HelpCenter +## Audiences +
client.preview.audiences.listAudiences({ ...params }) -> Intercom.AudienceList
@@ -12442,7 +12676,7 @@ await client.unstable.helpCenter.deleteCollection({
-You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. +You can fetch a list of all audiences for the workspace.
@@ -12457,8 +12691,9 @@ You can fetch the details of a single Help Center by making a GET request to `ht
```typescript -await client.unstable.helpCenter.retrieveHelpCenter({ - id: 1 +await client.preview.audiences.listAudiences({ + page: 1, + per_page: 1 }); ``` @@ -12475,7 +12710,7 @@ await client.unstable.helpCenter.retrieveHelpCenter({
-**request:** `Intercom.unstable.RetrieveHelpCenterRequest` +**request:** `Intercom.preview.ListAudiencesRequest`
@@ -12483,7 +12718,7 @@ await client.unstable.helpCenter.retrieveHelpCenter({
-**requestOptions:** `HelpCenterClient.RequestOptions` +**requestOptions:** `AudiencesClient.RequestOptions`
@@ -12495,7 +12730,7 @@ await client.unstable.helpCenter.retrieveHelpCenter({
-
client.unstable.helpCenter.listHelpCenters() -> Intercom.HelpCenterList +
client.preview.audiences.createAudience({ ...params }) -> Intercom.Audience
@@ -12507,7 +12742,7 @@ await client.unstable.helpCenter.retrieveHelpCenter({
-You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. +You can create a new audience by making a POST request to `https://api.intercom.io/audiences`.
@@ -12522,7 +12757,21 @@ You can list all Help Centers by making a GET request to `https://api.intercom.i
```typescript -await client.unstable.helpCenter.listHelpCenters(); +await client.preview.audiences.createAudience({ + name: "VIP Customers", + predicates: [{ + attribute: "company.name", + type: "string", + comparison: "contains", + value: "Acme" + }], + role_predicates: [{ + attribute: "role", + type: "role", + comparison: "eq", + value: "user" + }] +}); ```
@@ -12538,7 +12787,15 @@ await client.unstable.helpCenter.listHelpCenters();
-**requestOptions:** `HelpCenterClient.RequestOptions` +**request:** `Intercom.preview.CreateAudienceRequest` + +
+
+ +
+
+ +**requestOptions:** `AudiencesClient.RequestOptions`
@@ -12550,8 +12807,7 @@ await client.unstable.helpCenter.listHelpCenters();
-## Internal Articles -
client.unstable.internalArticles.listInternalArticles() -> Intercom.InternalArticleList +
client.preview.audiences.retrieveAudience({ ...params }) -> Intercom.Audience
@@ -12563,7 +12819,7 @@ await client.unstable.helpCenter.listHelpCenters();
-You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. +You can fetch the details of a single audience by making a GET request to `https://api.intercom.io/audiences/{id}`.
@@ -12578,7 +12834,9 @@ You can fetch a list of all internal articles by making a GET request to `https:
```typescript -await client.unstable.internalArticles.listInternalArticles(); +await client.preview.audiences.retrieveAudience({ + id: "123" +}); ```
@@ -12594,7 +12852,15 @@ await client.unstable.internalArticles.listInternalArticles();
-**requestOptions:** `InternalArticlesClient.RequestOptions` +**request:** `Intercom.preview.RetrieveAudienceRequest` + +
+
+ +
+
+ +**requestOptions:** `AudiencesClient.RequestOptions`
@@ -12606,7 +12872,7 @@ await client.unstable.internalArticles.listInternalArticles();
-
client.unstable.internalArticles.createInternalArticle({ ...params }) -> Intercom.InternalArticle +
client.preview.audiences.updateAudience({ ...params }) -> Intercom.Audience
@@ -12618,7 +12884,7 @@ await client.unstable.internalArticles.listInternalArticles();
-You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. +You can update the details of a single audience by making a PUT request to `https://api.intercom.io/audiences/{id}`.
@@ -12633,11 +12899,15 @@ You can create a new internal article by making a POST request to `https://api.i
```typescript -await client.unstable.internalArticles.createInternalArticle({ - title: "Thanks for everything", - body: "Body of the Article", - author_id: 991266252, - owner_id: 991266252 +await client.preview.audiences.updateAudience({ + id: "123", + name: "Enterprise Accounts", + predicates: [{ + attribute: "custom_attributes.plan", + type: "string", + comparison: "eq", + value: "enterprise" + }] }); ``` @@ -12654,7 +12924,7 @@ await client.unstable.internalArticles.createInternalArticle({
-**request:** `Intercom.CreateInternalArticleRequest` +**request:** `Intercom.preview.UpdateAudienceRequest`
@@ -12662,7 +12932,7 @@ await client.unstable.internalArticles.createInternalArticle({
-**requestOptions:** `InternalArticlesClient.RequestOptions` +**requestOptions:** `AudiencesClient.RequestOptions`
@@ -12674,7 +12944,7 @@ await client.unstable.internalArticles.createInternalArticle({
-
client.unstable.internalArticles.retrieveInternalArticle({ ...params }) -> Intercom.InternalArticle +
client.preview.audiences.deleteAudience({ ...params }) -> void
@@ -12686,7 +12956,7 @@ await client.unstable.internalArticles.createInternalArticle({
-You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. +You can delete a single audience by making a DELETE request to `https://api.intercom.io/audiences/{id}`.
@@ -12701,8 +12971,8 @@ You can fetch the details of a single internal article by making a GET request t
```typescript -await client.unstable.internalArticles.retrieveInternalArticle({ - id: 1 +await client.preview.audiences.deleteAudience({ + id: "123" }); ``` @@ -12719,7 +12989,7 @@ await client.unstable.internalArticles.retrieveInternalArticle({
-**request:** `Intercom.unstable.RetrieveInternalArticleRequest` +**request:** `Intercom.preview.DeleteAudienceRequest`
@@ -12727,7 +12997,7 @@ await client.unstable.internalArticles.retrieveInternalArticle({
-**requestOptions:** `InternalArticlesClient.RequestOptions` +**requestOptions:** `AudiencesClient.RequestOptions`
@@ -12739,7 +13009,8 @@ await client.unstable.internalArticles.retrieveInternalArticle({
-
client.unstable.internalArticles.updateInternalArticle({ ...params }) -> Intercom.InternalArticle +## Office Hours +
client.preview.officeHours.listOfficeHoursSchedules() -> Intercom.OfficeHoursScheduleList
@@ -12751,7 +13022,7 @@ await client.unstable.internalArticles.retrieveInternalArticle({
-You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. +You can fetch a list of all office hours schedules for the workspace.
@@ -12766,11 +13037,7 @@ You can update the details of a single internal article by making a PUT request
```typescript -await client.unstable.internalArticles.updateInternalArticle({ - id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

" -}); +await client.preview.officeHours.listOfficeHoursSchedules(); ```
@@ -12786,15 +13053,7 @@ await client.unstable.internalArticles.updateInternalArticle({
-**request:** `Intercom.unstable.UpdateInternalArticleRequestBody` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -12806,7 +13065,7 @@ await client.unstable.internalArticles.updateInternalArticle({
-
client.unstable.internalArticles.deleteInternalArticle({ ...params }) -> Intercom.DeletedInternalArticleObject +
client.preview.officeHours.createOfficeHoursSchedule({ ...params }) -> Intercom.OfficeHoursSchedule
@@ -12818,7 +13077,7 @@ await client.unstable.internalArticles.updateInternalArticle({
-You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. +You can create a new office hours schedule for the workspace.
@@ -12833,8 +13092,13 @@ You can delete a single internal article by making a DELETE request to `https://
```typescript -await client.unstable.internalArticles.deleteInternalArticle({ - id: 1 +await client.preview.officeHours.createOfficeHoursSchedule({ + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [{ + start_minute: 540, + end_minute: 1020 + }] }); ``` @@ -12851,7 +13115,7 @@ await client.unstable.internalArticles.deleteInternalArticle({
-**request:** `Intercom.unstable.DeleteInternalArticleRequest` +**request:** `Intercom.preview.CreateOfficeHoursScheduleRequest`
@@ -12859,7 +13123,7 @@ await client.unstable.internalArticles.deleteInternalArticle({
-**requestOptions:** `InternalArticlesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -12871,7 +13135,7 @@ await client.unstable.internalArticles.deleteInternalArticle({
-
client.unstable.internalArticles.searchInternalArticles({ ...params }) -> Intercom.InternalArticleSearchResponse +
client.preview.officeHours.getOfficeHoursSchedule({ ...params }) -> Intercom.OfficeHoursSchedule
@@ -12883,7 +13147,7 @@ await client.unstable.internalArticles.deleteInternalArticle({
-You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. +You can fetch the details of a single office hours schedule.
@@ -12898,8 +13162,8 @@ You can search for internal articles by making a GET request to `https://api.int
```typescript -await client.unstable.internalArticles.searchInternalArticles({ - folder_id: "folder_id" +await client.preview.officeHours.getOfficeHoursSchedule({ + id: "123" }); ``` @@ -12916,7 +13180,7 @@ await client.unstable.internalArticles.searchInternalArticles({
-**request:** `Intercom.unstable.SearchInternalArticlesRequest` +**request:** `Intercom.preview.GetOfficeHoursScheduleRequest`
@@ -12924,7 +13188,7 @@ await client.unstable.internalArticles.searchInternalArticles({
-**requestOptions:** `InternalArticlesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -12936,8 +13200,7 @@ await client.unstable.internalArticles.searchInternalArticles({
-## Companies -
client.unstable.companies.retrieveCompany({ ...params }) -> Intercom.CompanyList +
client.preview.officeHours.updateOfficeHoursSchedule({ ...params }) -> Intercom.OfficeHoursSchedule
@@ -12949,17 +13212,7 @@ await client.unstable.internalArticles.searchInternalArticles({
-You can fetch a single company by passing in `company_id` or `name`. - - `https://api.intercom.io/companies?name={name}` - - `https://api.intercom.io/companies?company_id={company_id}` - -You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. - - `https://api.intercom.io/companies?tag_id={tag_id}` - - `https://api.intercom.io/companies?segment_id={segment_id}` +You can update an existing office hours schedule.
@@ -12974,13 +13227,13 @@ You can fetch all companies and filter by `segment_id` or `tag_id` as a query pa
```typescript -await client.unstable.companies.retrieveCompany({ - name: "my company", - company_id: "12345", - tag_id: "678910", - segment_id: "98765", - page: 1, - per_page: 1 +await client.preview.officeHours.updateOfficeHoursSchedule({ + id: "123", + name: "Extended Support Hours", + time_intervals: [{ + start_minute: 480, + end_minute: 1080 + }] }); ``` @@ -12997,7 +13250,7 @@ await client.unstable.companies.retrieveCompany({
-**request:** `Intercom.unstable.RetrieveCompanyRequest` +**request:** `Intercom.preview.UpdateOfficeHoursScheduleRequest`
@@ -13005,7 +13258,7 @@ await client.unstable.companies.retrieveCompany({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -13017,7 +13270,7 @@ await client.unstable.companies.retrieveCompany({
-
client.unstable.companies.createOrUpdateCompany({ ...params }) -> Intercom.Company +
client.preview.officeHours.deleteOfficeHoursSchedule({ ...params }) -> Intercom.DeleteOfficeHoursScheduleResponse
@@ -13029,15 +13282,7 @@ await client.unstable.companies.retrieveCompany({
-You can create or update a company. - -Companies will be only visible in Intercom when there is at least one associated user. - -Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. - -{% admonition type="warning" name="Using `company_id`" %} - You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. -{% /admonition %} +You can delete a single office hours schedule.
@@ -13052,8 +13297,8 @@ Companies are looked up via `company_id` in a `POST` request, if not found via `
```typescript -await client.unstable.companies.createOrUpdateCompany({ - "key": "value" +await client.preview.officeHours.deleteOfficeHoursSchedule({ + id: "123" }); ``` @@ -13070,7 +13315,7 @@ await client.unstable.companies.createOrUpdateCompany({
-**request:** `unknown` +**request:** `Intercom.preview.DeleteOfficeHoursScheduleRequest`
@@ -13078,7 +13323,7 @@ await client.unstable.companies.createOrUpdateCompany({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -13090,7 +13335,7 @@ await client.unstable.companies.createOrUpdateCompany({
-
client.unstable.companies.retrieveACompanyById({ ...params }) -> Intercom.Company +
client.preview.officeHours.listOfficeHoursExceptions({ ...params }) -> Intercom.OfficeHoursExceptionList
@@ -13102,7 +13347,7 @@ await client.unstable.companies.createOrUpdateCompany({
-You can fetch a single company. +You can fetch a list of all exceptions for an office hours schedule.
@@ -13117,8 +13362,8 @@ You can fetch a single company.
```typescript -await client.unstable.companies.retrieveACompanyById({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" +await client.preview.officeHours.listOfficeHoursExceptions({ + office_hours_schedule_id: "123" }); ``` @@ -13135,7 +13380,7 @@ await client.unstable.companies.retrieveACompanyById({
-**request:** `Intercom.unstable.RetrieveACompanyByIdRequest` +**request:** `Intercom.preview.ListOfficeHoursExceptionsRequest`
@@ -13143,7 +13388,7 @@ await client.unstable.companies.retrieveACompanyById({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -13155,7 +13400,7 @@ await client.unstable.companies.retrieveACompanyById({
-
client.unstable.companies.updateCompany({ ...params }) -> Intercom.Company +
client.preview.officeHours.createOfficeHoursException({ ...params }) -> Intercom.OfficeHoursException
@@ -13167,11 +13412,7 @@ await client.unstable.companies.retrieveACompanyById({
-You can update a single company using the Intercom provisioned `id`. - -{% admonition type="warning" name="Using `company_id`" %} - When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. -{% /admonition %} +You can create an exception for an office hours schedule. Use `closed` to mark the day closed (omit `time_intervals`) or `custom_hours` to supply replacement intervals.
@@ -13186,8 +13427,12 @@ You can update a single company using the Intercom provisioned `id`.
```typescript -await client.unstable.companies.updateCompany({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" +await client.preview.officeHours.createOfficeHoursException({ + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + recurring_annually: true }); ``` @@ -13204,7 +13449,7 @@ await client.unstable.companies.updateCompany({
-**request:** `Intercom.unstable.UpdateCompanyRequest` +**request:** `Intercom.preview.CreateOfficeHoursExceptionRequest`
@@ -13212,7 +13457,7 @@ await client.unstable.companies.updateCompany({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -13224,7 +13469,7 @@ await client.unstable.companies.updateCompany({
-
client.unstable.companies.deleteCompany({ ...params }) -> Intercom.DeletedCompanyObject +
client.preview.officeHours.getOfficeHoursException({ ...params }) -> Intercom.OfficeHoursException
@@ -13236,7 +13481,7 @@ await client.unstable.companies.updateCompany({
-You can delete a single company. +You can fetch the details of a single office hours exception.
@@ -13251,8 +13496,9 @@ You can delete a single company.
```typescript -await client.unstable.companies.deleteCompany({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" +await client.preview.officeHours.getOfficeHoursException({ + office_hours_schedule_id: "123", + id: "456" }); ``` @@ -13269,7 +13515,7 @@ await client.unstable.companies.deleteCompany({
-**request:** `Intercom.unstable.DeleteCompanyRequest` +**request:** `Intercom.preview.GetOfficeHoursExceptionRequest`
@@ -13277,7 +13523,7 @@ await client.unstable.companies.deleteCompany({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -13289,7 +13535,7 @@ await client.unstable.companies.deleteCompany({
-
client.unstable.companies.listAttachedContacts({ ...params }) -> Intercom.CompanyAttachedContacts +
client.preview.officeHours.updateOfficeHoursException({ ...params }) -> Intercom.OfficeHoursException
@@ -13301,7 +13547,7 @@ await client.unstable.companies.deleteCompany({
-You can fetch a list of all contacts that belong to a company. +You can update an existing office hours exception.
@@ -13316,8 +13562,16 @@ You can fetch a list of all contacts that belong to a company.
```typescript -await client.unstable.companies.listAttachedContacts({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" +await client.preview.officeHours.updateOfficeHoursException({ + office_hours_schedule_id: "123", + id: "456", + exception_type: "custom_hours", + name: "Christmas Day (reduced hours)", + time_intervals: [{ + start_minute: 540, + end_minute: 780 + }], + recurring_annually: true }); ``` @@ -13334,7 +13588,7 @@ await client.unstable.companies.listAttachedContacts({
-**request:** `Intercom.unstable.ListAttachedContactsRequest` +**request:** `Intercom.preview.UpdateOfficeHoursExceptionRequest`
@@ -13342,7 +13596,7 @@ await client.unstable.companies.listAttachedContacts({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -13354,7 +13608,7 @@ await client.unstable.companies.listAttachedContacts({
-
client.unstable.companies.listAttachedSegmentsForCompanies({ ...params }) -> Intercom.CompanyAttachedSegments +
client.preview.officeHours.deleteOfficeHoursException({ ...params }) -> Intercom.DeleteOfficeHoursExceptionResponse
@@ -13366,7 +13620,7 @@ await client.unstable.companies.listAttachedContacts({
-You can fetch a list of all segments that belong to a company. +You can delete a single office hours exception.
@@ -13381,8 +13635,9 @@ You can fetch a list of all segments that belong to a company.
```typescript -await client.unstable.companies.listAttachedSegmentsForCompanies({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" +await client.preview.officeHours.deleteOfficeHoursException({ + office_hours_schedule_id: "123", + id: "456" }); ``` @@ -13399,7 +13654,7 @@ await client.unstable.companies.listAttachedSegmentsForCompanies({
-**request:** `Intercom.unstable.ListAttachedSegmentsForCompaniesRequest` +**request:** `Intercom.preview.DeleteOfficeHoursExceptionRequest`
@@ -13407,7 +13662,7 @@ await client.unstable.companies.listAttachedSegmentsForCompanies({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `OfficeHoursClient.RequestOptions`
@@ -13419,7 +13674,8 @@ await client.unstable.companies.listAttachedSegmentsForCompanies({
-
client.unstable.companies.listAllCompanies({ ...params }) -> Intercom.CompanyList +## Preview ReportingDataExport +
client.preview.reportingDataExport.enqueueANewReportingDataExportJob({ ...params }) -> Intercom.PostExportReportingDataEnqueueResponse
@@ -13431,15 +13687,7 @@ await client.unstable.companies.listAttachedSegmentsForCompanies({
-You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. - -Note that the API does not include companies who have no associated users in list responses. - -When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). -{% admonition type="warning" name="Pagination" %} - You can use pagination to limit the number of results returned. The default is `20` results per page. - See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. -{% /admonition %} +For the **conversation** dataset, from the Preview version this export returns all conversations, including those that never received a user reply. Earlier versions return only conversations that received at least one user reply. Other datasets are unaffected.
@@ -13454,10 +13702,11 @@ When using the Companies endpoint and the pages object to iterate through the re
```typescript -await client.unstable.companies.listAllCompanies({ - page: 1, - per_page: 1, - order: "desc" +await client.preview.reportingDataExport.enqueueANewReportingDataExportJob({ + dataset_id: "conversation", + attribute_ids: ["conversation_id", "conversation_started_at"], + start_time: 1717490000, + end_time: 1717510000 }); ``` @@ -13474,7 +13723,7 @@ await client.unstable.companies.listAllCompanies({
-**request:** `Intercom.unstable.ListAllCompaniesRequest` +**request:** `Intercom.preview.PostExportReportingDataEnqueueRequest`
@@ -13482,7 +13731,7 @@ await client.unstable.companies.listAllCompanies({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `ReportingDataExportClient.RequestOptions`
@@ -13494,38 +13743,10 @@ await client.unstable.companies.listAllCompanies({
-
client.unstable.companies.scrollOverAllCompanies({ ...params }) -> Intercom.CompanyScroll | undefined -
-
- -#### 📝 Description - -
-
- +
client.preview.reportingDataExport.listAvailableDatasetsAndAttributes() -> Intercom.GetExportReportingDataGetDatasetsResponse
- The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. - -- Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. -- If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail -- If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire - -{% admonition type="info" name="Scroll Parameter" %} - You can get the first page of companies by simply sending a GET request to the scroll endpoint. - For subsequent requests you will need to use the scroll parameter from the response. -{% /admonition %} -{% admonition type="danger" name="Scroll network timeouts" %} - Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: - "Request failed due to an internal network error. Please restart the scroll operation." - If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. -{% /admonition %} -
-
-
-
- #### 🔌 Usage
@@ -13535,9 +13756,7 @@ await client.unstable.companies.listAllCompanies({
```typescript -await client.unstable.companies.scrollOverAllCompanies({ - scroll_param: "scroll_param" -}); +await client.preview.reportingDataExport.listAvailableDatasetsAndAttributes(); ```
@@ -13553,15 +13772,7 @@ await client.unstable.companies.scrollOverAllCompanies({
-**request:** `Intercom.unstable.ScrollOverAllCompaniesRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `ReportingDataExportClient.RequestOptions`
@@ -13573,7 +13784,8 @@ await client.unstable.companies.scrollOverAllCompanies({
-
client.unstable.companies.attachContactToACompany({ ...params }) -> Intercom.Company +## Help Center +
client.preview.helpCenter.listHelpCenterRedirects({ ...params }) -> Intercom.HelpCenterRedirectList
@@ -13585,7 +13797,11 @@ await client.unstable.companies.scrollOverAllCompanies({
-You can attach a company to a single contact. +You can fetch a list of all URL redirects for a help center by making a GET request to `https://api.intercom.io/help_center/help_centers/{help_center_id}/redirects`. + +Redirects are returned in descending order on the `updated_at` attribute. + +Requires the `read_help_center_redirects_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -13600,9 +13816,10 @@ You can attach a company to a single contact.
```typescript -await client.unstable.companies.attachContactToACompany({ - id: "id", - company_id: "6762f09a1bb69f9f2193bb34" +await client.preview.helpCenter.listHelpCenterRedirects({ + help_center_id: "123", + page: 1, + per_page: 1 }); ``` @@ -13619,7 +13836,7 @@ await client.unstable.companies.attachContactToACompany({
-**request:** `Intercom.unstable.AttachContactToACompanyRequest` +**request:** `Intercom.preview.ListHelpCenterRedirectsRequest`
@@ -13627,7 +13844,7 @@ await client.unstable.companies.attachContactToACompany({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -13639,7 +13856,7 @@ await client.unstable.companies.attachContactToACompany({
-
client.unstable.companies.detachContactFromACompany({ ...params }) -> Intercom.Company +
client.preview.helpCenter.createHelpCenterRedirect({ ...params }) -> Intercom.HelpCenterRedirect
@@ -13651,7 +13868,9 @@ await client.unstable.companies.attachContactToACompany({
-You can detach a company from a single contact. +You can create a new URL redirect by making a POST request to `https://api.intercom.io/help_center/help_centers/{help_center_id}/redirects`. + +Requires the `read_write_help_center_redirects_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -13666,9 +13885,12 @@ You can detach a company from a single contact.
```typescript -await client.unstable.companies.detachContactFromACompany({ - contact_id: "58a430d35458202d41b1e65b", - id: "58a430d35458202d41b1e65b" +await client.preview.helpCenter.createHelpCenterRedirect({ + help_center_id: "123", + from_url: "http://help-center.test/lovelyhelpcenter/old-page", + locale: "en", + target_type: "article", + target_id: "11" }); ``` @@ -13685,7 +13907,7 @@ await client.unstable.companies.detachContactFromACompany({
-**request:** `Intercom.unstable.DetachContactFromACompanyRequest` +**request:** `Intercom.preview.CreateHelpCenterRedirectRequest`
@@ -13693,7 +13915,7 @@ await client.unstable.companies.detachContactFromACompany({
-**requestOptions:** `CompaniesClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -13705,8 +13927,7 @@ await client.unstable.companies.detachContactFromACompany({
-## Notes -
client.unstable.notes.listCompanyNotes({ ...params }) -> Intercom.NoteList +
client.preview.helpCenter.retrieveHelpCenterRedirect({ ...params }) -> Intercom.HelpCenterRedirect
@@ -13718,7 +13939,9 @@ await client.unstable.companies.detachContactFromACompany({
-You can fetch a list of notes that are associated to a company. +You can fetch the details of a single redirect by making a GET request to `https://api.intercom.io/help_center/help_centers/{help_center_id}/redirects/{id}`. + +Requires the `read_help_center_redirects_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -13733,8 +13956,9 @@ You can fetch a list of notes that are associated to a company.
```typescript -await client.unstable.notes.listCompanyNotes({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" +await client.preview.helpCenter.retrieveHelpCenterRedirect({ + help_center_id: "123", + id: "26" }); ``` @@ -13751,7 +13975,7 @@ await client.unstable.notes.listCompanyNotes({
-**request:** `Intercom.unstable.ListCompanyNotesRequest` +**request:** `Intercom.preview.RetrieveHelpCenterRedirectRequest`
@@ -13759,7 +13983,7 @@ await client.unstable.notes.listCompanyNotes({
-**requestOptions:** `NotesClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -13771,7 +13995,7 @@ await client.unstable.notes.listCompanyNotes({
-
client.unstable.notes.listNotes({ ...params }) -> Intercom.NoteList +
client.preview.helpCenter.deleteHelpCenterRedirect({ ...params }) -> Intercom.DeletedHelpCenterRedirectObject
@@ -13783,7 +14007,9 @@ await client.unstable.notes.listCompanyNotes({
-You can fetch a list of notes that are associated to a contact. +You can delete a single redirect by making a DELETE request to `https://api.intercom.io/help_center/help_centers/{help_center_id}/redirects/{id}`. + +Requires the `read_write_help_center_redirects_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -13798,8 +14024,9 @@ You can fetch a list of notes that are associated to a contact.
```typescript -await client.unstable.notes.listNotes({ - id: 1 +await client.preview.helpCenter.deleteHelpCenterRedirect({ + help_center_id: "123", + id: "26" }); ``` @@ -13816,7 +14043,7 @@ await client.unstable.notes.listNotes({
-**request:** `Intercom.unstable.ListNotesRequest` +**request:** `Intercom.preview.DeleteHelpCenterRedirectRequest`
@@ -13824,7 +14051,7 @@ await client.unstable.notes.listNotes({
-**requestOptions:** `NotesClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -13836,7 +14063,7 @@ await client.unstable.notes.listNotes({
-
client.unstable.notes.createNote({ ...params }) -> Intercom.Note +
client.preview.helpCenter.listAllCollections() -> Intercom.CollectionList
@@ -13848,7 +14075,9 @@ await client.unstable.notes.listNotes({
-You can add a note to a single contact. +You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. + +Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.
@@ -13863,12 +14092,7 @@ You can add a note to a single contact.
```typescript -await client.unstable.notes.createNote({ - id: 1, - body: "Hello", - contact_id: "6762f0ad1bb69f9f2193bb62", - admin_id: "123" -}); +await client.preview.helpCenter.listAllCollections(); ```
@@ -13884,15 +14108,7 @@ await client.unstable.notes.createNote({
-**request:** `Intercom.unstable.CreateNoteRequest` - -
-
- -
-
- -**requestOptions:** `NotesClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -13904,7 +14120,7 @@ await client.unstable.notes.createNote({
-
client.unstable.notes.retrieveNote({ ...params }) -> Intercom.Note +
client.preview.helpCenter.createCollection({ ...params }) -> Intercom.Collection
@@ -13916,7 +14132,7 @@ await client.unstable.notes.createNote({
-You can fetch the details of a single note. +You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.`
@@ -13931,8 +14147,8 @@ You can fetch the details of a single note.
```typescript -await client.unstable.notes.retrieveNote({ - id: 1 +await client.preview.helpCenter.createCollection({ + name: "Thanks for everything" }); ``` @@ -13949,7 +14165,7 @@ await client.unstable.notes.retrieveNote({
-**request:** `Intercom.unstable.RetrieveNoteRequest` +**request:** `Intercom.preview.CreateCollectionRequest`
@@ -13957,7 +14173,7 @@ await client.unstable.notes.retrieveNote({
-**requestOptions:** `NotesClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -13969,8 +14185,7 @@ await client.unstable.notes.retrieveNote({
-## Contacts -
client.unstable.contacts.listCompaniesForAContact({ ...params }) -> Intercom.ContactAttachedCompanies +
client.preview.helpCenter.retrieveCollection({ ...params }) -> Intercom.Collection
@@ -13982,7 +14197,7 @@ await client.unstable.notes.retrieveNote({
-You can fetch a list of companies that are associated to a contact. +You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`.
@@ -13997,8 +14212,8 @@ You can fetch a list of companies that are associated to a contact.
```typescript -await client.unstable.contacts.listCompaniesForAContact({ - id: "63a07ddf05a32042dffac965" +await client.preview.helpCenter.retrieveCollection({ + id: 1 }); ``` @@ -14015,7 +14230,7 @@ await client.unstable.contacts.listCompaniesForAContact({
-**request:** `Intercom.unstable.ListCompaniesForAContactRequest` +**request:** `Intercom.preview.RetrieveCollectionRequest`
@@ -14023,7 +14238,7 @@ await client.unstable.contacts.listCompaniesForAContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -14035,7 +14250,7 @@ await client.unstable.contacts.listCompaniesForAContact({
-
client.unstable.contacts.listSegmentsForAContact({ ...params }) -> Intercom.ContactSegments +
client.preview.helpCenter.updateCollection({ ...params }) -> Intercom.Collection
@@ -14047,7 +14262,7 @@ await client.unstable.contacts.listCompaniesForAContact({
-You can fetch a list of segments that are associated to a contact. +You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`.
@@ -14062,8 +14277,9 @@ You can fetch a list of segments that are associated to a contact.
```typescript -await client.unstable.contacts.listSegmentsForAContact({ - contact_id: "63a07ddf05a32042dffac965" +await client.preview.helpCenter.updateCollection({ + id: 1, + name: "Update collection name" }); ``` @@ -14080,7 +14296,7 @@ await client.unstable.contacts.listSegmentsForAContact({
-**request:** `Intercom.unstable.ListSegmentsForAContactRequest` +**request:** `Intercom.preview.UpdateCollectionRequest`
@@ -14088,7 +14304,7 @@ await client.unstable.contacts.listSegmentsForAContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -14100,7 +14316,7 @@ await client.unstable.contacts.listSegmentsForAContact({
-
client.unstable.contacts.listSubscriptionsForAContact({ ...params }) -> Intercom.SubscriptionTypeList +
client.preview.helpCenter.deleteCollection({ ...params }) -> Intercom.DeletedCollectionObject
@@ -14112,13 +14328,7 @@ await client.unstable.contacts.listSegmentsForAContact({
-You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. -This will return a list of Subscription Type objects that the contact is associated with. - -The data property will show a combined list of: - - 1.Opt-out subscription types that the user has opted-out from. - 2.Opt-in subscription types that the user has opted-in to receiving. +You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`.
@@ -14133,8 +14343,8 @@ The data property will show a combined list of:
```typescript -await client.unstable.contacts.listSubscriptionsForAContact({ - contact_id: "63a07ddf05a32042dffac965" +await client.preview.helpCenter.deleteCollection({ + id: 1 }); ``` @@ -14151,7 +14361,7 @@ await client.unstable.contacts.listSubscriptionsForAContact({
-**request:** `Intercom.unstable.ListSubscriptionsForAContactRequest` +**request:** `Intercom.preview.DeleteCollectionRequest`
@@ -14159,7 +14369,7 @@ await client.unstable.contacts.listSubscriptionsForAContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -14171,7 +14381,7 @@ await client.unstable.contacts.listSubscriptionsForAContact({
-
client.unstable.contacts.listTagsForAContact({ ...params }) -> Intercom.TagList +
client.preview.helpCenter.retrieveHelpCenter({ ...params }) -> Intercom.HelpCenter
@@ -14183,7 +14393,7 @@ await client.unstable.contacts.listSubscriptionsForAContact({
-You can fetch a list of all tags that are attached to a specific contact. +You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`.
@@ -14198,8 +14408,8 @@ You can fetch a list of all tags that are attached to a specific contact.
```typescript -await client.unstable.contacts.listTagsForAContact({ - contact_id: "63a07ddf05a32042dffac965" +await client.preview.helpCenter.retrieveHelpCenter({ + id: 1 }); ``` @@ -14216,7 +14426,7 @@ await client.unstable.contacts.listTagsForAContact({
-**request:** `Intercom.unstable.ListTagsForAContactRequest` +**request:** `Intercom.preview.RetrieveHelpCenterRequest`
@@ -14224,7 +14434,7 @@ await client.unstable.contacts.listTagsForAContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -14236,7 +14446,7 @@ await client.unstable.contacts.listTagsForAContact({
-
client.unstable.contacts.showContact({ ...params }) -> Intercom.ShowContactResponse +
client.preview.helpCenter.listHelpCenters() -> Intercom.HelpCenterList
@@ -14248,7 +14458,7 @@ await client.unstable.contacts.listTagsForAContact({
-You can fetch the details of a single contact. +You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`.
@@ -14263,9 +14473,7 @@ You can fetch the details of a single contact.
```typescript -await client.unstable.contacts.showContact({ - id: "63a07ddf05a32042dffac965" -}); +await client.preview.helpCenter.listHelpCenters(); ```
@@ -14281,15 +14489,7 @@ await client.unstable.contacts.showContact({
-**request:** `Intercom.unstable.ShowContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `HelpCenterClient.RequestOptions`
@@ -14301,7 +14501,8 @@ await client.unstable.contacts.showContact({
-
client.unstable.contacts.updateContact({ ...params }) -> Intercom.UpdateContactResponse +## Internal Articles +
client.preview.internalArticles.listInternalArticles() -> Intercom.InternalArticleList
@@ -14313,13 +14514,7 @@ await client.unstable.contacts.showContact({
-You can update an existing contact (ie. user or lead). - -{% admonition type="info" %} - This endpoint handles both **contact updates** and **custom object associations**. - - See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. -{% /admonition %} +You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`.
@@ -14334,11 +14529,7 @@ You can update an existing contact (ie. user or lead).
```typescript -await client.unstable.contacts.updateContact({ - id: "63a07ddf05a32042dffac965", - email: "joebloggs@intercom.io", - name: "joe bloggs" -}); +await client.preview.internalArticles.listInternalArticles(); ```
@@ -14354,15 +14545,7 @@ await client.unstable.contacts.updateContact({
-**request:** `Intercom.unstable.UpdateContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `InternalArticlesClient.RequestOptions`
@@ -14374,7 +14557,7 @@ await client.unstable.contacts.updateContact({
-
client.unstable.contacts.deleteContact({ ...params }) -> Intercom.ContactDeleted +
client.preview.internalArticles.createInternalArticle({ ...params }) -> Intercom.InternalArticle
@@ -14386,7 +14569,7 @@ await client.unstable.contacts.updateContact({
-You can delete a single contact. +You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`.
@@ -14401,8 +14584,12 @@ You can delete a single contact.
```typescript -await client.unstable.contacts.deleteContact({ - id: "id" +await client.preview.internalArticles.createInternalArticle({ + title: "Thanks for everything", + body: "Body of the Article", + author_id: 991266252, + owner_id: 991266252, + audience_ids: [1, 2] }); ``` @@ -14419,7 +14606,7 @@ await client.unstable.contacts.deleteContact({
-**request:** `Intercom.unstable.DeleteContactRequest` +**request:** `Intercom.CreateInternalArticleRequest`
@@ -14427,7 +14614,7 @@ await client.unstable.contacts.deleteContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `InternalArticlesClient.RequestOptions`
@@ -14439,7 +14626,7 @@ await client.unstable.contacts.deleteContact({
-
client.unstable.contacts.mergeContact({ ...params }) -> Intercom.MergeContactResponse +
client.preview.internalArticles.retrieveInternalArticle({ ...params }) -> Intercom.InternalArticle
@@ -14451,7 +14638,7 @@ await client.unstable.contacts.deleteContact({
-You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. +You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`.
@@ -14466,9 +14653,8 @@ You can merge a contact with a `role` of `lead` into a contact with a `role` of
```typescript -await client.unstable.contacts.mergeContact({ - from: "6762f0d51bb69f9f2193bb7f", - into: "6762f0d51bb69f9f2193bb80" +await client.preview.internalArticles.retrieveInternalArticle({ + id: 1 }); ``` @@ -14485,7 +14671,7 @@ await client.unstable.contacts.mergeContact({
-**request:** `Intercom.unstable.MergeContactsRequest` +**request:** `Intercom.preview.RetrieveInternalArticleRequest`
@@ -14493,7 +14679,7 @@ await client.unstable.contacts.mergeContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `InternalArticlesClient.RequestOptions`
@@ -14505,7 +14691,7 @@ await client.unstable.contacts.mergeContact({
-
client.unstable.contacts.searchContacts({ ...params }) -> Intercom.ContactList +
client.preview.internalArticles.updateInternalArticle({ ...params }) -> Intercom.InternalArticle
@@ -14517,106 +14703,7 @@ await client.unstable.contacts.mergeContact({
-You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. - -To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`. - -This will accept a query object in the body which will define your filters in order to search for contacts. - -{% admonition type="warning" name="Optimizing search queries" %} - Search queries can be complex, so optimizing them can help the performance of your search. - Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize - pagination to limit the number of results returned. The default is `50` results per page. - See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. -{% /admonition %} -### Contact Creation Delay - -If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. - -### Nesting & Limitations - -You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). -There are some limitations to the amount of multiple's there can be: -* There's a limit of max 2 nested filters -* There's a limit of max 15 filters for each AND or OR group - -### Searching for Timestamp Fields - -All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. -For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. -If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). -This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly. - -### Accepted Fields - -Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). - -| Field | Type | -| ---------------------------------- | ------------------------------ | -| id | String | -| role | String
Accepts user or lead | -| name | String | -| avatar | String | -| owner_id | Integer | -| email | String | -| email_domain | String | -| phone | String | -| formatted_phone | String | -| external_id | String | -| created_at | Date (UNIX Timestamp) | -| signed_up_at | Date (UNIX Timestamp) | -| updated_at | Date (UNIX Timestamp) | -| last_seen_at | Date (UNIX Timestamp) | -| last_contacted_at | Date (UNIX Timestamp) | -| last_replied_at | Date (UNIX Timestamp) | -| last_email_opened_at | Date (UNIX Timestamp) | -| last_email_clicked_at | Date (UNIX Timestamp) | -| language_override | String | -| browser | String | -| browser_language | String | -| os | String | -| location.country | String | -| location.region | String | -| location.city | String | -| unsubscribed_from_emails | Boolean | -| marked_email_as_spam | Boolean | -| has_hard_bounced | Boolean | -| ios_last_seen_at | Date (UNIX Timestamp) | -| ios_app_version | String | -| ios_device | String | -| ios_app_device | String | -| ios_os_version | String | -| ios_app_name | String | -| ios_sdk_version | String | -| android_last_seen_at | Date (UNIX Timestamp) | -| android_app_version | String | -| android_device | String | -| android_app_name | String | -| andoid_sdk_version | String | -| segment_id | String | -| tag_id | String | -| custom_attributes.{attribute_name} | String | - -### Accepted Operators - -{% admonition type="warning" name="Searching based on `created_at`" %} - You cannot use the `<=` or `>=` operators to search by `created_at`. -{% /admonition %} - -The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). - -| Operator | Valid Types | Description | -| :------- | :------------------------------- | :--------------------------------------------------------------- | -| = | All | Equals | -| != | All | Doesn't Equal | -| IN | All | In
Shortcut for `OR` queries
Values must be in Array | -| NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | -| > | Integer
Date (UNIX Timestamp) | Greater than | -| < | Integer
Date (UNIX Timestamp) | Lower than | -| ~ | String | Contains | -| !~ | String | Doesn't Contain | -| ^ | String | Starts With | -| $ | String | Ends With | +You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`.
@@ -14631,18 +14718,11 @@ The table below shows the operators you can use to define how you want to search
```typescript -await client.unstable.contacts.searchContacts({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] - }, - pagination: { - per_page: 5 - } +await client.preview.internalArticles.updateInternalArticle({ + id: 1, + title: "Christmas is here!", + body: "

New gifts in store for the jolly season

", + audience_ids: [1, 2] }); ``` @@ -14659,7 +14739,7 @@ await client.unstable.contacts.searchContacts({
-**request:** `Intercom.SearchRequest` +**request:** `Intercom.preview.UpdateInternalArticleRequestBody`
@@ -14667,7 +14747,7 @@ await client.unstable.contacts.searchContacts({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `InternalArticlesClient.RequestOptions`
@@ -14679,7 +14759,7 @@ await client.unstable.contacts.searchContacts({
-
client.unstable.contacts.listContacts() -> Intercom.ContactList +
client.preview.internalArticles.deleteInternalArticle({ ...params }) -> Intercom.DeletedInternalArticleObject
@@ -14691,11 +14771,7 @@ await client.unstable.contacts.searchContacts({
-You can fetch a list of all contacts (ie. users or leads) in your workspace. -{% admonition type="warning" name="Pagination" %} - You can use pagination to limit the number of results returned. The default is `50` results per page. - See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. -{% /admonition %} +You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`.
@@ -14710,7 +14786,9 @@ You can fetch a list of all contacts (ie. users or leads) in your workspace.
```typescript -await client.unstable.contacts.listContacts(); +await client.preview.internalArticles.deleteInternalArticle({ + id: 1 +}); ```
@@ -14726,7 +14804,15 @@ await client.unstable.contacts.listContacts();
-**requestOptions:** `ContactsClient.RequestOptions` +**request:** `Intercom.preview.DeleteInternalArticleRequest` + +
+
+ +
+
+ +**requestOptions:** `InternalArticlesClient.RequestOptions`
@@ -14738,7 +14824,7 @@ await client.unstable.contacts.listContacts();
-
client.unstable.contacts.createContact({ ...params }) -> Intercom.CreateContactResponse +
client.preview.internalArticles.attachTagToInternalArticle({ ...params }) -> Intercom.Tag
@@ -14750,7 +14836,13 @@ await client.unstable.contacts.listContacts();
-You can create a new contact (ie. user or lead). +Apply an existing tag to an internal article. Returns the tag that was applied. + +The tag must already exist in the workspace (create tags with the Tags API), +and the authenticating teammate must have the `manage_knowledge_base_content` +permission. + +Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -14765,8 +14857,9 @@ You can create a new contact (ie. user or lead).
```typescript -await client.unstable.contacts.createContact({ - "email": "joebloggs@intercom.io" +await client.preview.internalArticles.attachTagToInternalArticle({ + internal_article_id: 1, + id: "7522907" }); ``` @@ -14783,7 +14876,7 @@ await client.unstable.contacts.createContact({
-**request:** `Intercom.CreateContactRequestTwo` +**request:** `Intercom.preview.AttachTagToInternalArticleRequest`
@@ -14791,7 +14884,7 @@ await client.unstable.contacts.createContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `InternalArticlesClient.RequestOptions`
@@ -14803,7 +14896,7 @@ await client.unstable.contacts.createContact({
-
client.unstable.contacts.showContactByExternalId({ ...params }) -> Intercom.ShowContactByExternalIdResponse +
client.preview.internalArticles.detachTagFromInternalArticle({ ...params }) -> Intercom.Tag
@@ -14815,7 +14908,13 @@ await client.unstable.contacts.createContact({
-You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. +Remove a tag from an internal article. Returns the tag that was removed, with +null `applied_at` and `applied_by`. + +The authenticating teammate must have the `manage_knowledge_base_content` +permission. + +Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`.
@@ -14830,8 +14929,9 @@ You can fetch the details of a single contact by external ID. Note that this end
```typescript -await client.unstable.contacts.showContactByExternalId({ - external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27" +await client.preview.internalArticles.detachTagFromInternalArticle({ + internal_article_id: 1, + id: "7522907" }); ``` @@ -14848,7 +14948,7 @@ await client.unstable.contacts.showContactByExternalId({
-**request:** `Intercom.unstable.ShowContactByExternalIdRequest` +**request:** `Intercom.preview.DetachTagFromInternalArticleRequest`
@@ -14856,7 +14956,7 @@ await client.unstable.contacts.showContactByExternalId({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `InternalArticlesClient.RequestOptions`
@@ -14868,7 +14968,7 @@ await client.unstable.contacts.showContactByExternalId({
-
client.unstable.contacts.archiveContact({ ...params }) -> Intercom.ContactArchived +
client.preview.internalArticles.searchInternalArticles({ ...params }) -> Intercom.InternalArticleSearchResponse
@@ -14880,7 +14980,7 @@ await client.unstable.contacts.showContactByExternalId({
-You can archive a single contact. +You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`.
@@ -14895,8 +14995,8 @@ You can archive a single contact.
```typescript -await client.unstable.contacts.archiveContact({ - id: "63a07ddf05a32042dffac965" +await client.preview.internalArticles.searchInternalArticles({ + folder_id: 1 }); ``` @@ -14913,7 +15013,7 @@ await client.unstable.contacts.archiveContact({
-**request:** `Intercom.unstable.ArchiveContactRequest` +**request:** `Intercom.preview.SearchInternalArticlesRequest`
@@ -14921,7 +15021,7 @@ await client.unstable.contacts.archiveContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `InternalArticlesClient.RequestOptions`
@@ -14933,7 +15033,8 @@ await client.unstable.contacts.archiveContact({
-
client.unstable.contacts.unarchiveContact({ ...params }) -> Intercom.ContactUnarchived +## Preview Folders +
client.preview.folders.listFolders({ ...params }) -> Intercom.ListFoldersResponse
@@ -14945,7 +15046,7 @@ await client.unstable.contacts.archiveContact({
-You can unarchive a single contact. +You can fetch a list of all folders for organizing content by making a GET request to `https://api.intercom.io/folders`.
@@ -14960,8 +15061,10 @@ You can unarchive a single contact.
```typescript -await client.unstable.contacts.unarchiveContact({ - id: "63a07ddf05a32042dffac965" +await client.preview.folders.listFolders({ + page: 1, + per_page: 50, + parent_folder_id: 1 }); ``` @@ -14978,7 +15081,7 @@ await client.unstable.contacts.unarchiveContact({
-**request:** `Intercom.unstable.UnarchiveContactRequest` +**request:** `Intercom.preview.ListFoldersRequest`
@@ -14986,7 +15089,7 @@ await client.unstable.contacts.unarchiveContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `FoldersClient.RequestOptions`
@@ -14998,7 +15101,7 @@ await client.unstable.contacts.unarchiveContact({
-
client.unstable.contacts.blockContact({ ...params }) -> Intercom.ContactBlocked +
client.preview.folders.createFolder({ ...params }) -> Intercom.Folder
@@ -15010,7 +15113,7 @@ await client.unstable.contacts.unarchiveContact({
-Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) +You can create a new folder for organizing content by making a POST request to `https://api.intercom.io/folders`.
@@ -15025,8 +15128,12 @@ Block a single contact.
**Note:** conversations of the contact will also be a
```typescript -await client.unstable.contacts.blockContact({ - id: "63a07ddf05a32042dffac965" +await client.preview.folders.createFolder({ + folder: { + name: "Product Documentation", + description: "Internal product docs", + emoji: "\uD83D\uDCDA" + } }); ``` @@ -15043,7 +15150,7 @@ await client.unstable.contacts.blockContact({
-**request:** `Intercom.unstable.BlockContactRequest` +**request:** `Intercom.preview.CreateFolderRequest`
@@ -15051,7 +15158,7 @@ await client.unstable.contacts.blockContact({
-**requestOptions:** `ContactsClient.RequestOptions` +**requestOptions:** `FoldersClient.RequestOptions`
@@ -15063,8 +15170,7 @@ await client.unstable.contacts.blockContact({
-## Subscription Types -
client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ ...params }) -> Intercom.SubscriptionType +
client.preview.folders.retrieveFolder({ ...params }) -> Intercom.Folder
@@ -15076,13 +15182,7 @@ await client.unstable.contacts.blockContact({
-You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: - - 1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type. - - 2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type. - -This will return a subscription type model for the subscription type that was added to the contact. +You can fetch the details of a single folder by making a GET request to `https://api.intercom.io/folders/`.
@@ -15097,10 +15197,8 @@ This will return a subscription type model for the subscription type that was ad
```typescript -await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "37846", - consent_type: "opt_in" +await client.preview.folders.retrieveFolder({ + id: 1 }); ``` @@ -15117,7 +15215,7 @@ await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({
-**request:** `Intercom.unstable.AttachSubscriptionTypeToContactRequest` +**request:** `Intercom.preview.RetrieveFolderRequest`
@@ -15125,7 +15223,7 @@ await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({
-**requestOptions:** `SubscriptionTypesClient.RequestOptions` +**requestOptions:** `FoldersClient.RequestOptions`
@@ -15137,7 +15235,7 @@ await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({
-
client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ ...params }) -> Intercom.SubscriptionType +
client.preview.folders.updateFolder({ ...params }) -> Intercom.Folder
@@ -15149,7 +15247,7 @@ await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({
-You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. +You can update a folder by making a PUT request to `https://api.intercom.io/folders/`.
@@ -15164,9 +15262,12 @@ You can remove a specific subscription from a contact. This will return a subscr
```typescript -await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "37846" +await client.preview.folders.updateFolder({ + id: 1, + folder: { + name: "Updated Product Documentation", + emoji: "\uD83D\uDCD6" + } }); ``` @@ -15183,7 +15284,7 @@ await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({
-**request:** `Intercom.unstable.DetachSubscriptionTypeToContactRequest` +**request:** `Intercom.preview.UpdateFolderRequest`
@@ -15191,7 +15292,7 @@ await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({
-**requestOptions:** `SubscriptionTypesClient.RequestOptions` +**requestOptions:** `FoldersClient.RequestOptions`
@@ -15203,7 +15304,7 @@ await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({
-
client.unstable.subscriptionTypes.listSubscriptionTypes() -> Intercom.SubscriptionTypeList +
client.preview.folders.deleteFolder({ ...params }) -> Intercom.DeletedFolderObject
@@ -15215,7 +15316,7 @@ await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({
-You can list all subscription types. A list of subscription type objects will be returned. +You can delete a folder (if it contains no content) by making a DELETE request to `https://api.intercom.io/folders/`.
@@ -15230,7 +15331,9 @@ You can list all subscription types. A list of subscription type objects will be
```typescript -await client.unstable.subscriptionTypes.listSubscriptionTypes(); +await client.preview.folders.deleteFolder({ + id: 1 +}); ```
@@ -15246,7 +15349,15 @@ await client.unstable.subscriptionTypes.listSubscriptionTypes();
-**requestOptions:** `SubscriptionTypesClient.RequestOptions` +**request:** `Intercom.preview.DeleteFolderRequest` + +
+
+ +
+
+ +**requestOptions:** `FoldersClient.RequestOptions`
@@ -15258,8 +15369,8 @@ await client.unstable.subscriptionTypes.listSubscriptionTypes();
-## Tags -
client.unstable.tags.attachTagToContact({ ...params }) -> Intercom.Tag +## Companies +
client.preview.companies.retrieveCompany({ ...params }) -> Intercom.CompanyList
@@ -15271,7 +15382,17 @@ await client.unstable.subscriptionTypes.listSubscriptionTypes();
-You can tag a specific contact. This will return a tag object for the tag that was added to the contact. +You can fetch a single company by passing in `company_id` or `name`. + + `https://api.intercom.io/companies?name={name}` + + `https://api.intercom.io/companies?company_id={company_id}` + +You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. + + `https://api.intercom.io/companies?tag_id={tag_id}` + + `https://api.intercom.io/companies?segment_id={segment_id}`
@@ -15286,9 +15407,13 @@ You can tag a specific contact. This will return a tag object for the tag that w
```typescript -await client.unstable.tags.attachTagToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "7522907" +await client.preview.companies.retrieveCompany({ + name: "my company", + company_id: "12345", + tag_id: "678910", + segment_id: "98765", + page: 1, + per_page: 1 }); ``` @@ -15305,7 +15430,7 @@ await client.unstable.tags.attachTagToContact({
-**request:** `Intercom.unstable.AttachTagToContactRequest` +**request:** `Intercom.preview.RetrieveCompanyRequest`
@@ -15313,7 +15438,7 @@ await client.unstable.tags.attachTagToContact({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15325,7 +15450,7 @@ await client.unstable.tags.attachTagToContact({
-
client.unstable.tags.detachTagFromContact({ ...params }) -> Intercom.Tag +
client.preview.companies.createOrUpdateCompany({ ...params }) -> Intercom.Company
@@ -15337,7 +15462,15 @@ await client.unstable.tags.attachTagToContact({
-You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. +You can create or update a company. + +Companies will be only visible in Intercom when there is at least one associated user. + +Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. + +{% admonition type="warning" name="Using `company_id`" %} + You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. +{% /admonition %}
@@ -15352,9 +15485,8 @@ You can remove tag from a specific contact. This will return a tag object for th
```typescript -await client.unstable.tags.detachTagFromContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "7522907" +await client.preview.companies.createOrUpdateCompany({ + "key": "value" }); ``` @@ -15371,7 +15503,7 @@ await client.unstable.tags.detachTagFromContact({
-**request:** `Intercom.unstable.DetachTagFromContactRequest` +**request:** `unknown`
@@ -15379,7 +15511,7 @@ await client.unstable.tags.detachTagFromContact({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15391,7 +15523,7 @@ await client.unstable.tags.detachTagFromContact({
-
client.unstable.tags.attachTagToConversation({ ...params }) -> Intercom.Tag +
client.preview.companies.retrieveACompanyById({ ...params }) -> Intercom.Company
@@ -15403,7 +15535,7 @@ await client.unstable.tags.detachTagFromContact({
-You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. +You can fetch a single company.
@@ -15418,10 +15550,8 @@ You can tag a specific conversation. This will return a tag object for the tag t
```typescript -await client.unstable.tags.attachTagToConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "780" +await client.preview.companies.retrieveACompanyById({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }); ``` @@ -15438,7 +15568,7 @@ await client.unstable.tags.attachTagToConversation({
-**request:** `Intercom.unstable.AttachTagToConversationRequest` +**request:** `Intercom.preview.RetrieveACompanyByIdRequest`
@@ -15446,7 +15576,7 @@ await client.unstable.tags.attachTagToConversation({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15458,7 +15588,7 @@ await client.unstable.tags.attachTagToConversation({
-
client.unstable.tags.detachTagFromConversation({ ...params }) -> Intercom.Tag +
client.preview.companies.updateCompany({ ...params }) -> Intercom.Company
@@ -15470,7 +15600,11 @@ await client.unstable.tags.attachTagToConversation({
-You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. +You can update a single company using the Intercom provisioned `id`. + +{% admonition type="warning" name="Using `company_id`" %} + When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. +{% /admonition %}
@@ -15485,10 +15619,8 @@ You can remove tag from a specific conversation. This will return a tag object f
```typescript -await client.unstable.tags.detachTagFromConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "123" +await client.preview.companies.updateCompany({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }); ``` @@ -15505,7 +15637,7 @@ await client.unstable.tags.detachTagFromConversation({
-**request:** `Intercom.unstable.DetachTagFromConversationRequest` +**request:** `Intercom.preview.UpdateCompanyRequest`
@@ -15513,7 +15645,7 @@ await client.unstable.tags.detachTagFromConversation({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15525,7 +15657,7 @@ await client.unstable.tags.detachTagFromConversation({
-
client.unstable.tags.listTags() -> Intercom.TagList +
client.preview.companies.deleteCompany({ ...params }) -> Intercom.DeletedCompanyObject
@@ -15537,8 +15669,15 @@ await client.unstable.tags.detachTagFromConversation({
-You can fetch a list of all tags for a given workspace. +Delete a single company. + +This endpoint does not permanently remove the company. It archives the company record and detaches any contacts attached to it; the contacts themselves are not deleted. A `company.deleted` webhook is sent once archival completes. +The endpoint returns `200` with `"deleted": true` as soon as the request is accepted — archival is processed asynchronously. + +{% admonition type="warning" %} +Third-party integrations that sync companies into Intercom (for example, Salesforce or Chargebee) will recreate any company deleted through this endpoint on their next sync. To prevent recreation, remove or filter the company at the source integration before deleting it via the API. +{% /admonition %}
@@ -15553,7 +15692,9 @@ You can fetch a list of all tags for a given workspace.
```typescript -await client.unstable.tags.listTags(); +await client.preview.companies.deleteCompany({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" +}); ```
@@ -15569,7 +15710,15 @@ await client.unstable.tags.listTags();
-**requestOptions:** `TagsClient.RequestOptions` +**request:** `Intercom.preview.DeleteCompanyRequest` + +
+
+ +
+
+ +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15581,7 +15730,7 @@ await client.unstable.tags.listTags();
-
client.unstable.tags.createTag({ ...params }) -> Intercom.Tag +
client.preview.companies.listAttachedContacts({ ...params }) -> Intercom.CompanyAttachedContacts
@@ -15593,19 +15742,7 @@ await client.unstable.tags.listTags();
-You can use this endpoint to perform the following operations: - - **1. Create a new tag:** You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below. - - **2. Update an existing tag:** You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below. - - **3. Tag Companies:** You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically. - - **4. Untag Companies:** You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below. - - **5. Tag Multiple Users:** You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below. - -Each operation will return a tag object. +You can fetch a list of all contacts that belong to a company.
@@ -15620,8 +15757,8 @@ Each operation will return a tag object.
```typescript -await client.unstable.tags.createTag({ - name: "test" +await client.preview.companies.listAttachedContacts({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }); ``` @@ -15638,7 +15775,7 @@ await client.unstable.tags.createTag({
-**request:** `Intercom.CreateTagRequestBody` +**request:** `Intercom.preview.ListAttachedContactsRequest`
@@ -15646,7 +15783,7 @@ await client.unstable.tags.createTag({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15658,7 +15795,7 @@ await client.unstable.tags.createTag({
-
client.unstable.tags.findTag({ ...params }) -> Intercom.Tag +
client.preview.companies.listAttachedSegmentsForCompanies({ ...params }) -> Intercom.CompanyAttachedSegments
@@ -15670,8 +15807,7 @@ await client.unstable.tags.createTag({
-You can fetch the details of tags that are on the workspace by their id. -This will return a tag object. +You can fetch a list of all segments that belong to a company.
@@ -15686,8 +15822,8 @@ This will return a tag object.
```typescript -await client.unstable.tags.findTag({ - id: "123" +await client.preview.companies.listAttachedSegmentsForCompanies({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }); ``` @@ -15704,7 +15840,7 @@ await client.unstable.tags.findTag({
-**request:** `Intercom.unstable.FindTagRequest` +**request:** `Intercom.preview.ListAttachedSegmentsForCompaniesRequest`
@@ -15712,7 +15848,7 @@ await client.unstable.tags.findTag({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15724,7 +15860,7 @@ await client.unstable.tags.findTag({
-
client.unstable.tags.deleteTag({ ...params }) -> void +
client.preview.companies.searchCompanies({ ...params }) -> Intercom.CompanyList
@@ -15736,7 +15872,66 @@ await client.unstable.tags.findTag({
-You can delete the details of tags that are on the workspace by passing in the id. +You can search for companies by the value of their attributes in order to fetch exactly the companies you want. + +To search for companies, send a `POST` request to `https://api.intercom.io/companies/search`, with a query object in the body defining your filters. + +Note that the API does not include companies who have no associated users in search results. + +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `15` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: +* There's a limit of max 2 nested filters +* There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed as part of the Companies Model are searchable. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). + +| Field | Type | +| ---------------------------------- | ------------------------------ | +| company_id | String | +| name | String | +| created_at | Date (UNIX Timestamp) | +| updated_at | Date (UNIX Timestamp) | +| remote_created_at | Date (UNIX Timestamp) | +| last_request_at | Date (UNIX Timestamp) | +| monthly_spend | Integer | +| session_count | Integer | +| user_count | Integer | +| tag_id | String | +| custom_attributes.{attribute_name} | String | + +The `plan.id` and `plan.name` fields are not searchable and return a `400` error with code `invalid_field`. + +### Accepted Operators + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). Searching by `tag_id` supports only the `=` and `!=` operators. The `IN` and `NIN` operators are not supported for Date fields. + +| Operator | Valid Types | Description | +| :------- | :------------------------------- | :--------------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All except Date and tag_id | In
Shortcut for `OR` queries
Values must be in Array | +| NIN | All except Date and tag_id | Not In
Shortcut for `OR !` queries
Values must be in Array | +| > | Integer
Date (UNIX Timestamp) | Greater than | +| < | Integer
Date (UNIX Timestamp) | Lower than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | + +### Sorting + +Pass an optional `sort` object with a `field` and an `order` (`ascending` or `descending`; defaults to `descending`) to order the results. An invalid `order` returns a `400` error with code `invalid_sort_order`. `tag_id` can be used as a filter but not as a sort field.
@@ -15751,8 +15946,22 @@ You can delete the details of tags that are on the workspace by passing in the i
```typescript -await client.unstable.tags.deleteTag({ - id: "123" +await client.preview.companies.searchCompanies({ + query: { + operator: "AND", + value: [{ + field: "name", + operator: "=", + value: "my-company" + }] + }, + pagination: { + per_page: 5 + }, + sort: { + field: "name", + order: "ascending" + } }); ``` @@ -15769,7 +15978,7 @@ await client.unstable.tags.deleteTag({
-**request:** `Intercom.unstable.DeleteTagRequest` +**request:** `Intercom.preview.CompanySearchRequest`
@@ -15777,7 +15986,7 @@ await client.unstable.tags.deleteTag({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15789,7 +15998,7 @@ await client.unstable.tags.deleteTag({
-
client.unstable.tags.attachTagToTicket({ ...params }) -> Intercom.Tag +
client.preview.companies.listAllCompanies({ ...params }) -> Intercom.CompanyList
@@ -15801,7 +16010,15 @@ await client.unstable.tags.deleteTag({
-You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. +You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. + +Note that the API does not include companies who have no associated users in list responses. + +When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %}
@@ -15816,10 +16033,10 @@ You can tag a specific ticket. This will return a tag object for the tag that wa
```typescript -await client.unstable.tags.attachTagToTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "780" +await client.preview.companies.listAllCompanies({ + page: 1, + per_page: 1, + order: "desc" }); ``` @@ -15836,7 +16053,7 @@ await client.unstable.tags.attachTagToTicket({
-**request:** `Intercom.unstable.AttachTagToTicketRequest` +**request:** `Intercom.preview.ListAllCompaniesRequest`
@@ -15844,7 +16061,7 @@ await client.unstable.tags.attachTagToTicket({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15856,7 +16073,7 @@ await client.unstable.tags.attachTagToTicket({
-
client.unstable.tags.detachTagFromTicket({ ...params }) -> Intercom.Tag +
client.preview.companies.scrollOverAllCompanies({ ...params }) -> Intercom.CompanyScroll | undefined
@@ -15868,7 +16085,21 @@ await client.unstable.tags.attachTagToTicket({
-You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + +- Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. +- If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail +- If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire + +{% admonition type="info" name="Scroll Parameter" %} + You can get the first page of companies by simply sending a GET request to the scroll endpoint. + For subsequent requests you will need to use the scroll parameter from the response. +{% /admonition %} +{% admonition type="danger" name="Scroll network timeouts" %} + Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + "Request failed due to an internal network error. Please restart the scroll operation." + If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. +{% /admonition %}
@@ -15883,10 +16114,8 @@ You can remove tag from a specific ticket. This will return a tag object for the
```typescript -await client.unstable.tags.detachTagFromTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "123" +await client.preview.companies.scrollOverAllCompanies({ + scroll_param: "scroll_param" }); ``` @@ -15903,7 +16132,7 @@ await client.unstable.tags.detachTagFromTicket({
-**request:** `Intercom.unstable.DetachTagFromTicketRequest` +**request:** `Intercom.preview.ScrollOverAllCompaniesRequest`
@@ -15911,7 +16140,7 @@ await client.unstable.tags.detachTagFromTicket({
-**requestOptions:** `TagsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15923,8 +16152,7 @@ await client.unstable.tags.detachTagFromTicket({
-## Conversations -
client.unstable.conversations.listConversations({ ...params }) -> Intercom.ConversationList +
client.preview.companies.attachContactToACompany({ ...params }) -> Intercom.Company
@@ -15936,13 +16164,7 @@ await client.unstable.tags.detachTagFromTicket({
-You can fetch a list of all conversations. - -You can optionally request the result page size and the cursor to start after to fetch the result. -{% admonition type="warning" name="Pagination" %} - You can use pagination to limit the number of results returned. The default is `20` results per page. - See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. -{% /admonition %} +You can attach a company to a single contact.
@@ -15957,9 +16179,9 @@ You can optionally request the result page size and the cursor to start after to
```typescript -await client.unstable.conversations.listConversations({ - per_page: 1, - starting_after: "starting_after" +await client.preview.companies.attachContactToACompany({ + id: "id", + company_id: "6762f09a1bb69f9f2193bb34" }); ``` @@ -15976,7 +16198,7 @@ await client.unstable.conversations.listConversations({
-**request:** `Intercom.unstable.ListConversationsRequest` +**request:** `Intercom.preview.AttachContactToACompanyRequest`
@@ -15984,7 +16206,7 @@ await client.unstable.conversations.listConversations({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -15996,7 +16218,7 @@ await client.unstable.conversations.listConversations({
-
client.unstable.conversations.createConversation({ ...params }) -> Intercom.Message +
client.preview.companies.detachContactFromACompany({ ...params }) -> Intercom.Company
@@ -16008,16 +16230,7 @@ await client.unstable.conversations.listConversations({
-You can create a conversation that has been initiated by a contact (ie. user or lead). -The conversation can be an in-app message only. - -{% admonition type="info" name="Sending for visitors" %} -You can also send a message from a visitor by specifying their `user_id` or `id` value in the `from` field, along with a `type` field value of `contact`. -This visitor will be automatically converted to a contact with a lead role once the conversation is created. -{% /admonition %} - -This will return the Message model that has been created. - +You can detach a company from a single contact.
@@ -16032,12 +16245,9 @@ This will return the Message model that has been created.
```typescript -await client.unstable.conversations.createConversation({ - from: { - type: "user", - id: "6762f11b1bb69f9f2193bba3" - }, - body: "Hello there" +await client.preview.companies.detachContactFromACompany({ + contact_id: "58a430d35458202d41b1e65b", + id: "58a430d35458202d41b1e65b" }); ``` @@ -16054,7 +16264,7 @@ await client.unstable.conversations.createConversation({
-**request:** `Intercom.unstable.CreateConversationRequest` +**request:** `Intercom.preview.DetachContactFromACompanyRequest`
@@ -16062,7 +16272,7 @@ await client.unstable.conversations.createConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -16074,7 +16284,7 @@ await client.unstable.conversations.createConversation({
-
client.unstable.conversations.retrieveConversation({ ...params }) -> Intercom.Conversation +
client.preview.companies.bulkCreateCompanies({ ...params }) -> Intercom.CompaniesBulkJob
@@ -16086,16 +16296,18 @@ await client.unstable.conversations.createConversation({
+You can bulk create or update companies by submitting an array of company objects. Each company is matched on the `company_id` you have defined for it: a new company is created if none exists with that `company_id`, otherwise the matching company is updated. This mirrors the single [Create or update a company](/docs/references/preview/rest-api/api.intercom.io/companies/createorupdatecompany) endpoint. -You can fetch the details of a single conversation. - -This will return a single Conversation model with all its conversation parts. +The endpoint creates an async job that processes the items in the background. Use the returned job ID with `GET /companies/bulk/{id}` to check the job status. -{% admonition type="warning" name="Hard limit of 500 parts" %} -The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. +{% admonition type="info" name="Handling failures" %} + If an item fails validation, that item is rejected and the job's `state` ends as `completed_with_errors`. The other companies in the same request are still processed. The job `state` from `GET /companies/bulk/{id}` is the signal that one or more items were rejected. {% /admonition %} -For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a [paid feature](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). +{% admonition type="info" name="Limits" %} + - Maximum of 100 companies per request. + - You can append tasks to an existing job by including `job.id` in the request body. +{% /admonition %}
@@ -16110,10 +16322,26 @@ For AI agent conversation metadata, please note that you need to have the agent
```typescript -await client.unstable.conversations.retrieveConversation({ - id: 1, - display_as: "plaintext", - include_translations: true +await client.preview.companies.bulkCreateCompanies({ + companies: [{ + company_id: "abc123", + name: "Acme Corp", + plan: "Enterprise", + size: 100, + website: "https://www.example.com", + industry: "Manufacturing", + custom_attributes: { + "paid_subscriber": true, + "team_mates": 9 + }, + remote_created_at: 1394531169, + monthly_spend: 1000, + update_last_request_at: true + }, { + company_id: "def456", + name: "Example Inc", + industry: "Manufacturing" + }] }); ``` @@ -16130,7 +16358,7 @@ await client.unstable.conversations.retrieveConversation({
-**request:** `Intercom.unstable.RetrieveConversationRequest` +**request:** `Intercom.preview.BulkCreateCompaniesRequest`
@@ -16138,7 +16366,7 @@ await client.unstable.conversations.retrieveConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -16150,7 +16378,7 @@ await client.unstable.conversations.retrieveConversation({
-
client.unstable.conversations.updateConversation({ ...params }) -> Intercom.Conversation +
client.preview.companies.bulkUpdateCompanies({ ...params }) -> Intercom.CompaniesBulkJob
@@ -16162,19 +16390,16 @@ await client.unstable.conversations.retrieveConversation({
+You can bulk update companies by submitting an array of company objects with the fields to update. Each company must include an `id` field identifying the company to update by its Intercom company `id`. An unknown `id` fails that item and never creates a company. -You can update an existing conversation. - -{% admonition type="info" name="Replying and other actions" %} -If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. -{% /admonition %} +Only the fields listed in the request schema below can be set. Any other fields in a company object are ignored. -{% admonition type="info" %} - This endpoint handles both **conversation updates** and **custom object associations**. +The endpoint creates an async job that processes the updates in the background. Use the returned job ID with `GET /companies/bulk/{id}` to check the job status. - See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% admonition type="info" name="Limits" %} + - Maximum of 100 companies per request. + - You can append tasks to an existing job by including `job.id` in the request body. {% /admonition %} -
@@ -16189,15 +16414,25 @@ If you want to reply to a coveration or take an action such as assign, unassign,
```typescript -await client.unstable.conversations.updateConversation({ - id: 1, - display_as: "plaintext", - read: true, - title: "new conversation title", - custom_attributes: { - "issue_type": "Billing", - "priority": "High" - } +await client.preview.companies.bulkUpdateCompanies({ + companies: [{ + id: "531ee472cce572a6ec000006", + name: "Acme Corp", + plan: "Enterprise", + size: 100, + website: "https://www.example.com", + industry: "Manufacturing", + custom_attributes: { + "paid_subscriber": true, + "team_mates": 9 + }, + remote_created_at: 1394531169, + monthly_spend: 1000, + update_last_request_at: true + }, { + id: "531ee472cce572a6ec000007", + name: "Example Inc" + }] }); ``` @@ -16214,7 +16449,7 @@ await client.unstable.conversations.updateConversation({
-**request:** `Intercom.unstable.UpdateConversationRequest` +**request:** `Intercom.preview.BulkUpdateCompaniesRequest`
@@ -16222,7 +16457,7 @@ await client.unstable.conversations.updateConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -16234,7 +16469,7 @@ await client.unstable.conversations.updateConversation({
-
client.unstable.conversations.deleteConversation({ ...params }) -> Intercom.ConversationDeleted +
client.preview.companies.bulkDeleteCompanies({ ...params }) -> Intercom.CompaniesBulkJob
@@ -16246,7 +16481,14 @@ await client.unstable.conversations.updateConversation({
-You can delete a single conversation. +You can bulk delete companies by submitting an array of companies, each identified by its Intercom company `id`. Deleting a company detaches all of its associated contacts but keeps the company record itself — the same archival behaviour as the single [Delete a company](/docs/references/preview/rest-api/api.intercom.io/companies/deletecompany) endpoint. + +The endpoint creates an async job that processes the deletes in the background. Use the returned job ID with `GET /companies/bulk/{id}` to check the job status. + +{% admonition type="info" name="Limits" %} + - Maximum of 100 companies per request. + - You can append tasks to an existing job by including `job.id` in the request body. +{% /admonition %}
@@ -16261,8 +16503,12 @@ You can delete a single conversation.
```typescript -await client.unstable.conversations.deleteConversation({ - id: 1 +await client.preview.companies.bulkDeleteCompanies({ + companies: [{ + id: "531ee472cce572a6ec000006" + }, { + id: "531ee472cce572a6ec000007" + }] }); ``` @@ -16279,7 +16525,7 @@ await client.unstable.conversations.deleteConversation({
-**request:** `Intercom.unstable.DeleteConversationRequest` +**request:** `Intercom.preview.BulkDeleteCompaniesRequest`
@@ -16287,7 +16533,7 @@ await client.unstable.conversations.deleteConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -16299,7 +16545,7 @@ await client.unstable.conversations.deleteConversation({
-
client.unstable.conversations.searchConversations({ ...params }) -> Intercom.ConversationList +
client.preview.companies.showBulkCompaniesJob({ ...params }) -> Intercom.CompaniesBulkJob
@@ -16311,105 +16557,7 @@ await client.unstable.conversations.deleteConversation({
-You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. - -To search for conversations, you need to send a `POST` request to `https://api.intercom.io/conversations/search`. - -This will accept a query object in the body which will define your filters in order to search for conversations. -{% admonition type="warning" name="Optimizing search queries" %} - Search queries can be complex, so optimizing them can help the performance of your search. - Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize - pagination to limit the number of results returned. The default is `20` results per page and maximum is `150`. - See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. -{% /admonition %} - -### Nesting & Limitations - -You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). -There are some limitations to the amount of multiple's there can be: -- There's a limit of max 2 nested filters -- There's a limit of max 15 filters for each AND or OR group - -### Accepted Fields - -Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). -The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. - -| Field | Type | -| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | -| id | String | -| created_at | Date (UNIX timestamp) | -| updated_at | Date (UNIX timestamp) | -| source.type | String
Accepted fields are `conversation`, `email`, `facebook`, `instagram`, `phone_call`, `phone_switch`, `push`, `sms`, `twitter` and `whatsapp`. | -| source.id | String | -| source.delivered_as | String | -| source.subject | String | -| source.body | String | -| source.author.id | String | -| source.author.type | String | -| source.author.name | String | -| source.author.email | String | -| source.url | String | -| contact_ids | String | -| teammate_ids | String | -| admin_assignee_id | String | -| team_assignee_id | String | -| channel_initiated | String | -| open | Boolean | -| read | Boolean | -| state | String | -| waiting_since | Date (UNIX timestamp) | -| snoozed_until | Date (UNIX timestamp) | -| tag_ids | String | -| priority | String | -| statistics.time_to_assignment | Integer | -| statistics.time_to_admin_reply | Integer | -| statistics.time_to_first_close | Integer | -| statistics.time_to_last_close | Integer | -| statistics.median_time_to_reply | Integer | -| statistics.first_contact_reply_at | Date (UNIX timestamp) | -| statistics.first_assignment_at | Date (UNIX timestamp) | -| statistics.first_admin_reply_at | Date (UNIX timestamp) | -| statistics.first_close_at | Date (UNIX timestamp) | -| statistics.last_assignment_at | Date (UNIX timestamp) | -| statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | -| statistics.last_contact_reply_at | Date (UNIX timestamp) | -| statistics.last_admin_reply_at | Date (UNIX timestamp) | -| statistics.last_close_at | Date (UNIX timestamp) | -| statistics.last_closed_by_id | String | -| statistics.count_reopens | Integer | -| statistics.count_assignments | Integer | -| statistics.count_conversation_parts | Integer | -| conversation_rating.requested_at | Date (UNIX timestamp) | -| conversation_rating.replied_at | Date (UNIX timestamp) | -| conversation_rating.score | Integer | -| conversation_rating.remark | String | -| conversation_rating.contact_id | String | -| conversation_rating.admin_d | String | -| ai_agent_participated | Boolean | -| ai_agent.resolution_state | String | -| ai_agent.last_answer_type | String | -| ai_agent.rating | Integer | -| ai_agent.rating_remark | String | -| ai_agent.source_type | String | -| ai_agent.source_title | String | - -### Accepted Operators - -The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). - -| Operator | Valid Types | Description | -| :------- | :----------------------------- | :----------------------------------------------------------- | -| = | All | Equals | -| != | All | Doesn't Equal | -| IN | All | In Shortcut for `OR` queries Values most be in Array | -| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | -| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | -| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | -| ~ | String | Contains | -| !~ | String | Doesn't Contain | -| ^ | String | Starts With | -| $ | String | Ends With | +You can check the status of a bulk companies job. The `state` field indicates the overall job progress: `pending`, `running`, `completed`, or `completed_with_errors`.
@@ -16424,18 +16572,8 @@ The table below shows the operators you can use to define how you want to search
```typescript -await client.unstable.conversations.searchConversations({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] - }, - pagination: { - per_page: 5 - } +await client.preview.companies.showBulkCompaniesJob({ + id: "job_v2_1" }); ``` @@ -16452,7 +16590,7 @@ await client.unstable.conversations.searchConversations({
-**request:** `Intercom.SearchRequest` +**request:** `Intercom.preview.ShowBulkCompaniesJobRequest`
@@ -16460,7 +16598,7 @@ await client.unstable.conversations.searchConversations({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `CompaniesClient.RequestOptions`
@@ -16472,7 +16610,8 @@ await client.unstable.conversations.searchConversations({
-
client.unstable.conversations.replyConversation({ ...params }) -> Intercom.Conversation +## Notes +
client.preview.notes.listCompanyNotes({ ...params }) -> Intercom.NoteList
@@ -16484,7 +16623,7 @@ await client.unstable.conversations.searchConversations({
-You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. +You can fetch a list of notes that are associated to a company.
@@ -16499,14 +16638,8 @@ You can reply to a conversation with a message from an admin or on behalf of a c
```typescript -await client.unstable.conversations.replyConversation({ - id: "123 or \"last\"", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb" - } +await client.preview.notes.listCompanyNotes({ + company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }); ``` @@ -16523,7 +16656,7 @@ await client.unstable.conversations.replyConversation({
-**request:** `Intercom.unstable.ReplyConversationRequest` +**request:** `Intercom.preview.ListCompanyNotesRequest`
@@ -16531,7 +16664,7 @@ await client.unstable.conversations.replyConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `NotesClient.RequestOptions`
@@ -16543,7 +16676,7 @@ await client.unstable.conversations.replyConversation({
-
client.unstable.conversations.manageConversation({ ...params }) -> Intercom.Conversation +
client.preview.notes.createCompanyNote({ ...params }) -> Intercom.Note
@@ -16555,11 +16688,7 @@ await client.unstable.conversations.replyConversation({
-For managing conversations you can: -- Close a conversation -- Snooze a conversation to reopen on a future date -- Open a conversation which is `snoozed` or `closed` -- Assign a conversation to an admin and/or team. +You can add a note to a single company.
@@ -16574,13 +16703,10 @@ For managing conversations you can:
```typescript -await client.unstable.conversations.manageConversation({ - id: "123", - body: { - message_type: "close", - type: "admin", - admin_id: "12345" - } +await client.preview.notes.createCompanyNote({ + company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + body: "Hello", + admin_id: "991267583" }); ``` @@ -16597,7 +16723,7 @@ await client.unstable.conversations.manageConversation({
-**request:** `Intercom.unstable.ManageConversationRequest` +**request:** `Intercom.preview.CreateCompanyNoteRequest`
@@ -16605,7 +16731,7 @@ await client.unstable.conversations.manageConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `NotesClient.RequestOptions`
@@ -16617,7 +16743,7 @@ await client.unstable.conversations.manageConversation({
-
client.unstable.conversations.attachContactToConversation({ ...params }) -> Intercom.Conversation +
client.preview.notes.listNotes({ ...params }) -> Intercom.NoteList
@@ -16629,12 +16755,7 @@ await client.unstable.conversations.manageConversation({
-You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. - -{% admonition type="warning" name="Contacts without an email" %} -If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. -{% /admonition %} - +You can fetch a list of notes that are associated to a contact.
@@ -16649,12 +16770,8 @@ If you add a contact via the email parameter and there is no user/lead found on
```typescript -await client.unstable.conversations.attachContactToConversation({ - id: "123", - admin_id: "12345", - customer: { - intercom_user_id: "6762f19b1bb69f9f2193bbd4" - } +await client.preview.notes.listNotes({ + id: 1 }); ``` @@ -16671,7 +16788,7 @@ await client.unstable.conversations.attachContactToConversation({
-**request:** `Intercom.unstable.AttachContactToConversationRequest` +**request:** `Intercom.preview.ListNotesRequest`
@@ -16679,7 +16796,7 @@ await client.unstable.conversations.attachContactToConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `NotesClient.RequestOptions`
@@ -16691,7 +16808,7 @@ await client.unstable.conversations.attachContactToConversation({
-
client.unstable.conversations.detachContactFromConversation({ ...params }) -> Intercom.Conversation +
client.preview.notes.createNote({ ...params }) -> Intercom.Note
@@ -16703,12 +16820,7 @@ await client.unstable.conversations.attachContactToConversation({
-You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. - -{% admonition type="warning" name="Contacts without an email" %} -If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. -{% /admonition %} - +You can add a note to a single contact.
@@ -16723,10 +16835,11 @@ If you add a contact via the email parameter and there is no user/lead found on
```typescript -await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690" +await client.preview.notes.createNote({ + id: 1, + body: "Hello", + contact_id: "6762f0ad1bb69f9f2193bb62", + admin_id: "123" }); ``` @@ -16743,7 +16856,7 @@ await client.unstable.conversations.detachContactFromConversation({
-**request:** `Intercom.unstable.DetachContactFromConversationRequest` +**request:** `Intercom.preview.CreateNoteRequest`
@@ -16751,7 +16864,7 @@ await client.unstable.conversations.detachContactFromConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `NotesClient.RequestOptions`
@@ -16763,7 +16876,7 @@ await client.unstable.conversations.detachContactFromConversation({
-
client.unstable.conversations.listHandlingEvents({ ...params }) -> Intercom.HandlingEventList +
client.preview.notes.retrieveNote({ ...params }) -> Intercom.Note
@@ -16775,9 +16888,7 @@ await client.unstable.conversations.detachContactFromConversation({
-List all pause/resume events for a conversation. These events track when teammates paused or resumed handling a conversation. - -Requires the `read_conversations` OAuth scope. +You can fetch the details of a single note.
@@ -16792,8 +16903,8 @@ Requires the `read_conversations` OAuth scope.
```typescript -await client.unstable.conversations.listHandlingEvents({ - id: "123" +await client.preview.notes.retrieveNote({ + id: 1 }); ``` @@ -16810,7 +16921,7 @@ await client.unstable.conversations.listHandlingEvents({
-**request:** `Intercom.unstable.ListHandlingEventsRequest` +**request:** `Intercom.preview.RetrieveNoteRequest`
@@ -16818,7 +16929,7 @@ await client.unstable.conversations.listHandlingEvents({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `NotesClient.RequestOptions`
@@ -16830,7 +16941,7 @@ await client.unstable.conversations.listHandlingEvents({
-
client.unstable.conversations.redactConversation({ ...params }) -> Intercom.Conversation +
client.preview.notes.deleteNote({ ...params }) -> Intercom.DeletedNoteObject
@@ -16842,12 +16953,7 @@ await client.unstable.conversations.listHandlingEvents({
-You can redact a conversation part or the source message of a conversation (as seen in the source object). - -{% admonition type="info" name="Redacting parts and messages" %} -If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. -{% /admonition %} - +You can delete a single contact or company note. Notes of other kinds cannot be deleted through the API.
@@ -16862,10 +16968,8 @@ If you are redacting a conversation part, it must have a `body`. If you are reda
```typescript -await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "19894788788", - conversation_part_id: "19381789428" +await client.preview.notes.deleteNote({ + id: 1 }); ``` @@ -16882,7 +16986,7 @@ await client.unstable.conversations.redactConversation({
-**request:** `Intercom.RedactConversationRequest` +**request:** `Intercom.preview.DeleteNoteRequest`
@@ -16890,7 +16994,7 @@ await client.unstable.conversations.redactConversation({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `NotesClient.RequestOptions`
@@ -16902,7 +17006,8 @@ await client.unstable.conversations.redactConversation({
-
client.unstable.conversations.convertConversationToTicket({ ...params }) -> Intercom.Ticket | undefined +## Contacts +
client.preview.contacts.listCompaniesForAContact({ ...params }) -> Intercom.ContactAttachedCompanies
@@ -16914,7 +17019,7 @@ await client.unstable.conversations.redactConversation({
-You can convert a conversation to a ticket. +You can fetch a list of companies that are associated to a contact.
@@ -16929,9 +17034,8 @@ You can convert a conversation to a ticket.
```typescript -await client.unstable.conversations.convertConversationToTicket({ - id: 1, - ticket_type_id: "53" +await client.preview.contacts.listCompaniesForAContact({ + id: "63a07ddf05a32042dffac965" }); ``` @@ -16948,7 +17052,7 @@ await client.unstable.conversations.convertConversationToTicket({
-**request:** `Intercom.unstable.ConvertConversationToTicketRequest` +**request:** `Intercom.preview.ListCompaniesForAContactRequest`
@@ -16956,7 +17060,7 @@ await client.unstable.conversations.convertConversationToTicket({
-**requestOptions:** `ConversationsClient.RequestOptions` +**requestOptions:** `ContactsClient.RequestOptions`
@@ -16968,8 +17072,7 @@ await client.unstable.conversations.convertConversationToTicket({
-## Unstable CustomChannelEvents -
client.unstable.customChannelEvents.notifyNewConversation({ ...params }) -> Intercom.CustomChannelNotificationResponse +
client.preview.contacts.listGrantedCompaniesForAContact({ ...params }) -> Intercom.GrantedCompanyList
@@ -16981,8 +17084,15 @@ await client.unstable.conversations.convertConversationToTicket({
-Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. -> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +List the companies a contact has been granted access to. + +A granted company lets the contact read that company's tickets in the customer portal. It is separate from company membership — granting a company does not attach the contact to it, and [`GET /contacts/{id}/companies`](/docs/references/preview/rest-api/api.intercom.io/contacts/listcompaniesforacontact) does not include grants. + +`company_ids` holds the `company_id` values you set on your companies, so the list round-trips with the `company_ids` you send to `PUT /contacts/{contact_id}/granted_companies`. The list is sorted by company id and paginated. + +Returns an empty list when granted companies are not enabled for the workspace. + +Requires the `read_users_companies` OAuth scope. Set `Intercom-Version: Preview`.
@@ -16997,15 +17107,11 @@ Notifies Intercom that a new conversation was created in your custom channel/pla
```typescript -await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "evt_12345", - external_conversation_id: "conv_67890", - contact: { - type: "user", - external_id: "user_001", - name: "Jane Doe", - email: "jane.doe@example.com" - } +await client.preview.contacts.listGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + page: 1, + per_page: 1, + order: "asc" }); ``` @@ -17022,7 +17128,7 @@ await client.unstable.customChannelEvents.notifyNewConversation({
-**request:** `Intercom.CustomChannelBaseEvent` +**request:** `Intercom.preview.ListGrantedCompaniesForAContactRequest`
@@ -17030,7 +17136,7 @@ await client.unstable.customChannelEvents.notifyNewConversation({
-**requestOptions:** `CustomChannelEventsClient.RequestOptions` +**requestOptions:** `ContactsClient.RequestOptions`
@@ -17042,7 +17148,7 @@ await client.unstable.customChannelEvents.notifyNewConversation({
-
client.unstable.customChannelEvents.notifyNewMessage({ ...params }) -> Intercom.CustomChannelNotificationResponse +
client.preview.contacts.replaceGrantedCompaniesForAContact({ ...params }) -> Intercom.GrantedCompanyList
@@ -17054,8 +17160,7907 @@ await client.unstable.customChannelEvents.notifyNewConversation({
-Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. -> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +Replace the full set of companies a contact has been granted access to. + +This is a replacement, not an append. The `company_ids` you send become the contact's entire granted set — any company id you leave out is dropped. To add a company, send the existing ids plus the new one; to remove one, send the existing ids minus that one; to drop every grant, send an empty array. + +Identify companies by the `company_id` you set on them, the same values [`GET /contacts/{contact_id}/granted_companies`](/docs/references/preview/rest-api/api.intercom.io/contacts/listgrantedcompaniesforacontact) returns. Duplicates in the request are collapsed. A contact can be granted at most 100 companies. + +The response echoes the stored set, so a `200` is confirmation of exactly what the contact can now read. + +{% admonition type="info" name="Requires granted companies to be enabled" %} + This endpoint returns `404` with the code `granted_companies_not_enabled` unless granted companies are enabled for the workspace. Contact Intercom Support to enable it. +{% /admonition %} + +Requires the `write_users_companies` OAuth scope. Set `Intercom-Version: Preview`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + company_ids: ["acme-corp", "1234", "globex"] +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ReplaceGrantedCompaniesRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + + + +
+ +
client.preview.contacts.removeGrantedCompanyFromAContact({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Remove a single company from a contact's granted set, leaving the contact's other grants in place. + +Identify the company by the `company_id` you set on it, the same value [`GET /contacts/{contact_id}/granted_companies`](/docs/references/preview/rest-api/api.intercom.io/contacts/listgrantedcompaniesforacontact) returns. A `company_id` containing a dot or a slash is supported — URL-encode a slash as `%2F`. + +This endpoint is not idempotent. Removing a company the contact is not currently granted returns `404` with the code `company_not_found`, so repeating a successful call returns `404` rather than `204`. Treat the first `204` as the confirmation. + +{% admonition type="info" name="Requires granted companies to be enabled" %} + This endpoint returns `404` with the code `granted_companies_not_enabled` unless granted companies are enabled for the workspace. Contact Intercom Support to enable it. +{% /admonition %} + +Requires the `write_users_companies` OAuth scope. Set `Intercom-Version: Preview`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.removeGrantedCompanyFromAContact({ + contact_id: "63a07ddf05a32042dffac965", + company_id: "acme-corp" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.RemoveGrantedCompanyFromAContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.listSegmentsForAContact({ ...params }) -> Intercom.ContactSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of segments that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.listSegmentsForAContact({ + contact_id: "63a07ddf05a32042dffac965" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListSegmentsForAContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.listSubscriptionsForAContact({ ...params }) -> Intercom.SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. +This will return a list of Subscription Type objects that the contact is associated with. + +The data property will show a combined list of: + + 1.Opt-out subscription types that the user has opted-out from. + 2.Opt-in subscription types that the user has opted-in to receiving. + +**Note:** This endpoint only returns subscriptions where the contact has explicitly configured their preference. Subscriptions that are in the default state — where the contact has not made an explicit opt-in or opt-out choice — are not included in the response. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.listSubscriptionsForAContact({ + contact_id: "63a07ddf05a32042dffac965" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListSubscriptionsForAContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.listTagsForAContact({ ...params }) -> Intercom.TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags that are attached to a specific contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.listTagsForAContact({ + contact_id: "63a07ddf05a32042dffac965" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListTagsForAContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.listDeletedContacts({ ...params }) -> Intercom.DeletedContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a paginated list of the contacts in your workspace that are no longer active, +so you can recover ones whose `id`, `email`, or `external_id` you no longer have and +then permanently delete them. Each entry carries a `status` describing why the contact +is inactive: `archived`, `blocked`, `merged`, `pending_deletion`, or `permanently_deleted`. +`merged_into_id` is present only when `status` is `merged`, and `external_id` and `email` +are `null` for `permanently_deleted` contacts. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.listDeletedContacts({ + per_page: 1, + page: 1 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListDeletedContactsRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.showContact({ ...params }) -> Intercom.ShowContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact. + +{% admonition type="info" name="Merged contacts return 410 Gone" %} + If a contact has been merged into another contact via the Merge endpoint (`POST /contacts/merge`), requesting it by its original ID will return **HTTP 410 Gone** with a `Link` header pointing to the canonical (merged-into) contact. + + **Response headers:** + ``` + Link: ; rel="canonical" + ``` + + **Response body:** + ```json + { + "type": "error.list", + "errors": [{ "code": "contact_merged", "message": "This contact has been merged. See the 'Link' header for the canonical contact." }] + } + ``` + + The `Link` header contains the path to the final merge target, resolving multi-hop merge chains (up to 3 hops). +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.showContact({ + id: "63a07ddf05a32042dffac965", + include_merge_history: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ShowContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.updateContact({ ...params }) -> Intercom.UpdateContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing contact (ie. user or lead). + +{% admonition type="info" %} + This endpoint handles both **contact updates** and **custom object associations**. + + See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.updateContact({ + id: "63a07ddf05a32042dffac965", + include_merge_history: true, + email: "joebloggs@intercom.io", + name: "joe bloggs" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UpdateContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.deleteContact({ ...params }) -> Intercom.ContactDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.deleteContact({ + id: "id" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.mergeContact({ ...params }) -> Intercom.MergeContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge one contact into another. Both lead-into-user and user-into-user merges are supported: the source contact (`from`) may have a `role` of `lead` or `user`, and the destination contact (`into`) must have a `role` of `user`. + +{% admonition type="warning" name="User-to-user merges" %} + When you merge a user into another user, the source user's attribute values (standard and custom) are discarded and are not moved onto the target user. The target user keeps its own attribute values. Records associated with the source, such as conversations, notes, and tags, are still reassigned to the target. + + Merging a user into another user requires the `merge_users` OAuth scope on your access token, in addition to the scope required for lead-into-user merges. Tokens without this scope receive a `401 Unauthorized` when the source contact is a user. +{% /admonition %} + +{% admonition type="warning" name="Merged contacts are not retrievable via the API" %} + Once a merge is completed, the source contact (`from`) is permanently removed from the active contact list. This means: + - **GET /contacts/{id}** — Requesting the source contact by its original ID will return `410 Gone` with a `Link` header pointing to the canonical (merged-into) contact. + - **POST /contacts/search** — The source contact will not appear in search results, including queries filtered by `updated_at`. + - **GET /contacts** — The source contact will not appear in list results. + + Only the target contact (`into`) remains accessible. If your application stores contact IDs, update them to use the target contact's ID after a merge. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.mergeContact({ + include_merge_history: true, + from: "6762f0d51bb69f9f2193bb7f", + into: "6762f0d51bb69f9f2193bb80" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.MergeContactsRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.previewMergeContact({ ...params }) -> Intercom.MergePreviewResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Preview the result of merging one contact into another without applying the merge. This is a read-only dry run: it reports whether the merge is allowed and, if so, exactly what would change, **without modifying any data**. + +Send the same `from` and `into` contact IDs you would pass to [Merge two contacts](/docs/references/preview/rest-api/api.intercom.io/contacts/mergecontact). As with the merge endpoint, `from` may have a `role` of `lead` or `user`, and `into` must have a `role` of `user`. You can optionally pass `custom_attribute_names` to include specific custom attributes in the previewed attribute changes. + +- When `allowed` is `true`, the response contains a `summary`: every attribute change (with the resulting value on the surviving contact) and, for each object type, two counts — `from`, how many are on the source contact and would move to the destination, and `into`, how many the destination already has. Counts are reported for conversations, tickets, phone calls, notes, and tags. `conversations` counts non-ticket conversations only; tickets are reported separately under `tickets`, and `phone_calls` is present only for phone-channel merges. +- When `allowed` is `false`, the response contains `reasons`. Each reason has a stable `code` you can branch on and a human-readable `message` you can display. + +{% admonition type="warning" name="Previewing non-duplicate contacts" %} +By default a merge requires the two contacts to share an identifier (email or phone). Set `skip_duplicate_validation` to `true` to preview a merge of contacts that don't, the same rule the merge endpoint enforces. +{% /admonition %} + +When `allowed` is `false`, `reasons[].code` is one of: + +| code | meaning | +| --- | --- | +| `source_same_as_target` | The source contact (`from`) and the destination contact (`into`) are the same contact. A contact can't be merged into itself. | +| `invalid_merge_role_pair` | The `from`/`into` roles aren't mergeable. `into` must be a user. | +| `no_shared_identifier` | The contacts share no email or phone. Set `skip_duplicate_validation` to preview anyway. | +| `facebook_user` | Facebook contacts can't be merged. | +| `external_lead_channel_not_allowed` | The source is an external-channel lead that isn't eligible for merging. | +| `mailing_list` | Contacts created from a mailing list can't be merged. | +| `user_to_lead` | `into` is a lead or visitor. A user can only be merged into another user. | +| `whatsapp_data_cannot_be_merged` | The WhatsApp number on the source contact can't be reassigned to the destination. | +| `telegram_data_cannot_be_merged` | The Telegram sender on the source contact can't be reassigned to the destination. | +| `source_has_telegram_data` | The source contact has Telegram data, which user-into-user merges don't yet support moving. | +| `phone_data_cannot_be_merged` | The phone data on the source contact can't be reassigned to the destination. | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.previewMergeContact({ + from: "6762f0d51bb69f9f2193bb7f", + into: "6762f0d51bb69f9f2193bb80" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.MergePreviewRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.searchContacts({ ...params }) -> Intercom.ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + +To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`. + +This will accept a query object in the body which will define your filters in order to search for contacts. + +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `50` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} +### Merged Contacts + +Contacts that have been merged (via POST /contacts/merge) are excluded from search results. If a contact was recently merged into another, it will no longer appear in queries filtered by `updated_at` or any other field. Only the target contact from the merge remains searchable. + +### Contact Creation Delay + +If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: +* There's a limit of max 2 nested filters +* There's a limit of max 15 filters for each AND or OR group + +### Searching for Timestamp Fields + +Standard timestamp fields and Date custom attributes behave differently. + +**Standard timestamp fields** (`created_at`, `updated_at`, `last_seen_at` etc.) are filtered on the exact second, in UTC. `=` matches only Contacts whose value is that exact second, and `>`, `<`, `>=` and `<=` compare against the exact instant you pass - the value is not rounded or truncated. These fields report a type of `datetime` on the Data Attributes endpoint. Note that `!=` also matches Contacts with no value set for the field. + +**Date custom attributes** are matched by calendar day, and the day boundary is always UTC regardless of your workspace's timezone. `=` matches the whole UTC day, `>` matches from the start of the *next* UTC day, and `<` matches everything before the start of that day. The `!=`, `>=`, `<=`, `IN` and `NIN` operators are not supported on these fields and return an error. + +**Example.** Searching for `created_at` greater than `1577869200` (January 1st, 2020 9:00 AM UTC) returns Contacts created after that exact instant. Passing the same value for a Date custom attribute truncates it to `1577836800` (January 1st, 2020 12:00 AM UTC), so those results begin from January 2nd, 2020 12:00 AM UTC. + +Only search queries behave this way. Responses always carry the full UNIX timestamp, and sorting uses the full value. + +### Accepted Fields + +Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + +| Field | Type | +| ---------------------------------- | ------------------------------ | +| id | String | +| role | String
Accepts user or lead | +| name | String | +| avatar | String | +| owner_id | Integer | +| email | String | +| email_domain | String | +| phone | String | +| formatted_phone | String | +| external_id | String | +| created_at | Datetime (Unix timestamp in seconds) | +| signed_up_at | Datetime (Unix timestamp in seconds) | +| updated_at | Datetime (Unix timestamp in seconds) | +| last_seen_at | Datetime (Unix timestamp in seconds) | +| last_contacted_at | Datetime (Unix timestamp in seconds) | +| last_replied_at | Datetime (Unix timestamp in seconds) | +| last_email_opened_at | Datetime (Unix timestamp in seconds) | +| last_email_clicked_at | Datetime (Unix timestamp in seconds) | +| language_override | String | +| browser | String | +| browser_language | String | +| os | String | +| location.country | String | +| location.region | String | +| location.city | String | +| unsubscribed_from_emails | Boolean | +| marked_email_as_spam | Boolean | +| has_hard_bounced | Boolean | +| ios_last_seen_at | Datetime (Unix timestamp in seconds) | +| ios_app_version | String | +| ios_device | String | +| ios_app_device | String | +| ios_os_version | String | +| ios_app_name | String | +| ios_sdk_version | String | +| android_last_seen_at | Datetime (Unix timestamp in seconds) | +| android_app_version | String | +| android_device | String | +| android_app_name | String | +| andoid_sdk_version | String | +| segment_id | String | +| tag_id | String | +| custom_attributes.{attribute_name} | Matches the attribute's own type
(String, Integer, Float, Boolean or Date) | + +### Accepted Operators + +{% admonition type="warning" name="Operators not supported on Date custom attributes" %} + Date custom attributes do not support the `!=`, `>=`, or `<=` operators. Using them returns an error. Standard timestamp fields (`created_at`, `updated_at` etc.) do support these operators, and are filtered on the exact second. +{% /admonition %} + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). Which operators are valid depends on the field's type - see the "Valid Types" column below. Searching by `tag_id` supports only the `=` and `!=` operators. + +| Operator | Valid Types | Description | +| :------- | :---------------------------------- | :----------------------------------------------------------------------| +| = | All | Equals | +| != | All except Date | Doesn't Equal
Also matches Contacts with no value set | +| IN | All except Date, Datetime and tag_id | In
Shortcut for `OR` queries
Values must be in Array | +| NIN | All except Date, Datetime and tag_id | Not In
Shortcut for `OR !` queries
Values must be in Array | +| > | Integer
Datetime
Date | Greater than
On Date custom attributes, matches from the start of the next day | +| < | Integer
Datetime
Date | Lower than
On Date custom attributes, matches before the start of the day | +| >= | Integer
Datetime | Greater than or equal to
Not supported on Date custom attributes | +| <= | Integer
Datetime | Lower than or equal to
Not supported on Date custom attributes | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.searchContacts({ + include_merge_history: true, + query: { + operator: "AND", + value: [{ + field: "created_at", + operator: ">", + value: "1306054154" + }] + }, + pagination: { + per_page: 5 + }, + sort: { + field: "created_at", + order: "ascending" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ContactSearchRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.listContactActivities({ ...params }) -> Intercom.ContactActivityList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of contact activity events for your workspace, such as when contacts are created, role updated, merged, or deleted. Events are returned oldest first. + +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `50` results per page, with a maximum of `150`. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.listContactActivities({ + per_page: 1, + starting_after: "starting_after" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListContactActivitiesRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.listContacts({ ...params }) -> Intercom.ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts (ie. users or leads) in your workspace. +{% admonition type="info" name="Merged contacts" %} + Contacts that have been merged (via POST /contacts/merge) will not appear in list results. Only the target contact from the merge remains accessible. +{% /admonition %} +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `10` results per page, with a maximum of `150`. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.listContacts({ + include_merge_history: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListContactsRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.createContact({ ...params }) -> Intercom.CreateContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new contact (ie. user or lead). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.createContact({ + "email": "joebloggs@intercom.io" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CreateContactRequestTwo` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.showContactByExternalId({ ...params }) -> Intercom.ShowContactByExternalIdResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + +{% admonition type="info" name="Merged contacts return 410 Gone" %} + If the contact with this external ID has been merged into another contact, the API returns **HTTP 410 Gone** with a `Link` header pointing to the canonical (merged-into) contact. See `GET /contacts/{id}` for details on the response format. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.showContactByExternalId({ + external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27", + include_merge_history: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ShowContactByExternalIdRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.archiveContact({ ...params }) -> Intercom.ContactArchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can archive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.archiveContact({ + id: "63a07ddf05a32042dffac965" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ArchiveContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.unarchiveContact({ ...params }) -> Intercom.ContactUnarchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can unarchive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.unarchiveContact({ + id: "63a07ddf05a32042dffac965" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UnarchiveContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.blockContact({ ...params }) -> Intercom.ContactBlocked +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.blockContact({ + id: "63a07ddf05a32042dffac965" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.BlockContactRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.listContactMergeHistory({ ...params }) -> Intercom.MergeHistoryList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve the paginated list of contacts that have been merged into a given contact. + +Only available for contacts with a `user` role. Returns a `404` if the contact is not found or has a `lead` role. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.listContactMergeHistory({ + id: "63a07ddf05a32042dffac965", + cursor: "cursor", + per_page: 1, + order: "asc" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListContactMergeHistoryRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.bulkCreateContacts({ ...params }) -> Intercom.ContactsBulkJob +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can bulk create contacts by submitting an array of contact objects. This is a **strict create** and never updates an existing contact. + +The endpoint creates an async job that processes the items in the background. Use the returned job ID with `GET /contacts/bulk/{id}` to check the job status. + +Only the fields listed in the request schema below can be set. Any other fields in a contact object are ignored. + +{% admonition type="info" name="Handling existing contacts" %} + If a contact already exists with the given `external_id` or `email` (including an archived contact), that item is rejected and the job's `state` ends as `completed_with_errors`. New contacts in the same request are still created. The job `state` from `GET /contacts/bulk/{id}` is the signal that one or more items were rejected. + + Created contacts aren't returned with IDs in the response. Look them up afterwards with [Get a contact by External ID](/docs/references/preview/rest-api/api.intercom.io/contacts/showcontactbyexternalid) or [Search contacts](/docs/references/preview/rest-api/api.intercom.io/contacts/searchcontacts). +{% /admonition %} + +{% admonition type="info" name="Limits" %} + - Maximum of 100 contacts per request. + - You can append tasks to an existing job by including `job.id` in the request body. + - Tag application is best-effort and processed asynchronously: unknown tag IDs are skipped, and per-tag results are not returned in the job status. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.bulkCreateContacts({ + contacts: [{ + external_id: "abc123", + email: "joe@bloggs.com", + name: "Joe Bloggs", + role: "user", + phone: "+353871234567", + avatar: "https://www.example.com/avatar_image.jpg", + language_override: "fr", + custom_attributes: { + "plan": "pro" + }, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + owner_id: "321", + unsubscribed_from_emails: false, + companies: [{ + company_id: "6", + name: "Blue Sun" + }], + tags: { + add: [{ + id: "123" + }] + } + }] +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.BulkCreateContactsRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.bulkUpdateContacts({ ...params }) -> Intercom.ContactsBulkJob +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can bulk update contacts by submitting an array of contact objects with the fields to update. Each contact must include an `id` field identifying the contact to update. You can also add or remove tags on each contact by including a `tags` object. + +Only the fields listed in the request schema below can be set. Any other fields in a contact object are ignored. + +The endpoint creates an async job that processes the updates in the background. Use the returned job ID with `GET /contacts/bulk/{id}` to check the job status. + +{% admonition type="info" name="Limits" %} + - Maximum of 100 contacts per request. + - You can append tasks to an existing job by including `job.id` in the request body. + - Tag application is best-effort and processed asynchronously: unknown tag IDs are skipped, and per-tag results are not returned in the job status. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.bulkUpdateContacts({ + contacts: [{ + id: "abc123", + external_id: "ext123", + email: "joe@bloggs.com", + name: "Joe Bloggs", + phone: "+353871234567", + avatar: "https://www.example.com/avatar_image.jpg", + owner_id: "321", + unsubscribed_from_emails: false, + language_override: "fr", + custom_attributes: { + "plan": "pro" + }, + companies: [{ + company_id: "6", + name: "Blue Sun" + }], + tags: { + add: [{ + id: "123" + }], + remove: [{ + id: "987" + }] + } + }] +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.BulkUpdateContactsRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.bulkDeleteContacts({ ...params }) -> Intercom.ContactsBulkJob +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete contacts in bulk by submitting an array of contact `id`s. + +The endpoint creates an async job that processes the deletes in the background. Use the returned job ID with `GET /contacts/bulk/{id}` to check the job status. + +{% admonition type="warning" name="Permanent deletion" %} + A contact that doesn't exist, or can't be deleted, fails that item and the job's `state` ends as `completed_with_errors` (visible via `GET /contacts/bulk/{id}`) without failing the rest of the batch. +{% /admonition %} + +{% admonition type="info" name="Limits" %} + - Maximum of 100 contacts per request. + - You can append tasks to an existing job by including `job.id` in the request body. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.bulkDeleteContacts({ + contacts: [{ + id: "abc123" + }, { + id: "def456" + }] +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.BulkDeleteContactsRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contacts.showBulkUpdateContactsJob({ ...params }) -> Intercom.ContactsBulkJob +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can check the status of a bulk contact update job. The `state` field indicates the overall job progress: `pending`, `running`, `completed`, or `completed_with_errors`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contacts.showBulkUpdateContactsJob({ + id: "job_v2_1" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ShowBulkUpdateContactsJobRequest` + +
+
+ +
+
+ +**requestOptions:** `ContactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Subscription Types +
client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ ...params }) -> Intercom.SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + + 1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type. + + 2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type. + +This will return a subscription type model for the subscription type that was added to the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ + contact_id: "63a07ddf05a32042dffac965", + id: "37846", + consent_type: "opt_in" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.AttachSubscriptionTypeToContactRequest` + +
+
+ +
+
+ +**requestOptions:** `SubscriptionTypesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.subscriptionTypes.detachSubscriptionTypeToContact({ ...params }) -> Intercom.SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.subscriptionTypes.detachSubscriptionTypeToContact({ + contact_id: "63a07ddf05a32042dffac965", + id: "37846" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DetachSubscriptionTypeToContactRequest` + +
+
+ +
+
+ +**requestOptions:** `SubscriptionTypesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.subscriptionTypes.listSubscriptionTypes() -> Intercom.SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all subscription types. A list of subscription type objects will be returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.subscriptionTypes.listSubscriptionTypes(); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `SubscriptionTypesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Tags +
client.preview.tags.attachTagToContact({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific contact. This will return a tag object for the tag that was added to the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.attachTagToContact({ + contact_id: "63a07ddf05a32042dffac965", + id: "7522907" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.AttachTagToContactRequest` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.detachTagFromContact({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.detachTagFromContact({ + contact_id: "63a07ddf05a32042dffac965", + id: "7522907" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DetachTagFromContactRequest` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.attachTagToConversation({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.attachTagToConversation({ + conversation_id: "64619700005694", + id: "7522907", + admin_id: "780" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.AttachTagToConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.detachTagFromConversation({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.detachTagFromConversation({ + conversation_id: "64619700005694", + id: "7522907", + admin_id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DetachTagFromConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.listTags() -> Intercom.TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags for a given workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.listTags(); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.createTag({ ...params }) -> Intercom.TagCreateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can use this endpoint to perform the following operations: + + **1. Create a new tag:** You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below. + + **2. Update an existing tag:** You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below. + + **3. Tag Companies:** You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically. + + **4. Untag Companies:** You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below. + + **5. Tag Multiple Users:** You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below. + +Each operation will return a tag object. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.createTag({ + name: "test" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CreateTagRequestBody` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.findTag({ ...params }) -> Intercom.TagBasic +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of tags that are on the workspace by their id. +This will return a tag object. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.findTag({ + id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.FindTagRequest` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.deleteTag({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete the details of tags that are on the workspace by passing in the id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.deleteTag({ + id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteTagRequest` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.attachTagToTicket({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.attachTagToTicket({ + ticket_id: "64619700005694", + id: "7522907", + admin_id: "780" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.AttachTagToTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.tags.detachTagFromTicket({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.tags.detachTagFromTicket({ + ticket_id: "64619700005694", + id: "7522907", + admin_id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DetachTagFromTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `TagsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Banners +
client.preview.banners.listContactBanners({ ...params }) -> Intercom.BannerList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns the banners a contact currently matches, so you can display them on +surfaces outside the Messenger (native mobile apps, kiosks, embedded tools). + +Each banner in the response includes a `view_id`. Use it to record a dismissal +with the dismiss endpoint. A returned banner is treated as shown: requesting +this endpoint records an impression for each banner returned, so call it at the +point you are about to display the banners, not speculatively. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.banners.listContactBanners({ + id: "id" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListContactBannersRequest` + +
+
+ +
+
+ +**requestOptions:** `BannersClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.banners.dismissContactBanner({ ...params }) -> Intercom.BannerDismiss +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Records that a contact has dismissed a banner. Dismissals are shared across +surfaces, so a banner dismissed through this endpoint will also stop appearing +in the web Messenger for that contact, and vice versa. + +The request is idempotent: dismissing an already-dismissed banner succeeds and +returns the same response. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.banners.dismissContactBanner({ + id: "id", + view_id: "view_id" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DismissContactBannerRequest` + +
+
+ +
+
+ +**requestOptions:** `BannersClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Content +
client.preview.content.bulkContentActions({ ...params }) -> Intercom.ContentBulkActionResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Asynchronously run a bulk action over up to 1,000 Knowledge Hub content items. + +Six actions are supported: + * `publish` and `unpublish` — apply to `article_content` only. + * `delete` — permanently delete content (excludes synced sources and `external_content`). + * `set_availability` — toggle Fin AI Agent, Copilot, and Sales Agent availability flags. + * `set_audience` — manage segment membership on content. + * `update_tags` — apply and/or remove existing tags on content. Unlike the other + actions, `update_tags` addresses articles by the parent `article` id, not + `article_content`. Tags must already exist and not be archived; supply at least one of + `add_tag_ids` / `remove_tag_ids`. + +The endpoint validates the request, enqueues background work, and returns 202 with a +placeholder envelope. Items whose `type` is not in the action's allowlist are silently +dropped before processing. Articles imported from synced sources (Confluence, Notion, +Zendesk, Salesforce Knowledge, etc.) are silently skipped on `delete` — they can only be +removed by disconnecting the underlying import source. + +Requires the `write_content` OAuth scope. Set `Intercom-Version: Preview`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.content.bulkContentActions({ + action: "publish", + content_ids: [{ + type: "article_content", + id: "12345678" + }, { + type: "article_content", + id: "12345679" + }] +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ContentBulkActionRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.content.searchContent({ ...params }) -> Intercom.ContentSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Search the knowledge base contents — articles, snippets, external pages, uploaded files, and internal articles — using a keyword query. + +Each result row has a `type` discriminator. Most types (`content_snippet`, `external_content`, `file_source_content`, `internal_article`) return a flat `{ type, id, title }` shape. Help center articles return a nested shape with a `contents[]` array, one entry per locale. + +Requires the `read_content` OAuth scope. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.content.searchContent({ + query: "billing", + page: 1, + per_page: 1, + tag_operator: "IN", + folder_entity_type: "folder", + copilot_state: "on", + fin_service_state: "on", + fin_sales_state: "on", + created_at_after: 1, + created_at_before: 1, + updated_at_after: 1, + updated_at_before: 1 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.SearchContentRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Content Snippets +
client.preview.contentSnippets.listContentSnippets({ ...params }) -> Intercom.ContentSnippetList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all content snippets for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contentSnippets.listContentSnippets({ + page: 1, + per_page: 20 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListContentSnippetsRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentSnippetsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contentSnippets.createContentSnippet({ ...params }) -> Intercom.ContentSnippet +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new content snippet. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contentSnippets.createContentSnippet({ + title: "How to reset your password", + json_blocks: [{ + "type": "paragraph", + "text": "Navigate to Settings > Security > Reset password." + }], + locale: "en", + audience_ids: [1, 2] +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ContentSnippetCreateRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentSnippetsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contentSnippets.getContentSnippet({ ...params }) -> Intercom.ContentSnippet +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single content snippet by its id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contentSnippets.getContentSnippet({ + id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.GetContentSnippetRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentSnippetsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contentSnippets.updateContentSnippet({ ...params }) -> Intercom.ContentSnippet +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing content snippet. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contentSnippets.updateContentSnippet({ + id: "123", + title: "How to reset your password (updated)", + json_blocks: [{ + "type": "paragraph", + "text": "Go to Settings > Security > Reset password and follow the steps." + }], + audience_ids: [1, 2] +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ContentSnippetUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentSnippetsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contentSnippets.deleteContentSnippet({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single content snippet by its id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contentSnippets.deleteContentSnippet({ + id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteContentSnippetRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentSnippetsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contentSnippets.attachTagToContentSnippet({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Apply an existing tag to a content snippet. Returns the tag that was applied. + +The tag must already exist in the workspace (create tags with the Tags API), +and the authenticating teammate must have the `manage_knowledge_base_content` +permission. + +Requires the `read_write_content_snippets` OAuth scope. Set `Intercom-Version: Preview`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contentSnippets.attachTagToContentSnippet({ + content_snippet_id: "123", + id: "7522907" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.AttachTagToContentSnippetRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentSnippetsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.contentSnippets.detachTagFromContentSnippet({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Remove a tag from a content snippet. Returns the tag that was removed, with +null `applied_at` and `applied_by`. + +The authenticating teammate must have the `manage_knowledge_base_content` +permission. + +Requires the `read_write_content_snippets` OAuth scope. Set `Intercom-Version: Preview`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.contentSnippets.detachTagFromContentSnippet({ + content_snippet_id: "123", + id: "7522907" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DetachTagFromContentSnippetRequest` + +
+
+ +
+
+ +**requestOptions:** `ContentSnippetsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Conversations +
client.preview.conversations.listConversations({ ...params }) -> Intercom.ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all conversations. + +You can optionally request the result page size and the cursor to start after to fetch the result. +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.listConversations({ + per_page: 1, + starting_after: "starting_after", + include_monitors: true, + include_scorecards: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListConversationsRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.createConversation({ ...params }) -> Intercom.Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a conversation that has been initiated by a contact (ie. user or lead). +The conversation can be an in-app message only. + +{% admonition type="info" name="Sending for visitors" %} +You can also send a message from a visitor by specifying their `user_id` or `id` value in the `from` field, along with a `type` field value of `contact`. +This visitor will be automatically converted to a contact with a lead role once the conversation is created. +{% /admonition %} + +This will return the Message model that has been created. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.createConversation({ + from: { + type: "user", + id: "6762f11b1bb69f9f2193bba3" + }, + body: "Hello there", + brand_id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.CreateConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.retrieveConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can fetch the details of a single conversation. + +This will return a single Conversation model with all its conversation parts. + +{% admonition type="warning" name="Hard limit of 500 parts" %} +The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. `include_part_types` and `exclude_part_types` are applied before this limit, so filtering returns the 500 most recent matching parts. `conversation_parts.total_count` counts the parts in this response, after filtering — it is not the conversation's total part count. +{% /admonition %} + +For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a [paid feature](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.retrieveConversation({ + id: 1, + display_as: "plaintext", + include_translations: true, + include_email_history: true, + include_monitors: true, + include_scorecards: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.RetrieveConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.updateConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can update an existing conversation. + +{% admonition type="info" name="Replying and other actions" %} +If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. +{% /admonition %} + +{% admonition type="info" %} + This endpoint handles both **conversation updates** and **custom object associations**. + + See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% /admonition %} + +{% admonition type="danger" name="Breaking change: duplicate custom attribute names" %} +The `PUT /conversations/{id}` endpoint now returns a `400 INVALID_PARAMETER` error when the request includes `custom_attributes` and your workspace contains multiple non-archived conversation custom attributes with the same name. Previously, the update would silently apply to a non-deterministic attribute. + +To resolve, rename or archive the duplicate attribute so each name is unique, then retry the request. You can do this through: + +- The Conversation Attributes API — list with `GET /conversations/attributes`, then rename with `PUT /conversations/attributes/{id}` or archive with `DELETE /conversations/attributes/{id}` +- Your workspace settings (Settings → Data → Conversations) +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.updateConversation({ + id: 1, + display_as: "plaintext", + read: true, + title: "new conversation title", + priority: "high", + admin_id: "394051", + custom_attributes: { + "issue_type": "Billing" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UpdateConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.deleteConversation({ ...params }) -> Intercom.ConversationDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +{% admonition type="warning" name="Irreversible operation" %} +Deleting a conversation is permanent and cannot be reversed. +{% /admonition %} + +You can delete a single conversation. The behavior depends on the `retain_metrics` parameter: + +- **With `retain_metrics=true` (default)**: Deletes the conversation while retaining reporting data. The conversation will still appear in reporting, though some data may be incomplete due to the deletion. + +- **With `retain_metrics=false`**: Deletes the conversation and all associated reporting data. The conversation will be completely removed from both the inbox and all reporting. + +{% admonition type="info" name="Required scope for retain_metrics=false" %} +Using `retain_metrics=false` requires the `delete_conversations_and_metrics` OAuth scope. +{% /admonition %} + +For more info, see [this help center article](https://www.intercom.com/help/en/articles/13885146-deleting-a-conversation). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.deleteConversation({ + id: 1, + retain_metrics: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.searchConversations({ ...params }) -> Intercom.ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + +To search for conversations, you need to send a `POST` request to `https://api.intercom.io/conversations/search`. + +This will accept a query object in the body which will define your filters in order to search for conversations. +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `20` results per page and maximum is `150`. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). +The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + +| Field | Type | +| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | +| id | String | +| created_at | Date (UNIX timestamp) | +| updated_at | Date (UNIX timestamp) | +| source.type | String
Accepted fields are `conversation`, `email`, `facebook`, `instagram`, `phone_call`, `phone_switch`, `push`, `sms`, `twitter` and `whatsapp`. | +| source.id | String | +| source.delivered_as | String | +| source.subject | String | +| source.body | String | +| source.author.id | String | +| source.author.type | String | +| source.author.name | String | +| source.author.email | String | +| source.url | String | +| contact_ids | String | +| teammate_ids | String | +| admin_assignee_id | Integer | +| team_assignee_id | Integer | +| channel_initiated | String | +| open | Boolean | +| read | Boolean | +| state | String | +| waiting_since | Date (UNIX timestamp) | +| snoozed_until | Date (UNIX timestamp) | +| tag_ids | String | +| priority | String | +| statistics.time_to_assignment | Integer | +| statistics.time_to_admin_reply | Integer | +| statistics.time_to_first_close | Integer | +| statistics.time_to_last_close | Integer | +| statistics.median_time_to_reply | Integer | +| statistics.first_contact_reply_at | Date (UNIX timestamp) | +| statistics.first_assignment_at | Date (UNIX timestamp) | +| statistics.first_admin_reply_at | Date (UNIX timestamp) | +| statistics.first_close_at | Date (UNIX timestamp) | +| statistics.last_assignment_at | Date (UNIX timestamp) | +| statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | +| statistics.last_contact_reply_at | Date (UNIX timestamp) | +| statistics.last_admin_reply_at | Date (UNIX timestamp) | +| statistics.last_close_at | Date (UNIX timestamp) | +| statistics.last_closed_by_id | String | +| statistics.count_reopens | Integer | +| statistics.count_assignments | Integer | +| statistics.count_conversation_parts | Integer | +| conversation_rating.requested_at | Date (UNIX timestamp) | +| conversation_rating.replied_at | Date (UNIX timestamp) | +| conversation_rating.score | Integer | +| conversation_rating.remark | String | +| conversation_rating.contact_id | String | +| conversation_rating.admin_d | String | +| ai_agent_participated | Boolean | +| ai_agent.resolution_state | String | +| ai_agent.last_answer_type | String | +| ai_agent.rating | Integer | +| ai_agent.rating_remark | String | +| ai_agent.source_type | String | +| ai_agent.source_title | String | + +### Accepted Operators + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :----------------------------- | :----------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In Shortcut for `OR` queries Values most be in Array | +| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | +| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | +| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.searchConversations({ + include_monitors: true, + include_scorecards: true, + body: { + query: { + operator: "AND", + value: [{ + field: "created_at", + operator: ">", + value: "1306054154" + }] + }, + pagination: { + per_page: 5 + } + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.SearchConversationsRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.replyConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + +{% admonition type="warning" name="Bot replies to inbound email" %} +By default, bot or Operator replies to an inbound email conversation aren't sent to your customer. The reply is stored as an unnotifiable bot comment, and no `seen` receipt is generated until an email is actually delivered. + +To send these replies as outbound emails, reach out to your accounts team to enable the email-reply feature flag for your workspace. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.replyConversation({ + id: "123 or \"last\"", + body: { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f1571bb69f9f2193bbbb" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ReplyConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.manageConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +For managing conversations you can: +- Close a conversation +- Snooze a conversation to reopen on a future date +- Open a conversation which is `snoozed` or `closed` +- Assign a conversation to an admin and/or team. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.manageConversation({ + id: "123", + body: { + message_type: "close", + type: "admin", + admin_id: "12345" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ManageConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.listHandlingEvents({ ...params }) -> Intercom.HandlingEventList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all pause/resume events for a conversation. These events track when teammates paused or resumed handling a conversation. + +Requires the `read_conversations` OAuth scope. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.listHandlingEvents({ + id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListHandlingEventsRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.listHitlEvents({ ...params }) -> Intercom.HitlEventList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List the human-in-the-loop (HITL) events for a conversation. When Fin is unsure of an answer it can consult a teammate before replying, proposing a draft that the teammate approves, steers with free-text feedback, or takes over. Each consultation is returned as a series of events, oldest first, across every consultation on the conversation. + +Requires the `read_conversations` OAuth scope, and the caller must be able to access the conversation. + +Events are only recorded once a consultation has ended, so a consultation still awaiting a teammate does not appear. + +Which fields appear in `data` depends on `event_type`: + +| `event_type` | `data` fields | +|---|---| +| `fin_consultation_started` | `channel`, `rule_threshold_percent`, `confidence_percent`, `sharp_ask`, `ask_rationale`, `issue_summary`, `customer_question` | +| `fin_draft_proposed` | `draft` | +| `fin_teammate_input_received` | `round_index`, `teammate_input`, `reviewer_admin_id`, `regeneration_outcome` | +| `fin_draft_revised` | `round_index`, `revised_draft`, `regeneration_outcome` | +| `fin_consultation_finished` | `outcome`, `approved_draft_type`, `final_draft`, `sent_text`, `reviewer_admin_id`, `duration_seconds`, `rounds_count`, `payload_truncated` | + +A consultation always produces a `fin_consultation_started` and a `fin_consultation_finished` event. `fin_draft_proposed` appears when Fin proposed a draft. `fin_teammate_input_received` appears once per round of teammate feedback, and `fin_draft_revised` once per round where Fin produced a revised draft in response. + +Notes on interpreting the response: + +- `hitl_cycle_id` identifies the consultation, so it is the same on every event of one consultation. It is not unique per event. A conversation can hold several consultations — a consultation that replaces an outstanding one finishes with an `outcome` of `superseded`. +- `conversation_part_id` links an event to a conversation part where one exists. It is `null` in ordinary cases: teammate feedback given through the inbox creates no conversation part, a revised draft has no part of its own, and a consultation that escalated or was superseded sent no reply. +- `created_at` on `fin_draft_proposed` is approximate. It reports when the consultation started, which is when the draft was proposed. +- `rule_id`, `rule_name` and `rule_threshold_percent` are recorded when the consultation begins and are not updated afterwards, so a rule that has since been renamed or retuned will not match its current settings. They are `null` for consultations not triggered by a rule. +- `reviewer_admin_id` identifies the teammate involved in that event: on `fin_teammate_input_received` the teammate who gave the feedback, and on `fin_consultation_finished` the teammate who approved the draft or took over. On a consultation with several rounds these can be different teammates. +- `rounds_count` counts every round of teammate feedback the consultation had. Only the ten most recent rounds are retained, so a heavily steered consultation returns fewer `fin_teammate_input_received` events than `rounds_count`. +- Redacting a conversation removes this data. Depending on how it was redacted, the conversation either returns no events or returns events whose text fields are all `null`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.listHitlEvents({ + id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListHitlEventsRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.listSideConversations({ ...params }) -> Intercom.SideConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List side conversations for a given conversation. Side conversations are internal threads created by teammates from within a conversation. + +Each side conversation includes its conversation parts (messages). Results are paginated. + +Requires the `read_conversations` OAuth scope. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.listSideConversations({ + id: "123", + page: 1, + per_page: 1 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListSideConversationsRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.mergeConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Merge a secondary (source) conversation into a primary (target) conversation. +The secondary conversation is closed and linked to the primary, which +becomes the surviving thread. Returns the primary conversation on success. + +Requires `write_conversations` OAuth scope. When the secondary is a ticket, +`write_tickets` scope is also required. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.mergeConversation({ + id: "123", + merge_into_conversation_id: 456 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.MergeConversationsRequestBody` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.convertConversationToTicket({ ...params }) -> Intercom.Ticket | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can convert a conversation to a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.convertConversationToTicket({ + id: 1, + ticket_type_id: "53" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ConvertConversationToTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversations.listDeletedConversationIds({ ...params }) -> Intercom.DeletedConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all deleted conversation IDs. + +{% admonition type="warning" name="Pagination" %} + You can use pagination to limit the number of results returned. The default is `20` results per page. You can navigate to next pages using the `page` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversations.listDeletedConversationIds({ + page: 1, + per_page: 1, + order: "desc" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListDeletedConversationIdsRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Conversation Parts +
client.preview.conversationParts.updateConversationPart({ ...params }) -> Intercom.ConversationPart +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update properties of a conversation part. Currently supports updating the send state of an external reply or marking a part as seen by an admin. + +{% admonition type="warning" name="Experimental" %} + This is an experimental endpoint. It requires a valid HMAC secret for authentication in addition to the standard bearer token. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationParts.updateConversationPart({ + conversation_id: "123", + id: "456", + send_state: "sent", + info_message: "Message delivered successfully", + experimental: true, + secret: "hmac_secret_value" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UpdateConversationPartRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationPartsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationParts.redactConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can redact a conversation part or the source message of a conversation (as seen in the source object). + +{% admonition type="info" name="Redacting parts and messages" %} +If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationParts.redactConversation({ + type: "conversation_part", + conversation_id: "19894788788", + conversation_part_id: "19381789428" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.RedactConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationPartsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Conversation Participants +
client.preview.conversationParticipants.attachContactToConversation({ ...params }) -> Intercom.ConversationParticipantsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + +{% admonition type="warning" name="Contacts without an email" %} +If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationParticipants.attachContactToConversation({ + id: "123", + admin_id: "12345", + customer: { + intercom_user_id: "6762f19b1bb69f9f2193bbd4" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.AttachContactToConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationParticipantsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationParticipants.detachContactFromConversation({ ...params }) -> Intercom.ConversationParticipantsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove participants who are contacts from a group conversation, on behalf of an admin. + +{% admonition type="warning" name="Removing the last participant" %} +You cannot remove the last remaining contact from a conversation. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "123", + contact_id: "123", + admin_id: "5017690" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DetachContactFromConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationParticipantsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Conversations Attributes +
client.preview.conversationsAttributes.listConversationAttributes({ ...params }) -> Intercom.ConversationAttributeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all conversation attributes for your workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationsAttributes.listConversationAttributes({ + include_archived: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListConversationAttributesRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationsAttributes.createConversationAttribute({ ...params }) -> Intercom.ConversationAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new conversation attribute. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationsAttributes.createConversationAttribute({ + data_type: "string", + name: "api_test_attr" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CreateConversationAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationsAttributes.getConversationAttribute({ ...params }) -> Intercom.ConversationAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single conversation attribute by ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationsAttributes.getConversationAttribute({ + id: 1 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.GetConversationAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationsAttributes.updateConversationAttribute({ ...params }) -> Intercom.ConversationAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an existing conversation attribute. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationsAttributes.updateConversationAttribute({ + id: 1, + name: "api_test_renamed", + description: "Updated via API" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UpdateConversationAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationsAttributes.deleteConversationAttribute({ ...params }) -> Intercom.ConversationAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Archive a conversation attribute (soft delete). The attribute is marked as archived but not permanently deleted. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationsAttributes.deleteConversationAttribute({ + id: 1 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteConversationAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationsAttributes.createConversationAttributeOption({ ...params }) -> Intercom.ConversationAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a new option to a list-type conversation attribute. Returns the full attribute with the updated options array. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationsAttributes.createConversationAttributeOption({ + id: 1, + body: { + label: "High" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.CreateConversationAttributeOptionRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationsAttributes.updateConversationAttributeOption({ ...params }) -> Intercom.ConversationAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update the label of a single option on a list-type conversation attribute. Returns the full attribute with the updated options array. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationsAttributes.updateConversationAttributeOption({ + id: 1, + option_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + label: "Renamed" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UpdateConversationAttributeOptionRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.conversationsAttributes.deleteConversationAttributeOption({ ...params }) -> Intercom.ConversationAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Archive a single option on a list-type conversation attribute (soft delete). The option remains in the response with `archived: true`. Returns the full attribute with the updated options array. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.conversationsAttributes.deleteConversationAttributeOption({ + id: 1, + option_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteConversationAttributeOptionRequest` + +
+
+ +
+
+ +**requestOptions:** `ConversationsAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Custom Object Instances +
client.preview.customObjectInstances.listCustomObjectInstances({ ...params }) -> Intercom.CustomObjectInstancesPaginatedList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List instances of a custom object type. Three modes are supported: +- **No filter** — returns all instances for the type. +- **`references_contact_id`** — returns instances associated with the given contact. +- **`references_conversation_id`** — returns instances associated with the given conversation. + +When **`external_id`** is provided, returns a single matching instance (not a list). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.customObjectInstances.listCustomObjectInstances({ + custom_object_type_identifier: "Order", + references_contact_id: "references_contact_id", + references_conversation_id: "references_conversation_id", + external_id: "external_id", + page: 1, + per_page: 1 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListCustomObjectInstancesRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstancesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.customObjectInstances.createCustomObjectInstances({ ...params }) -> Intercom.CustomObjectInstance | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create or update a custom object instance +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.customObjectInstances.createCustomObjectInstances({ + custom_object_type_identifier: "Order", + external_id: "123", + external_created_at: 1392036272, + external_updated_at: 1392036272, + custom_attributes: { + "order_number": "ORDER-12345", + "total_amount": "custom_attributes" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.CreateOrUpdateCustomObjectInstanceRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstancesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.customObjectInstances.deleteCustomObjectInstancesById({ ...params }) -> Intercom.CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.customObjectInstances.deleteCustomObjectInstancesById({ + custom_object_type_identifier: "Order", + external_id: "external_id" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteCustomObjectInstancesByIdRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstancesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.customObjectInstances.getCustomObjectInstancesById({ ...params }) -> Intercom.CustomObjectInstance | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.customObjectInstances.getCustomObjectInstancesById({ + custom_object_type_identifier: "Order", + id: "id" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.GetCustomObjectInstancesByIdRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstancesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.customObjectInstances.deleteCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance using the Intercom defined id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.customObjectInstances.deleteCustomObjectInstancesByExternalId({ + custom_object_type_identifier: "Order", + id: "id" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteCustomObjectInstancesByExternalIdRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstancesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Data Attributes +
client.preview.dataAttributes.lisDataAttributes({ ...params }) -> Intercom.DataAttributeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all data attributes belonging to a workspace for contacts or companies. + +{% admonition type="warning" name="Conversation attributes removed" %} +Conversation attributes are no longer returned by this endpoint. Calling without a `model` parameter no longer includes them in the response, and `model=conversation` returns a `422` error. Use [GET /conversations/attributes](/docs/references/preview/rest-api/api.intercom.io/conversations-attributes/listconversationattributes) instead. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataAttributes.lisDataAttributes({ + model: "contact", + include_archived: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.LisDataAttributesRequest` + +
+
+ +
+
+ +**requestOptions:** `DataAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataAttributes.createDataAttribute({ ...params }) -> Intercom.DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a data attributes for a `contact` or a `company`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataAttributes.createDataAttribute({ + "key": "value" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `unknown` + +
+
+ +
+
+ +**requestOptions:** `DataAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataAttributes.updateDataAttribute({ ...params }) -> Intercom.DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can update a data attribute. + +> 🚧 Updating the data type is not possible +> +> It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataAttributes.updateDataAttribute({ + id: 1, + body: { + "key": "value" + } +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UpdateDataAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `DataAttributesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Auth Tokens +
client.preview.authTokens.listAuthTokens({ ...params }) -> Intercom.AuthTokenList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a paginated list of the workspace's stored third-party credentials. Use this to discover the id of a credential you want a data connector to authenticate with — that id is not otherwise available over REST. Only metadata is returned; credential values are never exposed. The list is not exhaustive: credentials a teammate created are listed, as are those created by some Intercom integrations, but credentials installed by an app package, those created by most other integrations, and those minted for an individual teammate's MCP access are not. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.authTokens.listAuthTokens({ + per_page: 1, + starting_after: "starting_after" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListAuthTokensRequest` + +
+
+ +
+
+ +**requestOptions:** `AuthTokensClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.authTokens.createAuthToken({ ...params }) -> Intercom.AuthToken +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Stores a third-party credential in your workspace so a data connector can authenticate outbound requests with it. Only credentials with a `token_type` of `text` can be created here — the credential value is sent as a request header. The value you supply is stored encrypted and is never returned by any endpoint, including this one. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.authTokens.createAuthToken({ + name: "Fulfilment API key", + token_value: "sk_live_9f3c2a7b41e8", + request_header_key: "Authorization", + token_prefix: "Bearer", + description: "Used by the order status connector", + domain: "api.fulfilment.example.com" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.CreateAuthTokenRequest` + +
+
+ +
+
+ +**requestOptions:** `AuthTokensClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.authTokens.retrieveAuthToken({ ...params }) -> Intercom.AuthToken +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns the metadata for a single stored third-party credential. A credential that the list endpoint does not return is also not retrievable here, and responds with 404. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.authTokens.retrieveAuthToken({ + id: "12345" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.RetrieveAuthTokenRequest` + +
+
+ +
+
+ +**requestOptions:** `AuthTokensClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.authTokens.updateAuthToken({ ...params }) -> Intercom.AuthToken +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates the metadata of a stored third-party credential. A field you omit keeps its current value. The credential value itself cannot be changed here and is never returned. Only credentials with a `token_type` of `text` can be updated; any other type responds with `400`. A credential the list endpoint does not return is also not updatable, and responds with `404`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.authTokens.updateAuthToken({ + id: "12345", + name: "Fulfilment API key (rotated host)", + description: "Used by the order status connector" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UpdateAuthTokenRequest` + +
+
+ +
+
+ +**requestOptions:** `AuthTokensClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Data Connectors +
client.preview.dataConnectors.listDataConnectors({ ...params }) -> Intercom.DataConnectorList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a paginated list of all data connectors for the workspace, ordered by most recently updated first. Data connectors allow workflows and AI agents to make HTTP requests to external APIs. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataConnectors.listDataConnectors({ + per_page: 1, + starting_after: "starting_after" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListDataConnectorsRequest` + +
+
+ +
+
+ +**requestOptions:** `DataConnectorsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataConnectors.createDataConnector({ ...params }) -> Intercom.DataConnectorDetail +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new data connector. The connector is created in `draft` state. Configure its URL, headers, data inputs, and other settings, then set it to `live` when ready. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataConnectors.createDataConnector({ + name: "Get Order Status", + description: "Looks up order status from an external service", + http_method: "get", + url: "https://api.example.com/orders/{{order_id}}/status", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + headers: [{ + name: "Content-Type", + value: "application/json" + }], + data_inputs: [{ + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "" + }], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.CreateDataConnectorRequest` + +
+
+ +
+
+ +**requestOptions:** `DataConnectorsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataConnectors.retrieveDataConnector({ ...params }) -> Intercom.DataConnectorDetail +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve the full detail of a single data connector by its ID. + +The response includes configuration, data inputs, response fields, and object mappings. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataConnectors.retrieveDataConnector({ + id: "12345", + state_version: "draft" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.RetrieveDataConnectorRequest` + +
+
+ +
+
+ +**requestOptions:** `DataConnectorsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataConnectors.deleteDataConnector({ ...params }) -> Intercom.DeletedDataConnectorObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an existing data connector. The connector must be in `draft` state and must not be in use by any workflows or AI agents. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataConnectors.deleteDataConnector({ + id: "12345" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DeleteDataConnectorRequest` + +
+
+ +
+
+ +**requestOptions:** `DataConnectorsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataConnectors.updateDataConnector({ ...params }) -> Intercom.DataConnectorDetail +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an existing data connector. Only provided fields are changed. Set `state` to `live` or `draft` to change the connector's state. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataConnectors.updateDataConnector({ + id: "12345", + name: "Updated Connector Name", + description: "Updated description" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UpdateDataConnectorRequest` + +
+
+ +
+
+ +**requestOptions:** `DataConnectorsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataConnectors.listDataConnectorExecutionResults({ ...params }) -> Intercom.DataConnectorExecutionResultList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve paginated execution logs for a specific data connector. +Results from the last hour are returned by default. Use `start_ts` and `end_ts` to customize the time range. + +Request/response bodies are excluded by default. Use `include_bodies=true` to include them. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataConnectors.listDataConnectorExecutionResults({ + data_connector_id: "12345", + per_page: 1, + starting_after: "starting_after", + success: "true", + error_type: "request_configuration_error", + start_ts: 1, + end_ts: 1, + include_bodies: "true" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListDataConnectorExecutionResultsRequest` + +
+
+ +
+
+ +**requestOptions:** `DataConnectorsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataConnectors.showDataConnectorExecutionResult({ ...params }) -> Intercom.DataConnectorExecutionResult +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve details for a specific data connector execution result. +Always includes request/response bodies and the sanitised request URL. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataConnectors.showDataConnectorExecutionResult({ + data_connector_id: "12345", + id: "99001" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ShowDataConnectorExecutionResultRequest` + +
+
+ +
+
+ +**requestOptions:** `DataConnectorsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Ecommerce Connectors +
client.preview.ecommerceConnectors.uploadEcommerceCatalog({ ...params }) -> Intercom.EcommerceCatalogUploadPartResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Upload a product catalog to an ecommerce connector. The catalog must be a JSON +array of product objects. There are two upload modes: + +**Single-file upload** — POST a single catalog file (up to 99 MB per request). +Omit `finalize` and `import_job_id`. Returns `202 Accepted` when sync has started. + +**Multipart upload** — For catalogs that must be split across multiple requests: + +1. POST the first part with `finalize=false` (no `import_job_id`). The response + returns an `import_job_id` and `next_part_number`. +2. POST each subsequent part with `finalize=false`, the `import_job_id` from step 1, + and the `part_number` from the previous response. Each part must be ≤ 99 MB. +3. POST with `finalize=true` and the `import_job_id` to complete the upload and + start the sync. No catalog file is required in the finalization request. + +Part uploads are idempotent — retrying the same `part_number` does not create +a duplicate. If a response is lost, retry with the same `part_number`. + +## Product object structure + +The catalog file must be a JSON array where each element is a product object. +Only `id`, `title`, and `url` are required — all other fields are optional. + +| Field | Type | Required | Description | +|---|---|---|---| +| `id` | string | ✓ | Your unique product identifier. Used to match products on re-upload so only changed products are re-indexed. Also the delete key — any product ID absent from a new upload is removed from Fin's knowledge. Must be stable across uploads. | +| `title` | string | ✓ | Product name. Used by Fin when searching for and recommending products. | +| `url` | string | ✓ | Canonical product page URL shown in Fin's product recommendations. Must be a valid `https://` URL. | +| `description` | string | | Product description that Fin reads to understand what the product is. HTML formatting is supported and safely sanitized (`description_html` takes precedence if both are provided). This is the primary field Fin uses to match products to shopper questions — a richer description leads to better recommendations. | +| `featured_image_url` | string | | Primary product image shown in Fin's recommendation cards. Falls back to the first entry of `image_urls` if not provided. If no valid image can be resolved for a variant, that variant's card is not shown to the shopper. | +| `image_urls` | string[] | | Additional product images. Used as a fallback when `featured_image_url` is absent or when a variant has no specific image. | +| `price_min` | number | | Lowest price across all variants. If omitted, derived automatically from variant prices. Fin uses this to filter products when a shopper mentions a budget (e.g. "under $100"). Displayed as a range alongside `price_max`, or as a single value if both are equal. | +| `price_max` | number | | Highest price across all variants. If omitted, derived from variant prices. Used alongside `price_min` for budget filtering and price display. | +| `currency` | string | | ISO 4217 currency code (e.g. `"USD"`, `"EUR"`, `"GBP"`). Defaults to USD if omitted. Used to format prices with the correct symbol in Fin's responses and product cards. | +| `in_stock` | boolean | | Whether the product is available to purchase. If omitted, derived from variant stock — the product is in stock if at least one variant has `in_stock: true`. Products with no in-stock variants are hidden from Fin entirely. | +| `category_path` | string or string[] | Strongly recommended | Hierarchical category breadcrumb (e.g. `["Clothing", "Outerwear", "Jackets"]`). Fin understands the hierarchy — a shopper asking about "Clothing" sees products from all subcategories underneath it. The most specific category is shown in search results. | +| `collections` | string[] | Strongly recommended | Collections or groupings this product belongs to in your store. Fin uses collections to understand your catalog's structure and answer questions like "what's in the sale collection?". | +| `tags` | string[] | | Free-form keywords matching how shoppers phrase needs in chat (e.g. `["waterproof", "gift", "plus-size"]`). Complements `category_path` and `collections`. | +| `available_options` | object[] | | Option types and their possible values (e.g. `{"name": "Size", "values": ["S", "M", "L"]}`). Fin uses these to understand what choices a shopper can make and to correctly filter variants when asked for a specific size, colour, or other attribute. | +| `additional_data` | object | | Custom attributes for your business. Fin uses these to show each customer only relevant products. All keys must be consistent across all products in your catalog — the attribute schema is read from the first product in the file. | +| `variants` | object[] | | Individual purchasable variants. Fin recommends specific variants (not just products), so populating variants with accurate stock, price, and option data leads to more precise recommendations. See the variant table below. | + +### Variant object structure + +Each object in the `variants` array may contain: + +| Field | Type | Required | Description | +|---|---|---|---| +| `id` | string | ✓ | Unique identifier for this variant within the product. | +| `title` | string | | Variant display name shown to shoppers (e.g. `"Small / Blue"`). | +| `price` | number | | Price of this specific variant. Fin uses variant prices for precise budget filtering and displays the variant price in recommendation cards. | +| `compare_at_price` | number | | Original price before a discount. When provided, Fin will naturally mention the saving (e.g. "down from $129 to $99"). | +| `in_stock` | boolean | | Whether this variant is currently available. Out-of-stock variants are not shown in Fin's recommendation cards and Fin will not suggest them to shoppers. | +| `image_url` | string | | Image specific to this variant. Takes precedence over the product's `featured_image_url`. Falls back to `featured_image_url`, then `image_urls`. If no valid image can be resolved, this variant's recommendation card will not be shown. | +| `selected_options` | object[] | | The specific option values that define this variant (e.g. `[{"name": "Size", "value": "Small"}, {"name": "Color", "value": "Blue"}]`). Fin uses these to match shopper requests like "do you have this in medium?" to the correct variant. | +| `url` | string | | Direct link to this variant's page. Takes precedence over the product URL in recommendation cards. If omitted, constructed automatically as `{product_url}?variant={id}`. | + +### Example catalog file + +```json +[ + { + "id": "prod-12345", + "title": "Classic Cotton T-Shirt", + "url": "https://example.com/products/classic-cotton-t-shirt", + "description": "A comfortable everyday t-shirt.", + "featured_image_url": "https://cdn.example.com/images/t-shirt.jpg", + "price_min": 19.99, + "price_max": 29.99, + "currency": "USD", + "in_stock": true, + "tags": ["organic", "bestseller"], + "collections": ["Summer Collection"], + "category_path": "Clothing > T-Shirts", + "available_options": [ + {"name": "Size", "values": ["S", "M", "L"]}, + {"name": "Color", "values": ["White", "Blue"]} + ], + "variants": [ + { + "id": "var-001", + "title": "S / White", + "price": 19.99, + "in_stock": true, + "selected_options": [ + {"name": "Size", "value": "S"}, + {"name": "Color", "value": "White"} + ] + }, + { + "id": "var-002", + "title": "M / Blue", + "price": 29.99, + "in_stock": true, + "selected_options": [ + {"name": "Size", "value": "M"}, + {"name": "Color", "value": "Blue"} + ] + } + ], + "additional_data": { + "sku": "TSHIRT-WHT-S", + "vendor": "Acme Apparel" + } + } +] +``` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.ecommerceConnectors.uploadEcommerceCatalog({ + id: "42939" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.UploadEcommerceCatalogRequest` + +
+
+ +
+
+ +**requestOptions:** `EcommerceConnectorsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Data Events +
client.preview.dataEvents.lisDataEvents({ ...params }) -> Intercom.DataEventSummary +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +> 🚧 +> +> Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days + +The events belonging to a customer can be listed by sending a GET request to `https://api.intercom.io/events` with a user or lead identifier along with a `type` parameter. The identifier parameter can be one of `user_id`, `email` or `intercom_user_id`. The `type` parameter value must be `user`. + +- `https://api.intercom.io/events?type=user&user_id={user_id}` +- `https://api.intercom.io/events?type=user&email={email}` +- `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads) + +The `email` parameter value should be [url encoded](http://en.wikipedia.org/wiki/Percent-encoding) when sending. + +You can optionally define the result page size as well with the `per_page` parameter. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataEvents.lisDataEvents({ + filter: { + user_id: "user_id" + }, + type: "type" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.LisDataEventsRequest` + +
+
+ +
+
+ +**requestOptions:** `DataEventsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataEvents.createDataEvent({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a `Content-Type` of `application/json`. + +When using the JavaScript API, [adding the code to your app](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-your-app) makes the Events API available. Once added, you can submit an event using the `trackEvent` method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event. + +With the Ruby client you pass a hash describing the event to `Intercom::Event.create`, or call the `track_user` method directly on the current user object (e.g. `user.track_event`). + +**NB: For the JSON object types, please note that we do not currently support nested JSON structure.** + +| Type | Description | Example | +| :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | +| String | The value is a JSON String | `"source":"desktop"` | +| Number | The value is a JSON Number | `"load": 3.67` | +| Date | The key ends with the String `_date` and the value is a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) timezone. | `"contact_date": 1392036272` | +| Link | The value is a HTTP or HTTPS URI. | `"article": "https://example.org/ab1de.html"` | +| Rich Link | The value is a JSON object that contains `url` and `value` keys. | `"article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"}` | +| Monetary Amount | The value is a JSON object that contains `amount` and `currency` keys. The `amount` key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | `"price": {"amount": 34999, "currency": "eur"}` | + +**Lead Events** + +When submitting events for Leads, you will need to specify the Lead's `id`. + +**Metadata behaviour** + +- We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event. +- It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one. +- There might be up to 24 hrs delay when you send a new metadata for an existing event. + +**Event de-duplication** + +The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is **strongly recommended** to send a second granularity Unix timestamp in the `created_at` field. + +Duplicated events are responded to using the normal `202 Accepted` code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place. + +### HTTP API Responses + +- Successful responses to submitted events return `202 Accepted` with an empty body. +- Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code. +- Events sent about users that cannot be found will return a `404 Not Found`. +- Event lists containing duplicate events will have those duplicates ignored. +- Server errors will return a `500` response code and may contain an error message in the body. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataEvents.createDataEvent({ + "key": "value" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CreateDataEventRequestTwo` + +
+
+ +
+
+ +**requestOptions:** `DataEventsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataEvents.dataEventSummaries({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataEvents.dataEventSummaries(); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.CreateDataEventSummariesRequest` + +
+
+ +
+
+ +**requestOptions:** `DataEventsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Data Export +
client.preview.dataExport.createDataExport({ ...params }) -> Intercom.DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. + +This endpoint exports **message delivery and engagement data** for outbound content (Emails, Posts, Custom Bots, Surveys, Tours, Series, and more). The exported data includes who received each message, when they received it, and how they engaged with it (opens, clicks, replies, completions, dismissals, unsubscribes, and bounces). It does not export raw message or conversation content. + +The only parameters you need to provide are the range of dates that you want exported. + +>🚧 Limit of one active job +> +> You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job. + +>❗️ Updated_at not included +> +> It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job. + +>📘 Date ranges are inclusive +> +> Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataExport.createDataExport({ + created_at_after: 1734519776, + created_at_before: 1734537776 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.CreateDataExportsRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExportClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataExport.getDataExport({ ...params }) -> Intercom.DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can view the status of your job by sending a `GET` request to the URL +`https://api.intercom.io/export/content/data/{job_identifier}` - the `{job_identifier}` is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + +> 🚧 Jobs expire after two days +> All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataExport.getDataExport({ + job_identifier: "job_identifier" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.GetDataExportRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExportClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataExport.cancelDataExport({ ...params }) -> Intercom.DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can cancel your job +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataExport.cancelDataExport({ + job_identifier: "job_identifier" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.CancelDataExportRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExportClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.dataExport.downloadDataExport({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + +Your exported message data will be streamed continuously back down to you in a gzipped CSV format. + +> 📘 Octet header required +> +> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.dataExport.downloadDataExport({ + job_identifier: "job_identifier" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.DownloadDataExportRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExportClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Workflows +
client.preview.workflows.exportWorkflow({ ...params }) -> Intercom.WorkflowExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Export a workflow configuration by its ID. This endpoint returns the complete workflow definition including its steps, targeting rules, and attributes. + +This endpoint is designed for EU Data Act compliance, allowing customers to export their workflow configurations. + +{% admonition type="info" name="Preview API" %} + This endpoint is available in the Preview API version. We may make iterative improvements, including adding new fields or refining existing ones. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.workflows.exportWorkflow({ + id: "12345" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ExportWorkflowRequest` + +
+
+ +
+
+ +**requestOptions:** `WorkflowsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Jobs +
client.preview.jobs.status({ ...params }) -> Intercom.Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve the status of job execution. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.jobs.status({ + id: "id" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.JobsStatusRequest` + +
+
+ +
+
+ +**requestOptions:** `JobsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Macros +
client.preview.macros.listMacros({ ...params }) -> Intercom.MacroList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all macros (saved replies) in your workspace for use in automating responses. + +The macros are returned in descending order by updated_at. + +**Pagination** + +This endpoint uses cursor-based pagination via the `starting_after` parameter. The cursor is a Base64-encoded JSON array containing `[updated_at, id]` of the last item from the previous page. + +**Placeholder Transformation** + +The API transforms Intercom placeholders to a more standard XML-like format: +- From: `{{user.name | fallback: 'there'}}` +- To: `` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.macros.listMacros({ + per_page: 1, + starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", + updated_since: 1000000 +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.ListMacrosRequest` + +
+
+ +
+
+ +**requestOptions:** `MacrosClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.preview.macros.getMacro({ ...params }) -> Intercom.Macro | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single macro (saved reply) by its ID. The macro will only be returned if it is visible to the authenticated user based on its visibility settings. + +**Visibility Rules** + +A macro is returned based on its `visible_to` setting: +- `everyone`: Always visible to all team members +- `specific_teams`: Only visible if the authenticated user belongs to one of the teams specified in `visible_to_team_ids` + +If a macro exists but is not visible to the authenticated user, a 404 error is returned. + +**Placeholder Transformation** + +The API transforms Intercom placeholders to a more standard XML-like format in the `body` field: +- From: `{{user.name | fallback: 'there'}}` +- To: `` + +Default values in placeholders are HTML-escaped for security. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.preview.macros.getMacro({ + id: "123" +}); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.preview.GetMacroRequest` + +
+
+ +
+
+ +**requestOptions:** `MacrosClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## Messages +
client.preview.messages.createMessage({ ...params }) -> Intercom.Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email, sms or whatsapp. + +> 🚧 Sending for visitors +> +> There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case. + +This will return the Message model that has been created. + +> 🚧 Retrieving Associated Conversations +> +> As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.
@@ -17070,16 +25075,13 @@ Notifies Intercom that a new message was sent in a conversation on your custom c
```typescript -await client.unstable.customChannelEvents.notifyNewMessage({ - event_id: "evt_54321", - external_conversation_id: "conv_98765", - contact: { - type: "user", - external_id: "user_002", - name: "John Smith", - email: "john.smith@example.com" +await client.preview.messages.createMessage({ + "from": { + "type": "user", + "id": "6762f2341bb69f9f2193bc17" }, - body: "Hello, I need help with my order." + "body": "heyy", + "referer": "https://twitter.com/bob" }); ``` @@ -17096,7 +25098,7 @@ await client.unstable.customChannelEvents.notifyNewMessage({
-**request:** `Intercom.unstable.NotifyNewMessageRequest` +**request:** `Intercom.CreateMessageRequest | undefined`
@@ -17104,7 +25106,7 @@ await client.unstable.customChannelEvents.notifyNewMessage({
-**requestOptions:** `CustomChannelEventsClient.RequestOptions` +**requestOptions:** `MessagesClient.RequestOptions`
@@ -17116,7 +25118,7 @@ await client.unstable.customChannelEvents.notifyNewMessage({
-
client.unstable.customChannelEvents.notifyQuickReplySelected({ ...params }) -> Intercom.CustomChannelNotificationResponse +
client.preview.messages.getWhatsAppMessageStatus({ ...params }) -> Intercom.WhatsappMessageStatusList
@@ -17128,8 +25130,11 @@ await client.unstable.customChannelEvents.notifyNewMessage({
-Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. -> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + + +This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing +information about delivery state and related message details.
@@ -17144,16 +25149,10 @@ Notifies Intercom that a user selected a quick reply option in your custom chann
```typescript -await client.unstable.customChannelEvents.notifyQuickReplySelected({ - event_id: "evt_67890", - external_conversation_id: "conv_13579", - contact: { - type: "user", - external_id: "user_003", - name: "Alice Example", - email: "alice@example.com" - }, - quick_reply_option_id: "1234" +await client.preview.messages.getWhatsAppMessageStatus({ + ruleset_id: "ruleset_id", + per_page: 1, + starting_after: "starting_after" }); ``` @@ -17170,7 +25169,7 @@ await client.unstable.customChannelEvents.notifyQuickReplySelected({
-**request:** `Intercom.unstable.NotifyQuickReplySelectedRequest` +**request:** `Intercom.preview.GetWhatsAppMessageStatusRequest`
@@ -17178,7 +25177,7 @@ await client.unstable.customChannelEvents.notifyQuickReplySelected({
-**requestOptions:** `CustomChannelEventsClient.RequestOptions` +**requestOptions:** `MessagesClient.RequestOptions`
@@ -17190,7 +25189,7 @@ await client.unstable.customChannelEvents.notifyQuickReplySelected({
-
client.unstable.customChannelEvents.notifyAttributeCollected({ ...params }) -> Intercom.CustomChannelNotificationResponse +
client.preview.messages.retrieveWhatsAppMessageStatus({ ...params }) -> Intercom.WhatsappMessageStatus
@@ -17202,8 +25201,10 @@ await client.unstable.customChannelEvents.notifyQuickReplySelected({
-Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. -> **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +Retrieves the delivery status of a specific WhatsApp message by its message ID. + + +Returns the current status, conversation details, and any error information if the message failed to deliver.
@@ -17218,19 +25219,8 @@ Notifies Intercom that a user provided a response to an attribute collector in y
```typescript -await client.unstable.customChannelEvents.notifyAttributeCollected({ - event_id: "evt_24680", - external_conversation_id: "conv_11223", - contact: { - type: "user", - external_id: "user_004", - name: "Bob Example", - email: "bob@example.com" - }, - attribute: { - id: "shipping_address", - value: "123 Main St, Springfield" - } +await client.preview.messages.retrieveWhatsAppMessageStatus({ + message_id: "message_id" }); ``` @@ -17247,7 +25237,7 @@ await client.unstable.customChannelEvents.notifyAttributeCollected({
-**request:** `Intercom.unstable.NotifyAttributeCollectedRequest` +**request:** `Intercom.preview.RetrieveWhatsAppMessageStatusRequest`
@@ -17255,7 +25245,7 @@ await client.unstable.customChannelEvents.notifyAttributeCollected({
-**requestOptions:** `CustomChannelEventsClient.RequestOptions` +**requestOptions:** `MessagesClient.RequestOptions`
@@ -17267,8 +25257,8 @@ await client.unstable.customChannelEvents.notifyAttributeCollected({
-## Custom Object Instances -
client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstance | undefined +## Teams +
client.preview.teams.getTeamMetrics({ ...params }) -> Intercom.TeamMetricList
@@ -17280,7 +25270,9 @@ await client.unstable.customChannelEvents.notifyAttributeCollected({
-Fetch a Custom Object Instance by external_id. +Returns real-time activity metrics for admins in the specified team. For each admin, the response includes counts of open, idle, and snoozed conversations. + +This endpoint requires the `realtime_monitoring` feature to be enabled for your workspace.
@@ -17295,9 +25287,9 @@ Fetch a Custom Object Instance by external_id.
```typescript -await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - external_id: "external_id" +await client.preview.teams.getTeamMetrics({ + team_id: "42", + idle_threshold: 1800 }); ``` @@ -17314,7 +25306,7 @@ await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId
-**request:** `Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest` +**request:** `Intercom.preview.GetTeamMetricsRequest`
@@ -17322,7 +25314,7 @@ await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId
-**requestOptions:** `CustomObjectInstancesClient.RequestOptions` +**requestOptions:** `TeamsClient.RequestOptions`
@@ -17334,7 +25326,7 @@ await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId
-
client.unstable.customObjectInstances.createCustomObjectInstances({ ...params }) -> Intercom.CustomObjectInstance | undefined +
client.preview.teams.listTeams() -> Intercom.TeamList
@@ -17346,7 +25338,7 @@ await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId
-Create or update a custom object instance +This will return a list of team objects for the App.
@@ -17361,16 +25353,7 @@ Create or update a custom object instance
```typescript -await client.unstable.customObjectInstances.createCustomObjectInstances({ - custom_object_type_identifier: "Order", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { - "order_number": "ORDER-12345", - "total_amount": "custom_attributes" - } -}); +await client.preview.teams.listTeams(); ```
@@ -17386,15 +25369,7 @@ await client.unstable.customObjectInstances.createCustomObjectInstances({
-**request:** `Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest` - -
-
- -
-
- -**requestOptions:** `CustomObjectInstancesClient.RequestOptions` +**requestOptions:** `TeamsClient.RequestOptions`
@@ -17406,7 +25381,7 @@ await client.unstable.customObjectInstances.createCustomObjectInstances({
-
client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ ...params }) -> Intercom.CustomObjectInstanceDeleted +
client.preview.teams.retrieveTeam({ ...params }) -> Intercom.Team
@@ -17418,7 +25393,7 @@ await client.unstable.customObjectInstances.createCustomObjectInstances({
-Delete a single Custom Object instance by external_id. +You can fetch the details of a single team, containing an array of admins that belong to this team.
@@ -17433,9 +25408,8 @@ Delete a single Custom Object instance by external_id.
```typescript -await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ - custom_object_type_identifier: "Order", - external_id: "external_id" +await client.preview.teams.retrieveTeam({ + id: "123" }); ``` @@ -17452,7 +25426,7 @@ await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({
-**request:** `Intercom.unstable.DeleteCustomObjectInstancesByIdRequest` +**request:** `Intercom.preview.RetrieveTeamRequest`
@@ -17460,7 +25434,7 @@ await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({
-**requestOptions:** `CustomObjectInstancesClient.RequestOptions` +**requestOptions:** `TeamsClient.RequestOptions`
@@ -17472,7 +25446,7 @@ await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({
-
client.unstable.customObjectInstances.getCustomObjectInstancesById({ ...params }) -> Intercom.CustomObjectInstance | undefined +
client.preview.teams.updateTeamMembers({ ...params }) -> Intercom.Team
@@ -17484,7 +25458,15 @@ await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({
-Fetch a Custom Object Instance by id. +You can replace the set of teammates who belong to a team. Send the full list of +teammates the team should end up with — any teammate currently on the team and +missing from the list is removed. This makes the endpoint safe to call on a +schedule to keep Intercom in step with an external rota or workforce management +system, since sending an unchanged list makes no changes at all. + +A token that acts on behalf of a teammate carries that teammate's permissions: +they must be able to manage teams, and any team or teammate their access is +restricted from remains out of reach here.
@@ -17499,9 +25481,13 @@ Fetch a Custom Object Instance by id.
```typescript -await client.unstable.customObjectInstances.getCustomObjectInstancesById({ - custom_object_type_identifier: "Order", - id: "id" +await client.preview.teams.updateTeamMembers({ + id: "123", + admin_ids: [493881, 493882], + admin_priority_level: { + primary_admin_ids: [493881], + secondary_admin_ids: [493882] + } }); ``` @@ -17518,7 +25504,7 @@ await client.unstable.customObjectInstances.getCustomObjectInstancesById({
-**request:** `Intercom.unstable.GetCustomObjectInstancesByIdRequest` +**request:** `Intercom.preview.UpdateTeamMembersRequest`
@@ -17526,7 +25512,7 @@ await client.unstable.customObjectInstances.getCustomObjectInstancesById({
-**requestOptions:** `CustomObjectInstancesClient.RequestOptions` +**requestOptions:** `TeamsClient.RequestOptions`
@@ -17538,7 +25524,8 @@ await client.unstable.customObjectInstances.getCustomObjectInstancesById({
-
client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstanceDeleted +## News +
client.preview.news.listNewsItems() -> Intercom.PaginatedResponse
@@ -17550,7 +25537,7 @@ await client.unstable.customObjectInstances.getCustomObjectInstancesById({
-Delete a single Custom Object instance using the Intercom defined id. +You can fetch a list of all news items
@@ -17565,10 +25552,7 @@ Delete a single Custom Object instance using the Intercom defined id.
```typescript -await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - id: "id" -}); +await client.preview.news.listNewsItems(); ```
@@ -17584,15 +25568,7 @@ await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExterna
-**request:** `Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest` - -
-
- -
-
- -**requestOptions:** `CustomObjectInstancesClient.RequestOptions` +**requestOptions:** `NewsClient.RequestOptions`
@@ -17604,8 +25580,7 @@ await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExterna
-## Data Attributes -
client.unstable.dataAttributes.lisDataAttributes({ ...params }) -> Intercom.DataAttributeList +
client.preview.news.createNewsItem({ ...params }) -> Intercom.NewsItem
@@ -17617,7 +25592,7 @@ await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExterna
-You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. +You can create a news item
@@ -17632,9 +25607,18 @@ You can fetch a list of all data attributes belonging to a workspace for contact
```typescript -await client.unstable.dataAttributes.lisDataAttributes({ - model: "contact", - include_archived: true +await client.preview.news.createNewsItem({ + title: "Halloween is here!", + body: "

New costumes in store for this spooky season

", + sender_id: 991267834, + state: "live", + deliver_silently: true, + labels: ["Product", "Update", "New"], + reactions: ["\uD83D\uDE06", "\uD83D\uDE05"], + newsfeed_assignments: [{ + newsfeed_id: 53, + published_at: 1664638214 + }] }); ``` @@ -17651,7 +25635,7 @@ await client.unstable.dataAttributes.lisDataAttributes({
-**request:** `Intercom.unstable.LisDataAttributesRequest` +**request:** `Intercom.NewsItemRequest`
@@ -17659,7 +25643,7 @@ await client.unstable.dataAttributes.lisDataAttributes({
-**requestOptions:** `DataAttributesClient.RequestOptions` +**requestOptions:** `NewsClient.RequestOptions`
@@ -17671,7 +25655,7 @@ await client.unstable.dataAttributes.lisDataAttributes({
-
client.unstable.dataAttributes.createDataAttribute({ ...params }) -> Intercom.DataAttribute +
client.preview.news.retrieveNewsItem({ ...params }) -> Intercom.NewsItem
@@ -17683,7 +25667,7 @@ await client.unstable.dataAttributes.lisDataAttributes({
-You can create a data attributes for a `contact` or a `company`. +You can fetch the details of a single news item.
@@ -17698,8 +25682,8 @@ You can create a data attributes for a `contact` or a `company`.
```typescript -await client.unstable.dataAttributes.createDataAttribute({ - "key": "value" +await client.preview.news.retrieveNewsItem({ + id: 1 }); ``` @@ -17716,7 +25700,7 @@ await client.unstable.dataAttributes.createDataAttribute({
-**request:** `unknown` +**request:** `Intercom.preview.RetrieveNewsItemRequest`
@@ -17724,7 +25708,7 @@ await client.unstable.dataAttributes.createDataAttribute({
-**requestOptions:** `DataAttributesClient.RequestOptions` +**requestOptions:** `NewsClient.RequestOptions`
@@ -17736,29 +25720,10 @@ await client.unstable.dataAttributes.createDataAttribute({
-
client.unstable.dataAttributes.updateDataAttribute({ ...params }) -> Intercom.DataAttribute +
client.preview.news.updateNewsItem({ ...params }) -> Intercom.NewsItem
-#### 📝 Description - -
-
- -
-
- - -You can update a data attribute. - -> 🚧 Updating the data type is not possible -> -> It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead. -
-
-
-
- #### 🔌 Usage
@@ -17768,10 +25733,13 @@ You can update a data attribute.
```typescript -await client.unstable.dataAttributes.updateDataAttribute({ +await client.preview.news.updateNewsItem({ id: 1, body: { - "key": "value" + title: "Christmas is here!", + body: "

New gifts in store for the jolly season

", + sender_id: 991267845, + reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"] } }); @@ -17789,7 +25757,7 @@ await client.unstable.dataAttributes.updateDataAttribute({
-**request:** `Intercom.unstable.UpdateDataAttributeRequest` +**request:** `Intercom.preview.UpdateNewsItemRequest`
@@ -17797,7 +25765,7 @@ await client.unstable.dataAttributes.updateDataAttribute({
-**requestOptions:** `DataAttributesClient.RequestOptions` +**requestOptions:** `NewsClient.RequestOptions`
@@ -17809,8 +25777,7 @@ await client.unstable.dataAttributes.updateDataAttribute({
-## Data Events -
client.unstable.dataEvents.lisDataEvents({ ...params }) -> Intercom.DataEventSummary +
client.preview.news.deleteNewsItem({ ...params }) -> Intercom.DeletedObject
@@ -17822,20 +25789,7 @@ await client.unstable.dataAttributes.updateDataAttribute({
- -> 🚧 -> -> Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days - -The events belonging to a customer can be listed by sending a GET request to `https://api.intercom.io/events` with a user or lead identifier along with a `type` parameter. The identifier parameter can be one of `user_id`, `email` or `intercom_user_id`. The `type` parameter value must be `user`. - -- `https://api.intercom.io/events?type=user&user_id={user_id}` -- `https://api.intercom.io/events?type=user&email={email}` -- `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads) - -The `email` parameter value should be [url encoded](http://en.wikipedia.org/wiki/Percent-encoding) when sending. - -You can optionally define the result page size as well with the `per_page` parameter. +You can delete a single news item.
@@ -17850,11 +25804,8 @@ You can optionally define the result page size as well with the `per_page` param
```typescript -await client.unstable.dataEvents.lisDataEvents({ - filter: { - user_id: "user_id" - }, - type: "type" +await client.preview.news.deleteNewsItem({ + id: 1 }); ``` @@ -17871,7 +25822,7 @@ await client.unstable.dataEvents.lisDataEvents({
-**request:** `Intercom.unstable.LisDataEventsRequest` +**request:** `Intercom.preview.DeleteNewsItemRequest`
@@ -17879,7 +25830,7 @@ await client.unstable.dataEvents.lisDataEvents({
-**requestOptions:** `DataEventsClient.RequestOptions` +**requestOptions:** `NewsClient.RequestOptions`
@@ -17891,7 +25842,7 @@ await client.unstable.dataEvents.lisDataEvents({
-
client.unstable.dataEvents.createDataEvent({ ...params }) -> void +
client.preview.news.listLiveNewsfeedItems({ ...params }) -> Intercom.PaginatedResponse
@@ -17903,48 +25854,7 @@ await client.unstable.dataEvents.lisDataEvents({
- -You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a `Content-Type` of `application/json`. - -When using the JavaScript API, [adding the code to your app](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-your-app) makes the Events API available. Once added, you can submit an event using the `trackEvent` method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event. - -With the Ruby client you pass a hash describing the event to `Intercom::Event.create`, or call the `track_user` method directly on the current user object (e.g. `user.track_event`). - -**NB: For the JSON object types, please note that we do not currently support nested JSON structure.** - -| Type | Description | Example | -| :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | -| String | The value is a JSON String | `"source":"desktop"` | -| Number | The value is a JSON Number | `"load": 3.67` | -| Date | The key ends with the String `_date` and the value is a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) timezone. | `"contact_date": 1392036272` | -| Link | The value is a HTTP or HTTPS URI. | `"article": "https://example.org/ab1de.html"` | -| Rich Link | The value is a JSON object that contains `url` and `value` keys. | `"article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"}` | -| Monetary Amount | The value is a JSON object that contains `amount` and `currency` keys. The `amount` key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | `"price": {"amount": 34999, "currency": "eur"}` | - -**Lead Events** - -When submitting events for Leads, you will need to specify the Lead's `id`. - -**Metadata behaviour** - -- We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event. -- It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one. -- There might be up to 24 hrs delay when you send a new metadata for an existing event. - -**Event de-duplication** - -The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is **strongly recommended** to send a second granularity Unix timestamp in the `created_at` field. - -Duplicated events are responded to using the normal `202 Accepted` code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place. - -### HTTP API Responses - -- Successful responses to submitted events return `202 Accepted` with an empty body. -- Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code. -- Events sent about users that cannot be found will return a `404 Not Found`. -- Event lists containing duplicate events will have those duplicates ignored. -- Server errors will return a `500` response code and may contain an error message in the body. - +You can fetch a list of all news items that are live on a given newsfeed
@@ -17959,8 +25869,8 @@ Duplicated events are responded to using the normal `202 Accepted` code - an err
```typescript -await client.unstable.dataEvents.createDataEvent({ - "key": "value" +await client.preview.news.listLiveNewsfeedItems({ + id: "123" }); ``` @@ -17977,7 +25887,7 @@ await client.unstable.dataEvents.createDataEvent({
-**request:** `Intercom.CreateDataEventRequestTwo` +**request:** `Intercom.preview.ListLiveNewsfeedItemsRequest`
@@ -17985,7 +25895,7 @@ await client.unstable.dataEvents.createDataEvent({
-**requestOptions:** `DataEventsClient.RequestOptions` +**requestOptions:** `NewsClient.RequestOptions`
@@ -17997,7 +25907,7 @@ await client.unstable.dataEvents.createDataEvent({
-
client.unstable.dataEvents.dataEventSummaries({ ...params }) -> void +
client.preview.news.listNewsfeeds() -> Intercom.PaginatedResponse
@@ -18009,8 +25919,7 @@ await client.unstable.dataEvents.createDataEvent({
-Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. - +You can fetch a list of all newsfeeds
@@ -18025,7 +25934,7 @@ Create event summaries for a user. Event summaries are used to track the number
```typescript -await client.unstable.dataEvents.dataEventSummaries(); +await client.preview.news.listNewsfeeds(); ```
@@ -18041,15 +25950,7 @@ await client.unstable.dataEvents.dataEventSummaries();
-**request:** `Intercom.unstable.CreateDataEventSummariesRequest` - -
-
- -
-
- -**requestOptions:** `DataEventsClient.RequestOptions` +**requestOptions:** `NewsClient.RequestOptions`
@@ -18061,8 +25962,7 @@ await client.unstable.dataEvents.dataEventSummaries();
-## Data Export -
client.unstable.dataExport.createDataExport({ ...params }) -> Intercom.DataExport +
client.preview.news.retrieveNewsfeed({ ...params }) -> Intercom.Newsfeed
@@ -18074,21 +25974,7 @@ await client.unstable.dataEvents.dataEventSummaries();
-To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. - -The only parameters you need to provide are the range of dates that you want exported. - ->🚧 Limit of one active job -> -> You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job. - ->❗️ Updated_at not included -> -> It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job. - ->📘 Date ranges are inclusive -> -> Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99. +You can fetch the details of a single newsfeed
@@ -18103,9 +25989,8 @@ The only parameters you need to provide are the range of dates that you want exp
```typescript -await client.unstable.dataExport.createDataExport({ - created_at_after: 1734519776, - created_at_before: 1734537776 +await client.preview.news.retrieveNewsfeed({ + id: "123" }); ``` @@ -18122,7 +26007,7 @@ await client.unstable.dataExport.createDataExport({
-**request:** `Intercom.unstable.CreateDataExportsRequest` +**request:** `Intercom.preview.RetrieveNewsfeedRequest`
@@ -18130,7 +26015,7 @@ await client.unstable.dataExport.createDataExport({
-**requestOptions:** `DataExportClient.RequestOptions` +**requestOptions:** `NewsClient.RequestOptions`
@@ -18142,7 +26027,8 @@ await client.unstable.dataExport.createDataExport({
-
client.unstable.dataExport.getDataExport({ ...params }) -> Intercom.DataExport +## Roles +
client.preview.roles.listRoles() -> Intercom.RoleList
@@ -18154,11 +26040,12 @@ await client.unstable.dataExport.createDataExport({
-You can view the status of your job by sending a `GET` request to the URL -`https://api.intercom.io/export/content/data/{job_identifier}` - the `{job_identifier}` is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. +You can fetch a list of all roles in the workspace. -> 🚧 Jobs expire after two days -> All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available. +Roles define what a teammate can do in a workspace. The teammates endpoint +returns the role a teammate holds, but only the roles that are currently +assigned, and only their id and name. This endpoint lists every role in the +workspace, each with its description.
@@ -18173,9 +26060,7 @@ You can view the status of your job by sending a `GET` request to the URL
```typescript -await client.unstable.dataExport.getDataExport({ - job_identifier: "job_identifier" -}); +await client.preview.roles.listRoles(); ```
@@ -18191,15 +26076,7 @@ await client.unstable.dataExport.getDataExport({
-**request:** `Intercom.unstable.GetDataExportRequest` - -
-
- -
-
- -**requestOptions:** `DataExportClient.RequestOptions` +**requestOptions:** `RolesClient.RequestOptions`
@@ -18211,7 +26088,7 @@ await client.unstable.dataExport.getDataExport({
-
client.unstable.dataExport.cancelDataExport({ ...params }) -> Intercom.DataExport +
client.preview.roles.retrieveRole({ ...params }) -> Intercom.Role
@@ -18223,7 +26100,8 @@ await client.unstable.dataExport.getDataExport({
-You can cancel your job +You can fetch the details of a single role by its id, including its +description, which the teammates endpoint does not return.
@@ -18238,8 +26116,8 @@ You can cancel your job
```typescript -await client.unstable.dataExport.cancelDataExport({ - job_identifier: "job_identifier" +await client.preview.roles.retrieveRole({ + id: "991267902" }); ``` @@ -18256,7 +26134,7 @@ await client.unstable.dataExport.cancelDataExport({
-**request:** `Intercom.unstable.CancelDataExportRequest` +**request:** `Intercom.preview.RetrieveRoleRequest`
@@ -18264,7 +26142,7 @@ await client.unstable.dataExport.cancelDataExport({
-**requestOptions:** `DataExportClient.RequestOptions` +**requestOptions:** `RolesClient.RequestOptions`
@@ -18276,7 +26154,8 @@ await client.unstable.dataExport.cancelDataExport({
-
client.unstable.dataExport.downloadDataExport({ ...params }) -> void +## Identity Verification Secrets +
client.preview.identityVerificationSecrets.listIdentityVerificationSecrets() -> Intercom.IdentityVerificationSecretList
@@ -18288,13 +26167,9 @@ await client.unstable.dataExport.cancelDataExport({
-When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. - -Your exported message data will be streamed continuously back down to you in a gzipped CSV format. +Returns the identity verification secrets configured for your workspace. -> 📘 Octet header required -> -> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. +Each entry includes metadata only — the HMAC signing material itself is **never** returned by this endpoint. The raw secret is only available once, in the response to `POST /secure_mode_secrets`. Persist it at that moment.
@@ -18309,9 +26184,7 @@ Your exported message data will be streamed continuously back down to you in a g
```typescript -await client.unstable.dataExport.downloadDataExport({ - job_identifier: "job_identifier" -}); +await client.preview.identityVerificationSecrets.listIdentityVerificationSecrets(); ```
@@ -18327,15 +26200,7 @@ await client.unstable.dataExport.downloadDataExport({
-**request:** `Intercom.unstable.DownloadDataExportRequest` - -
-
- -
-
- -**requestOptions:** `DataExportClient.RequestOptions` +**requestOptions:** `IdentityVerificationSecretsClient.RequestOptions`
@@ -18347,8 +26212,7 @@ await client.unstable.dataExport.downloadDataExport({
-## Workflows -
client.unstable.workflows.exportWorkflow({ ...params }) -> Intercom.WorkflowExport +
client.preview.identityVerificationSecrets.createIdentityVerificationSecret({ ...params }) -> Intercom.IdentityVerificationSecretWithMaterial
@@ -18360,13 +26224,11 @@ await client.unstable.dataExport.downloadDataExport({
-Export a workflow configuration by its ID. This endpoint returns the complete workflow definition including its steps, targeting rules, and attributes. +Creates a new identity verification secret for your workspace. Intercom generates a 256-bit, cryptographically random value server-side and returns it once in the response. -This endpoint is designed for EU Data Act compliance, allowing customers to export their workflow configurations. +**This is the only opportunity to capture the secret.** Store it in your secure configuration immediately. The `secret` field is omitted from all subsequent responses (including `GET /secure_mode_secrets`) — if you lose it, you must rotate a new secret in and delete this one. -{% admonition type="warning" name="Unstable API" %} - This API is currently in the Unstable version. Its behavior may change in future releases. -{% /admonition %} +You must enable the secret for at least one platform (`supports_android`, `supports_ios`, or `supports_web`). Rotation flow: create the new secret, roll it out to every client signing `user_hash` values, then delete the old secret with `DELETE /secure_mode_secrets/{id}` once traffic has cut over.
@@ -18381,8 +26243,9 @@ This endpoint is designed for EU Data Act compliance, allowing customers to expo
```typescript -await client.unstable.workflows.exportWorkflow({ - id: "12345" +await client.preview.identityVerificationSecrets.createIdentityVerificationSecret({ + name: "Production Web", + supports_web: true }); ``` @@ -18399,7 +26262,7 @@ await client.unstable.workflows.exportWorkflow({
-**request:** `Intercom.unstable.ExportWorkflowRequest` +**request:** `Intercom.preview.CreateIdentityVerificationSecretRequest`
@@ -18407,7 +26270,7 @@ await client.unstable.workflows.exportWorkflow({
-**requestOptions:** `WorkflowsClient.RequestOptions` +**requestOptions:** `IdentityVerificationSecretsClient.RequestOptions`
@@ -18419,8 +26282,7 @@ await client.unstable.workflows.exportWorkflow({
-## Jobs -
client.unstable.jobs.status({ ...params }) -> Intercom.Jobs +
client.preview.identityVerificationSecrets.deleteIdentityVerificationSecret({ ...params }) -> void
@@ -18432,7 +26294,7 @@ await client.unstable.workflows.exportWorkflow({
-Retrieve the status of job execution. +Soft-deletes an identity verification secret. After deletion, any `user_hash` values signed with that secret will no longer verify — Messenger sessions depending on it will be rejected on their next request. Use this to complete a rotation: create a new secret, roll it out, then delete the old one.
@@ -18447,8 +26309,8 @@ Retrieve the status of job execution.
```typescript -await client.unstable.jobs.status({ - id: "id" +await client.preview.identityVerificationSecrets.deleteIdentityVerificationSecret({ + id: "102" }); ``` @@ -18465,7 +26327,7 @@ await client.unstable.jobs.status({
-**request:** `Intercom.unstable.JobsStatusRequest` +**request:** `Intercom.preview.DeleteIdentityVerificationSecretRequest`
@@ -18473,7 +26335,7 @@ await client.unstable.jobs.status({
-**requestOptions:** `JobsClient.RequestOptions` +**requestOptions:** `IdentityVerificationSecretsClient.RequestOptions`
@@ -18485,8 +26347,8 @@ await client.unstable.jobs.status({
-## Macros -
client.unstable.macros.listMacros({ ...params }) -> Intercom.MacroList +## Segments +
client.preview.segments.listSegments({ ...params }) -> Intercom.SegmentList
@@ -18498,19 +26360,7 @@ await client.unstable.jobs.status({
-You can fetch a list of all macros (saved replies) in your workspace for use in automating responses. - -The macros are returned in descending order by updated_at. - -**Pagination** - -This endpoint uses cursor-based pagination via the `starting_after` parameter. The cursor is a Base64-encoded JSON array containing `[updated_at, id]` of the last item from the previous page. - -**Placeholder Transformation** - -The API transforms Intercom placeholders to a more standard XML-like format: -- From: `{{user.name | fallback: 'there'}}` -- To: `` +You can fetch a list of all segments.
@@ -18525,10 +26375,8 @@ The API transforms Intercom placeholders to a more standard XML-like format:
```typescript -await client.unstable.macros.listMacros({ - per_page: 1, - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - updated_since: 1000000 +await client.preview.segments.listSegments({ + include_count: true }); ``` @@ -18545,7 +26393,7 @@ await client.unstable.macros.listMacros({
-**request:** `Intercom.unstable.ListMacrosRequest` +**request:** `Intercom.preview.ListSegmentsRequest`
@@ -18553,7 +26401,7 @@ await client.unstable.macros.listMacros({
-**requestOptions:** `MacrosClient.RequestOptions` +**requestOptions:** `SegmentsClient.RequestOptions`
@@ -18565,7 +26413,7 @@ await client.unstable.macros.listMacros({
-
client.unstable.macros.getMacro({ ...params }) -> Intercom.Macro | undefined +
client.preview.segments.retrieveSegment({ ...params }) -> Intercom.Segment
@@ -18577,23 +26425,7 @@ await client.unstable.macros.listMacros({
-You can fetch a single macro (saved reply) by its ID. The macro will only be returned if it is visible to the authenticated user based on its visibility settings. - -**Visibility Rules** - -A macro is returned based on its `visible_to` setting: -- `everyone`: Always visible to all team members -- `specific_teams`: Only visible if the authenticated user belongs to one of the teams specified in `visible_to_team_ids` - -If a macro exists but is not visible to the authenticated user, a 404 error is returned. - -**Placeholder Transformation** - -The API transforms Intercom placeholders to a more standard XML-like format in the `body` field: -- From: `{{user.name | fallback: 'there'}}` -- To: `` - -Default values in placeholders are HTML-escaped for security. +You can fetch the details of a single segment.
@@ -18608,7 +26440,7 @@ Default values in placeholders are HTML-escaped for security.
```typescript -await client.unstable.macros.getMacro({ +await client.preview.segments.retrieveSegment({ id: "123" }); @@ -18626,7 +26458,7 @@ await client.unstable.macros.getMacro({
-**request:** `Intercom.unstable.GetMacroRequest` +**request:** `Intercom.preview.RetrieveSegmentRequest`
@@ -18634,7 +26466,7 @@ await client.unstable.macros.getMacro({
-**requestOptions:** `MacrosClient.RequestOptions` +**requestOptions:** `SegmentsClient.RequestOptions`
@@ -18646,8 +26478,8 @@ await client.unstable.macros.getMacro({
-## Messages -
client.unstable.messages.createMessage({ ...params }) -> Intercom.Message +## Switch +
client.preview.switch.createPhoneSwitch({ ...params }) -> Intercom.PhoneSwitch | undefined
@@ -18659,17 +26491,10 @@ await client.unstable.macros.getMacro({
-You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email, sms or whatsapp. - -> 🚧 Sending for visitors -> -> There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case. - -This will return the Message model that has been created. +You can use the API to deflect phone calls to the Intercom Messenger. +Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. -> 🚧 Retrieving Associated Conversations -> -> As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message. +If custom attributes are specified, they will be added to the user or lead's custom data attributes.
@@ -18684,13 +26509,8 @@ This will return the Message model that has been created.
```typescript -await client.unstable.messages.createMessage({ - "from": { - "type": "user", - "id": "6762f2341bb69f9f2193bc17" - }, - "body": "heyy", - "referer": "https://twitter.com/bob" +await client.preview.switch.createPhoneSwitch({ + "key": "value" }); ``` @@ -18707,7 +26527,7 @@ await client.unstable.messages.createMessage({
-**request:** `Intercom.CreateMessageRequest | undefined` +**request:** `unknown`
@@ -18715,7 +26535,7 @@ await client.unstable.messages.createMessage({
-**requestOptions:** `MessagesClient.RequestOptions` +**requestOptions:** `SwitchClient.RequestOptions`
@@ -18727,7 +26547,8 @@ await client.unstable.messages.createMessage({
-
client.unstable.messages.getWhatsAppMessageStatus({ ...params }) -> Intercom.WhatsappMessageStatusList +## Calls +
client.preview.calls.listCalls({ ...params }) -> Intercom.CallList
@@ -18739,11 +26560,7 @@ await client.unstable.messages.createMessage({
-Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. - - -This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing -information about delivery state and related message details. +Retrieve a paginated list of calls.
@@ -18758,10 +26575,9 @@ information about delivery state and related message details.
```typescript -await client.unstable.messages.getWhatsAppMessageStatus({ - ruleset_id: "ruleset_id", - per_page: 1, - starting_after: "starting_after" +await client.preview.calls.listCalls({ + page: 1, + per_page: 1 }); ``` @@ -18778,7 +26594,7 @@ await client.unstable.messages.getWhatsAppMessageStatus({
-**request:** `Intercom.unstable.GetWhatsAppMessageStatusRequest` +**request:** `Intercom.preview.ListCallsRequest`
@@ -18786,7 +26602,7 @@ await client.unstable.messages.getWhatsAppMessageStatus({
-**requestOptions:** `MessagesClient.RequestOptions` +**requestOptions:** `CallsClient.RequestOptions`
@@ -18798,8 +26614,7 @@ await client.unstable.messages.getWhatsAppMessageStatus({
-## News -
client.unstable.news.listNewsItems() -> Intercom.PaginatedResponse +
client.preview.calls.showCall({ ...params }) -> Intercom.Call
@@ -18811,7 +26626,7 @@ await client.unstable.messages.getWhatsAppMessageStatus({
-You can fetch a list of all news items +Retrieve a single call by id.
@@ -18826,7 +26641,9 @@ You can fetch a list of all news items
```typescript -await client.unstable.news.listNewsItems(); +await client.preview.calls.showCall({ + id: "id" +}); ```
@@ -18842,7 +26659,15 @@ await client.unstable.news.listNewsItems();
-**requestOptions:** `NewsClient.RequestOptions` +**request:** `Intercom.preview.ShowCallRequest` + +
+
+ +
+
+ +**requestOptions:** `CallsClient.RequestOptions`
@@ -18854,7 +26679,7 @@ await client.unstable.news.listNewsItems();
-
client.unstable.news.createNewsItem({ ...params }) -> Intercom.NewsItem +
client.preview.calls.showCallRecording({ ...params }) -> void
@@ -18866,7 +26691,7 @@ await client.unstable.news.listNewsItems();
-You can create a news item +Redirects to a signed URL for the call's recording if it exists.
@@ -18881,18 +26706,8 @@ You can create a news item
```typescript -await client.unstable.news.createNewsItem({ - title: "Halloween is here!", - body: "

New costumes in store for this spooky season

", - sender_id: 991267834, - state: "live", - deliver_silently: true, - labels: ["Product", "Update", "New"], - reactions: ["\uD83D\uDE06", "\uD83D\uDE05"], - newsfeed_assignments: [{ - newsfeed_id: 53, - published_at: 1664638214 - }] +await client.preview.calls.showCallRecording({ + id: "id" }); ``` @@ -18909,7 +26724,7 @@ await client.unstable.news.createNewsItem({
-**request:** `Intercom.NewsItemRequest` +**request:** `Intercom.preview.ShowCallRecordingRequest`
@@ -18917,7 +26732,7 @@ await client.unstable.news.createNewsItem({
-**requestOptions:** `NewsClient.RequestOptions` +**requestOptions:** `CallsClient.RequestOptions`
@@ -18929,7 +26744,7 @@ await client.unstable.news.createNewsItem({
-
client.unstable.news.retrieveNewsItem({ ...params }) -> Intercom.NewsItem +
client.preview.calls.showCallTranscript({ ...params }) -> string
@@ -18941,7 +26756,7 @@ await client.unstable.news.createNewsItem({
-You can fetch the details of a single news item. +Returns the transcript for the specified call as a downloadable text file.
@@ -18956,8 +26771,8 @@ You can fetch the details of a single news item.
```typescript -await client.unstable.news.retrieveNewsItem({ - id: 1 +await client.preview.calls.showCallTranscript({ + id: "id" }); ``` @@ -18974,7 +26789,7 @@ await client.unstable.news.retrieveNewsItem({
-**request:** `Intercom.unstable.RetrieveNewsItemRequest` +**request:** `Intercom.preview.ShowCallTranscriptRequest`
@@ -18982,7 +26797,7 @@ await client.unstable.news.retrieveNewsItem({
-**requestOptions:** `NewsClient.RequestOptions` +**requestOptions:** `CallsClient.RequestOptions`
@@ -18994,10 +26809,25 @@ await client.unstable.news.retrieveNewsItem({
-
client.unstable.news.updateNewsItem({ ...params }) -> Intercom.NewsItem +
client.preview.calls.listCallsWithTranscripts({ ...params }) -> Intercom.ListCallsWithTranscriptsResponse +
+
+ +#### 📝 Description + +
+
+
+Retrieve calls by a list of conversation ids and include transcripts when available. +A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. +
+
+
+
+ #### 🔌 Usage
@@ -19007,14 +26837,8 @@ await client.unstable.news.retrieveNewsItem({
```typescript -await client.unstable.news.updateNewsItem({ - id: 1, - body: { - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"] - } +await client.preview.calls.listCallsWithTranscripts({ + conversation_ids: ["64619700005694", "64619700005695"] }); ``` @@ -19031,7 +26855,7 @@ await client.unstable.news.updateNewsItem({
-**request:** `Intercom.unstable.UpdateNewsItemRequest` +**request:** `Intercom.preview.ListCallsWithTranscriptsRequest`
@@ -19039,7 +26863,7 @@ await client.unstable.news.updateNewsItem({
-**requestOptions:** `NewsClient.RequestOptions` +**requestOptions:** `CallsClient.RequestOptions`
@@ -19051,7 +26875,7 @@ await client.unstable.news.updateNewsItem({
-
client.unstable.news.deleteNewsItem({ ...params }) -> Intercom.DeletedObject +
client.preview.calls.registerFinVoiceCall({ ...params }) -> Intercom.AiCallResponse
@@ -19063,7 +26887,13 @@ await client.unstable.news.updateNewsItem({
-You can delete a single news item. +Register a Fin Voice call with Intercom. This endpoint creates an external reference +that links an external call identifier to an Intercom call and conversation. + +The call can be from different sources: +- AWS Connect (default) +- Five9 +- Zoom Phone
@@ -19078,8 +26908,9 @@ You can delete a single news item.
```typescript -await client.unstable.news.deleteNewsItem({ - id: 1 +await client.preview.calls.registerFinVoiceCall({ + phone_number: "+1234567890", + call_id: "call-123-abc" }); ``` @@ -19096,7 +26927,7 @@ await client.unstable.news.deleteNewsItem({
-**request:** `Intercom.unstable.DeleteNewsItemRequest` +**request:** `Intercom.RegisterFinVoiceCallRequest`
@@ -19104,7 +26935,7 @@ await client.unstable.news.deleteNewsItem({
-**requestOptions:** `NewsClient.RequestOptions` +**requestOptions:** `CallsClient.RequestOptions`
@@ -19116,7 +26947,7 @@ await client.unstable.news.deleteNewsItem({
-
client.unstable.news.listLiveNewsfeedItems({ ...params }) -> Intercom.PaginatedResponse +
client.preview.calls.collectFinVoiceCallById({ ...params }) -> Intercom.AiCallResponse
@@ -19128,7 +26959,7 @@ await client.unstable.news.deleteNewsItem({
-You can fetch a list of all news items that are live on a given newsfeed +Retrieve information about a Fin Voice call using the external reference ID.
@@ -19143,8 +26974,8 @@ You can fetch a list of all news items that are live on a given newsfeed
```typescript -await client.unstable.news.listLiveNewsfeedItems({ - id: "123" +await client.preview.calls.collectFinVoiceCallById({ + id: 1 }); ``` @@ -19161,7 +26992,7 @@ await client.unstable.news.listLiveNewsfeedItems({
-**request:** `Intercom.unstable.ListLiveNewsfeedItemsRequest` +**request:** `Intercom.preview.CollectFinVoiceCallByIdRequest`
@@ -19169,7 +27000,7 @@ await client.unstable.news.listLiveNewsfeedItems({
-**requestOptions:** `NewsClient.RequestOptions` +**requestOptions:** `CallsClient.RequestOptions`
@@ -19181,7 +27012,7 @@ await client.unstable.news.listLiveNewsfeedItems({
-
client.unstable.news.listNewsfeeds() -> Intercom.PaginatedResponse +
client.preview.calls.collectFinVoiceCallByExternalId({ ...params }) -> Intercom.AiCallResponse
@@ -19193,7 +27024,7 @@ await client.unstable.news.listLiveNewsfeedItems({
-You can fetch a list of all newsfeeds +Retrieve information about a Fin Voice call using the external call identifier.
@@ -19208,7 +27039,9 @@ You can fetch a list of all newsfeeds
```typescript -await client.unstable.news.listNewsfeeds(); +await client.preview.calls.collectFinVoiceCallByExternalId({ + external_id: "external_id" +}); ```
@@ -19224,7 +27057,15 @@ await client.unstable.news.listNewsfeeds();
-**requestOptions:** `NewsClient.RequestOptions` +**request:** `Intercom.preview.CollectFinVoiceCallByExternalIdRequest` + +
+
+ +
+
+ +**requestOptions:** `CallsClient.RequestOptions`
@@ -19236,7 +27077,7 @@ await client.unstable.news.listNewsfeeds();
-
client.unstable.news.retrieveNewsfeed({ ...params }) -> Intercom.Newsfeed +
client.preview.calls.collectFinVoiceCallByPhoneNumber({ ...params }) -> Intercom.Error_
@@ -19248,7 +27089,9 @@ await client.unstable.news.listNewsfeeds();
-You can fetch the details of a single newsfeed +Retrieve information about a Fin Voice call using the phone number. + +Returns the most recent matched call for the given phone number, ordered by creation date.
@@ -19263,8 +27106,8 @@ You can fetch the details of a single newsfeed
```typescript -await client.unstable.news.retrieveNewsfeed({ - id: "123" +await client.preview.calls.collectFinVoiceCallByPhoneNumber({ + phone_number: "phone_number" }); ``` @@ -19281,7 +27124,7 @@ await client.unstable.news.retrieveNewsfeed({
-**request:** `Intercom.unstable.RetrieveNewsfeedRequest` +**request:** `Intercom.preview.CollectFinVoiceCallByPhoneNumberRequest`
@@ -19289,7 +27132,7 @@ await client.unstable.news.retrieveNewsfeed({
-**requestOptions:** `NewsClient.RequestOptions` +**requestOptions:** `CallsClient.RequestOptions`
@@ -19301,8 +27144,7 @@ await client.unstable.news.retrieveNewsfeed({
-## Segments -
client.unstable.segments.listSegments({ ...params }) -> Intercom.SegmentList +
client.preview.calls.collectFinVoiceCallsByConversationId({ ...params }) -> Intercom.AiCallResponse[]
@@ -19314,7 +27156,9 @@ await client.unstable.news.retrieveNewsfeed({
-You can fetch a list of all segments. +Retrieve information about Fin Voice calls associated with a conversation. + +Returns all matched calls for the given conversation ID. A conversation may have multiple associated calls.
@@ -19329,8 +27173,8 @@ You can fetch a list of all segments.
```typescript -await client.unstable.segments.listSegments({ - include_count: true +await client.preview.calls.collectFinVoiceCallsByConversationId({ + conversation_id: "conversation_id" }); ``` @@ -19347,7 +27191,7 @@ await client.unstable.segments.listSegments({
-**request:** `Intercom.unstable.ListSegmentsRequest` +**request:** `Intercom.preview.CollectFinVoiceCallsByConversationIdRequest`
@@ -19355,7 +27199,7 @@ await client.unstable.segments.listSegments({
-**requestOptions:** `SegmentsClient.RequestOptions` +**requestOptions:** `CallsClient.RequestOptions`
@@ -19367,7 +27211,8 @@ await client.unstable.segments.listSegments({
-
client.unstable.segments.retrieveSegment({ ...params }) -> Intercom.Segment +## Ticket States +
client.preview.ticketStates.listTicketStates() -> Intercom.TicketStateList
@@ -19379,7 +27224,7 @@ await client.unstable.segments.listSegments({
-You can fetch the details of a single segment. +You can get a list of all ticket states for a workspace.
@@ -19394,9 +27239,7 @@ You can fetch the details of a single segment.
```typescript -await client.unstable.segments.retrieveSegment({ - id: "123" -}); +await client.preview.ticketStates.listTicketStates(); ```
@@ -19412,15 +27255,7 @@ await client.unstable.segments.retrieveSegment({
-**request:** `Intercom.unstable.RetrieveSegmentRequest` - -
-
- -
-
- -**requestOptions:** `SegmentsClient.RequestOptions` +**requestOptions:** `TicketStatesClient.RequestOptions`
@@ -19432,8 +27267,8 @@ await client.unstable.segments.retrieveSegment({
-## Switch -
client.unstable.switch.createPhoneSwitch({ ...params }) -> Intercom.PhoneSwitch | undefined +## Ticket Type Attributes +
client.preview.ticketTypeAttributes.createTicketTypeAttribute({ ...params }) -> Intercom.TicketTypeAttribute | undefined
@@ -19445,10 +27280,7 @@ await client.unstable.segments.retrieveSegment({
-You can use the API to deflect phone calls to the Intercom Messenger. -Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. - -If custom attributes are specified, they will be added to the user or lead's custom data attributes. +You can create a new attribute for a ticket type.
@@ -19463,8 +27295,12 @@ If custom attributes are specified, they will be added to the user or lead's cus
```typescript -await client.unstable.switch.createPhoneSwitch({ - "key": "value" +await client.preview.ticketTypeAttributes.createTicketTypeAttribute({ + ticket_type_id: "ticket_type_id", + name: "Attribute Title", + description: "Attribute Description", + data_type: "string", + required_to_create: false }); ``` @@ -19481,7 +27317,7 @@ await client.unstable.switch.createPhoneSwitch({
-**request:** `unknown` +**request:** `Intercom.preview.CreateTicketTypeAttributeRequest`
@@ -19489,7 +27325,7 @@ await client.unstable.switch.createPhoneSwitch({
-**requestOptions:** `SwitchClient.RequestOptions` +**requestOptions:** `TicketTypeAttributesClient.RequestOptions`
@@ -19501,8 +27337,7 @@ await client.unstable.switch.createPhoneSwitch({
-## Calls -
client.unstable.calls.listCalls({ ...params }) -> Intercom.CallList +
client.preview.ticketTypeAttributes.updateTicketTypeAttribute({ ...params }) -> Intercom.TicketTypeAttribute | undefined
@@ -19514,7 +27349,7 @@ await client.unstable.switch.createPhoneSwitch({
-Retrieve a paginated list of calls. +You can update an existing attribute for a ticket type.
@@ -19529,9 +27364,10 @@ Retrieve a paginated list of calls.
```typescript -await client.unstable.calls.listCalls({ - page: 1, - per_page: 1 +await client.preview.ticketTypeAttributes.updateTicketTypeAttribute({ + ticket_type_id: "ticket_type_id", + id: "id", + description: "New Attribute Description" }); ``` @@ -19548,7 +27384,7 @@ await client.unstable.calls.listCalls({
-**request:** `Intercom.unstable.ListCallsRequest` +**request:** `Intercom.preview.UpdateTicketTypeAttributeRequest`
@@ -19556,7 +27392,7 @@ await client.unstable.calls.listCalls({
-**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketTypeAttributesClient.RequestOptions`
@@ -19568,7 +27404,8 @@ await client.unstable.calls.listCalls({
-
client.unstable.calls.showCall({ ...params }) -> Intercom.Call +## Ticket Types +
client.preview.ticketTypes.listTicketTypes() -> Intercom.TicketTypeList
@@ -19580,7 +27417,7 @@ await client.unstable.calls.listCalls({
-Retrieve a single call by id. +You can get a list of all ticket types for a workspace.
@@ -19595,9 +27432,7 @@ Retrieve a single call by id.
```typescript -await client.unstable.calls.showCall({ - id: "id" -}); +await client.preview.ticketTypes.listTicketTypes(); ```
@@ -19613,15 +27448,7 @@ await client.unstable.calls.showCall({
-**request:** `Intercom.unstable.ShowCallRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketTypesClient.RequestOptions`
@@ -19633,7 +27460,7 @@ await client.unstable.calls.showCall({
-
client.unstable.calls.showCallRecording({ ...params }) -> void +
client.preview.ticketTypes.createTicketType({ ...params }) -> Intercom.TicketType | undefined
@@ -19645,7 +27472,11 @@ await client.unstable.calls.showCall({
-Redirects to a signed URL for the call's recording if it exists. +You can create a new ticket type. +> 📘 Creating ticket types. +> +> Every ticket type will be created with two default attributes: _default_title_ and _default_description_. +> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/)
@@ -19660,8 +27491,8 @@ Redirects to a signed URL for the call's recording if it exists.
```typescript -await client.unstable.calls.showCallRecording({ - id: "id" +await client.preview.ticketTypes.createTicketType({ + "key": "value" }); ``` @@ -19678,7 +27509,7 @@ await client.unstable.calls.showCallRecording({
-**request:** `Intercom.unstable.ShowCallRecordingRequest` +**request:** `unknown`
@@ -19686,7 +27517,7 @@ await client.unstable.calls.showCallRecording({
-**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketTypesClient.RequestOptions`
@@ -19698,7 +27529,7 @@ await client.unstable.calls.showCallRecording({
-
client.unstable.calls.showCallTranscript({ ...params }) -> string +
client.preview.ticketTypes.getTicketType({ ...params }) -> Intercom.TicketType | undefined
@@ -19710,7 +27541,7 @@ await client.unstable.calls.showCallRecording({
-Returns the transcript for the specified call as a downloadable text file. +You can fetch the details of a single ticket type.
@@ -19725,7 +27556,7 @@ Returns the transcript for the specified call as a downloadable text file.
```typescript -await client.unstable.calls.showCallTranscript({ +await client.preview.ticketTypes.getTicketType({ id: "id" }); @@ -19743,7 +27574,7 @@ await client.unstable.calls.showCallTranscript({
-**request:** `Intercom.unstable.ShowCallTranscriptRequest` +**request:** `Intercom.preview.GetTicketTypeRequest`
@@ -19751,7 +27582,7 @@ await client.unstable.calls.showCallTranscript({
-**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketTypesClient.RequestOptions`
@@ -19763,7 +27594,8 @@ await client.unstable.calls.showCallTranscript({
-
client.unstable.calls.listCallsWithTranscripts({ ...params }) -> Intercom.ListCallsWithTranscriptsResponse +## Tickets +
client.preview.tickets.replyTicket({ ...params }) -> Intercom.TicketReply
@@ -19775,8 +27607,7 @@ await client.unstable.calls.showCallTranscript({
-Retrieve calls by a list of conversation ids and include transcripts when available. -A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. +You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins.
@@ -19791,8 +27622,14 @@ A maximum of 20 `conversation_ids` can be provided. If none are provided or more
```typescript -await client.unstable.calls.listCallsWithTranscripts({ - conversation_ids: ["64619700005694", "64619700005695"] +await client.preview.tickets.replyTicket({ + id: "123", + body: { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f2971bb69f9f2193bc49" + } }); ``` @@ -19809,7 +27646,7 @@ await client.unstable.calls.listCallsWithTranscripts({
-**request:** `Intercom.unstable.ListCallsWithTranscriptsRequest` +**request:** `Intercom.preview.ReplyTicketRequest`
@@ -19817,7 +27654,7 @@ await client.unstable.calls.listCallsWithTranscripts({
-**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketsClient.RequestOptions`
@@ -19829,7 +27666,7 @@ await client.unstable.calls.listCallsWithTranscripts({
-
client.unstable.calls.registerFinVoiceCall({ ...params }) -> Intercom.AiCallResponse +
client.preview.tickets.linkConversationToTicket({ ...params }) -> Intercom.Conversation
@@ -19841,13 +27678,18 @@ await client.unstable.calls.listCallsWithTranscripts({
-Register a Fin Voice call with Intercom. This endpoint creates an external reference -that links an external call identifier to an Intercom call and conversation. +Link a conversation to an existing tracker ticket. The conversation can be +a regular conversation or one that has been converted into a customer ticket. -The call can be from different sources: -- AWS Connect (default) -- Five9 -- Zoom Phone +Use this when related conversations surface after a tracker ticket has +already been created. The ticket in the path must be a tracker ticket, and +`conversation_id` in the body is the conversation (or customer ticket) to +link to it. This returns the linked conversation. + +A tracker ticket can have up to 2,500 linked conversations; once that +limit is reached, further requests return `linked_conversation_limit_exceeded`. + +Requires the `write_tickets` OAuth scope.
@@ -19862,9 +27704,9 @@ The call can be from different sources:
```typescript -await client.unstable.calls.registerFinVoiceCall({ - phone_number: "+1234567890", - call_id: "call-123-abc" +await client.preview.tickets.linkConversationToTicket({ + ticket_id: "64619700005694", + conversation_id: "204" }); ``` @@ -19881,7 +27723,7 @@ await client.unstable.calls.registerFinVoiceCall({
-**request:** `Intercom.RegisterFinVoiceCallRequest` +**request:** `Intercom.preview.LinkConversationToTicketRequest`
@@ -19889,7 +27731,7 @@ await client.unstable.calls.registerFinVoiceCall({
-**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketsClient.RequestOptions`
@@ -19901,7 +27743,7 @@ await client.unstable.calls.registerFinVoiceCall({
-
client.unstable.calls.collectFinVoiceCallById({ ...params }) -> Intercom.AiCallResponse +
client.preview.tickets.unlinkConversationFromTicket({ ...params }) -> Intercom.Conversation
@@ -19913,7 +27755,11 @@ await client.unstable.calls.registerFinVoiceCall({
-Retrieve information about a Fin Voice call using the external reference ID. +Unlink a conversation (or converted customer ticket) from a tracker ticket +it is currently linked to. The ticket in the path must be a tracker ticket. +This returns the conversation that was unlinked. + +Requires the `write_tickets` OAuth scope.
@@ -19928,8 +27774,9 @@ Retrieve information about a Fin Voice call using the external reference ID.
```typescript -await client.unstable.calls.collectFinVoiceCallById({ - id: 1 +await client.preview.tickets.unlinkConversationFromTicket({ + ticket_id: "64619700005694", + id: "204" }); ``` @@ -19946,7 +27793,7 @@ await client.unstable.calls.collectFinVoiceCallById({
-**request:** `Intercom.unstable.CollectFinVoiceCallByIdRequest` +**request:** `Intercom.preview.UnlinkConversationFromTicketRequest`
@@ -19954,7 +27801,7 @@ await client.unstable.calls.collectFinVoiceCallById({
-**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketsClient.RequestOptions`
@@ -19966,7 +27813,7 @@ await client.unstable.calls.collectFinVoiceCallById({
-
client.unstable.calls.collectFinVoiceCallByExternalId({ ...params }) -> Intercom.AiCallResponse +
client.preview.tickets.enqueueCreateTicket({ ...params }) -> Intercom.Jobs
@@ -19978,7 +27825,7 @@ await client.unstable.calls.collectFinVoiceCallById({
-Retrieve information about a Fin Voice call using the external call identifier. +Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job.
@@ -19993,8 +27840,11 @@ Retrieve information about a Fin Voice call using the external call identifier.
```typescript -await client.unstable.calls.collectFinVoiceCallByExternalId({ - external_id: "external_id" +await client.preview.tickets.enqueueCreateTicket({ + ticket_type_id: "1234", + contacts: [{ + id: "6762f2d81bb69f9f2193bc54" + }] }); ``` @@ -20011,7 +27861,7 @@ await client.unstable.calls.collectFinVoiceCallByExternalId({
-**request:** `Intercom.unstable.CollectFinVoiceCallByExternalIdRequest` +**request:** `Intercom.preview.EnqueueCreateTicketRequest`
@@ -20019,7 +27869,7 @@ await client.unstable.calls.collectFinVoiceCallByExternalId({
-**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketsClient.RequestOptions`
@@ -20031,7 +27881,7 @@ await client.unstable.calls.collectFinVoiceCallByExternalId({
-
client.unstable.calls.collectFinVoiceCallByPhoneNumber({ ...params }) -> Intercom.Error_ +
client.preview.tickets.getTicket({ ...params }) -> Intercom.Ticket | undefined
@@ -20043,9 +27893,7 @@ await client.unstable.calls.collectFinVoiceCallByExternalId({
-Retrieve information about a Fin Voice call using the phone number. - -Returns the most recent matched call for the given phone number, ordered by creation date. +You can fetch the details of a single ticket.
@@ -20060,8 +27908,8 @@ Returns the most recent matched call for the given phone number, ordered by crea
```typescript -await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ - phone_number: "phone_number" +await client.preview.tickets.getTicket({ + id: "id" }); ``` @@ -20078,7 +27926,7 @@ await client.unstable.calls.collectFinVoiceCallByPhoneNumber({
-**request:** `Intercom.unstable.CollectFinVoiceCallByPhoneNumberRequest` +**request:** `Intercom.preview.GetTicketRequest`
@@ -20086,7 +27934,7 @@ await client.unstable.calls.collectFinVoiceCallByPhoneNumber({
-**requestOptions:** `CallsClient.RequestOptions` +**requestOptions:** `TicketsClient.RequestOptions`
@@ -20098,8 +27946,7 @@ await client.unstable.calls.collectFinVoiceCallByPhoneNumber({
-## Teams -
client.unstable.teams.listTeams() -> Intercom.TeamList +
client.preview.tickets.updateTicket({ ...params }) -> Intercom.Ticket | undefined
@@ -20111,7 +27958,7 @@ await client.unstable.calls.collectFinVoiceCallByPhoneNumber({
-This will return a list of team objects for the App. +You can update a ticket.
@@ -20126,7 +27973,19 @@ This will return a list of team objects for the App.
```typescript -await client.unstable.teams.listTeams(); +await client.preview.tickets.updateTicket({ + id: "id", + ticket_attributes: { + "_default_title_": "example", + "_default_description_": "there is a problem" + }, + ticket_state_id: "123", + open: true, + snoozed_until: 1673609604, + admin_id: 991268011, + assignee_id: "123", + priority: "high" +}); ```
@@ -20142,7 +28001,15 @@ await client.unstable.teams.listTeams();
-**requestOptions:** `TeamsClient.RequestOptions` +**request:** `Intercom.preview.UpdateTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `TicketsClient.RequestOptions`
@@ -20154,7 +28021,7 @@ await client.unstable.teams.listTeams();
-
client.unstable.teams.retrieveTeam({ ...params }) -> Intercom.Team +
client.preview.tickets.deleteTicket({ ...params }) -> Intercom.TicketDeleted
@@ -20166,7 +28033,11 @@ await client.unstable.teams.listTeams();
-You can fetch the details of a single team, containing an array of admins that belong to this team. +{% admonition type="warning" name="Irreversible operation" %} +Deleting a ticket is permanent and cannot be reversed. +{% /admonition %} + +Deleting a ticket permanently removes it from the inbox. All sensitive data is deleted, including admin and user replies, ticket attributes, uploads, and related content. The ticket will still appear in reporting, though some data may be incomplete due to the deletion.
@@ -20181,8 +28052,8 @@ You can fetch the details of a single team, containing an array of admins that b
```typescript -await client.unstable.teams.retrieveTeam({ - id: "123" +await client.preview.tickets.deleteTicket({ + id: "id" }); ``` @@ -20199,7 +28070,7 @@ await client.unstable.teams.retrieveTeam({
-**request:** `Intercom.unstable.RetrieveTeamRequest` +**request:** `Intercom.preview.DeleteTicketRequest`
@@ -20207,7 +28078,7 @@ await client.unstable.teams.retrieveTeam({
-**requestOptions:** `TeamsClient.RequestOptions` +**requestOptions:** `TicketsClient.RequestOptions`
@@ -20219,8 +28090,7 @@ await client.unstable.teams.retrieveTeam({
-## Ticket States -
client.unstable.ticketStates.listTicketStates() -> Intercom.TicketStateList +
client.preview.tickets.changeTicketType({ ...params }) -> Intercom.Ticket | undefined
@@ -20232,7 +28102,7 @@ await client.unstable.teams.retrieveTeam({
-You can get a list of all ticket states for a workspace. +You can change the type of a ticket. The new ticket type must be in the same category as the current type. Attributes matching by name and type are automatically transferred from the old type; values provided in ticket_attributes override transferred values.
@@ -20247,7 +28117,11 @@ You can get a list of all ticket states for a workspace.
```typescript -await client.unstable.ticketStates.listTicketStates(); +await client.preview.tickets.changeTicketType({ + ticket_id: "ticket_id", + ticket_type_id: "1234", + ticket_state_id: "5678" +}); ```
@@ -20263,7 +28137,15 @@ await client.unstable.ticketStates.listTicketStates();
-**requestOptions:** `TicketStatesClient.RequestOptions` +**request:** `Intercom.preview.ChangeTicketTypeRequest` + +
+
+ +
+
+ +**requestOptions:** `TicketsClient.RequestOptions`
@@ -20275,8 +28157,7 @@ await client.unstable.ticketStates.listTicketStates();
-## Ticket Type Attributes -
client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ ...params }) -> Intercom.TicketTypeAttribute | undefined +
client.preview.tickets.searchTickets({ ...params }) -> Intercom.TicketList
@@ -20288,7 +28169,75 @@ await client.unstable.ticketStates.listTicketStates();
-You can create a new attribute for a ticket type. +You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + +To search for tickets, you send a `POST` request to `https://api.intercom.io/tickets/search`. + +This will accept a query object in the body which will define your filters. +{% admonition type="warning" name="Optimizing search queries" %} + Search queries can be complex, so optimizing them can help the performance of your search. + Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + pagination to limit the number of results returned. The default is `20` results per page. + See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiples there can be: +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). +The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + +| Field | Type | +| :---------------------------------------- | :--------------------------------------------------------------------------------------- | +| id | String | +| created_at | Date (UNIX timestamp) | +| updated_at | Date (UNIX timestamp) | +| title | String | +| description | String | +| category | String | +| ticket_type_id | String | +| contact_ids | String | +| teammate_ids | String | +| admin_assignee_id | Integer | +| team_assignee_id | Integer | +| open | Boolean | +| state | String | +| snoozed_until | Date (UNIX timestamp) | +| ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | + +{% admonition type="info" name="Searching by Category" %} +When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: +* For **Customer** category tickets, use the term `request`. +* For **Back-office** category tickets, use the term `task`. +* For **Tracker** category tickets, use the term `tracker`. +{% /admonition %} + +### Accepted Operators + +{% admonition type="info" name="Searching based on `created_at`" %} + You may use the `<=` or `>=` operators to search by `created_at`. +{% /admonition %} + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :----------------------------- | :----------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In Shortcut for `OR` queries Values most be in Array | +| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | +| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | +| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With |
@@ -20303,12 +28252,18 @@ You can create a new attribute for a ticket type.
```typescript -await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ - ticket_type_id: "ticket_type_id", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - required_to_create: false +await client.preview.tickets.searchTickets({ + query: { + operator: "AND", + value: [{ + field: "created_at", + operator: ">", + value: "1306054154" + }] + }, + pagination: { + per_page: 5 + } }); ``` @@ -20325,7 +28280,7 @@ await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({
-**request:** `Intercom.unstable.CreateTicketTypeAttributeRequest` +**request:** `Intercom.SearchRequest`
@@ -20333,7 +28288,7 @@ await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({
-**requestOptions:** `TicketTypeAttributesClient.RequestOptions` +**requestOptions:** `TicketsClient.RequestOptions`
@@ -20345,7 +28300,8 @@ await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({
-
client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ ...params }) -> Intercom.TicketTypeAttribute | undefined +## Visitors +
client.preview.visitors.retrieveVisitorWithUserId({ ...params }) -> Intercom.Visitor | undefined
@@ -20357,7 +28313,7 @@ await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({
-You can update an existing attribute for a ticket type. +You can fetch the details of a single visitor.
@@ -20372,10 +28328,8 @@ You can update an existing attribute for a ticket type.
```typescript -await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ - ticket_type_id: "ticket_type_id", - id: "id", - description: "New Attribute Description" +await client.preview.visitors.retrieveVisitorWithUserId({ + user_id: "user_id" }); ``` @@ -20392,7 +28346,7 @@ await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({
-**request:** `Intercom.unstable.UpdateTicketTypeAttributeRequest` +**request:** `Intercom.preview.RetrieveVisitorWithUserIdRequest`
@@ -20400,7 +28354,7 @@ await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({
-**requestOptions:** `TicketTypeAttributesClient.RequestOptions` +**requestOptions:** `VisitorsClient.RequestOptions`
@@ -20412,8 +28366,7 @@ await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({
-## Ticket Types -
client.unstable.ticketTypes.listTicketTypes() -> Intercom.TicketTypeList +
client.preview.visitors.updateVisitor({ ...params }) -> Intercom.Visitor | undefined
@@ -20425,7 +28378,11 @@ await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({
-You can get a list of all ticket types for a workspace. +Sending a PUT request to `/visitors` will result in an update of an existing Visitor. + +**Option 1.** You can update a visitor by passing in the `user_id` of the visitor in the Request body. + +**Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body.
@@ -20440,7 +28397,10 @@ You can get a list of all ticket types for a workspace.
```typescript -await client.unstable.ticketTypes.listTicketTypes(); +await client.preview.visitors.updateVisitor({ + "id": "6762f30c1bb69f9f2193bc5e", + "name": "Gareth Bale" +}); ```
@@ -20456,7 +28416,15 @@ await client.unstable.ticketTypes.listTicketTypes();
-**requestOptions:** `TicketTypesClient.RequestOptions` +**request:** `Intercom.UpdateVisitorRequestOne` + +
+
+ +
+
+ +**requestOptions:** `VisitorsClient.RequestOptions`
@@ -20468,7 +28436,7 @@ await client.unstable.ticketTypes.listTicketTypes();
-
client.unstable.ticketTypes.createTicketType({ ...params }) -> Intercom.TicketType | undefined +
client.preview.visitors.convertVisitor({ ...params }) -> Intercom.Contact
@@ -20480,11 +28448,11 @@ await client.unstable.ticketTypes.listTicketTypes();
-You can create a new ticket type. -> 📘 Creating ticket types. +You can merge a Visitor to a Contact of role type `lead` or `user`. + +> 📘 What happens upon a visitor being converted? > -> Every ticket type will be created with two default attributes: _default_title_ and _default_description_. -> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) +> If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers.
@@ -20499,8 +28467,14 @@ You can create a new ticket type.
```typescript -await client.unstable.ticketTypes.createTicketType({ - "key": "value" +await client.preview.visitors.convertVisitor({ + type: "user", + user: { + "email": "foo@bar.com" + }, + visitor: { + "user_id": "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" + } }); ``` @@ -20517,7 +28491,7 @@ await client.unstable.ticketTypes.createTicketType({
-**request:** `unknown` +**request:** `Intercom.preview.ConvertVisitorRequest`
@@ -20525,7 +28499,7 @@ await client.unstable.ticketTypes.createTicketType({
-**requestOptions:** `TicketTypesClient.RequestOptions` +**requestOptions:** `VisitorsClient.RequestOptions`
@@ -20537,7 +28511,8 @@ await client.unstable.ticketTypes.createTicketType({
-
client.unstable.ticketTypes.getTicketType({ ...params }) -> Intercom.TicketType | undefined +## Brands +
client.preview.brands.listBrands() -> Intercom.BrandList
@@ -20549,7 +28524,8 @@ await client.unstable.ticketTypes.createTicketType({
-You can fetch the details of a single ticket type. +Retrieves all brands for the workspace, including the default brand. +The default brand id always matches the workspace
@@ -20564,9 +28540,7 @@ You can fetch the details of a single ticket type.
```typescript -await client.unstable.ticketTypes.getTicketType({ - id: "id" -}); +await client.preview.brands.listBrands(); ```
@@ -20582,15 +28556,7 @@ await client.unstable.ticketTypes.getTicketType({
-**request:** `Intercom.unstable.GetTicketTypeRequest` - -
-
- -
-
- -**requestOptions:** `TicketTypesClient.RequestOptions` +**requestOptions:** `BrandsClient.RequestOptions`
@@ -20602,8 +28568,7 @@ await client.unstable.ticketTypes.getTicketType({
-## Tickets -
client.unstable.tickets.replyTicket({ ...params }) -> Intercom.TicketReply +
client.preview.brands.retrieveBrand({ ...params }) -> Intercom.Brand
@@ -20615,7 +28580,7 @@ await client.unstable.ticketTypes.getTicketType({
-You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. +Fetches a specific brand by its unique identifier
@@ -20630,14 +28595,8 @@ You can reply to a ticket with a message from an admin or on behalf of a contact
```typescript -await client.unstable.tickets.replyTicket({ - id: "123", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49" - } +await client.preview.brands.retrieveBrand({ + id: "id" }); ``` @@ -20654,7 +28613,7 @@ await client.unstable.tickets.replyTicket({
-**request:** `Intercom.unstable.ReplyTicketRequest` +**request:** `Intercom.preview.RetrieveBrandRequest`
@@ -20662,7 +28621,7 @@ await client.unstable.tickets.replyTicket({
-**requestOptions:** `TicketsClient.RequestOptions` +**requestOptions:** `BrandsClient.RequestOptions`
@@ -20674,7 +28633,8 @@ await client.unstable.tickets.replyTicket({
-
client.unstable.tickets.enqueueCreateTicket({ ...params }) -> Intercom.Jobs +## Emails +
client.preview.emails.listEmails() -> Intercom.EmailList
@@ -20686,7 +28646,7 @@ await client.unstable.tickets.replyTicket({
-Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. +Lists all sender email address settings for the workspace
@@ -20701,12 +28661,7 @@ Enqueues ticket creation for asynchronous processing, returning if the job was e
```typescript -await client.unstable.tickets.enqueueCreateTicket({ - ticket_type_id: "1234", - contacts: [{ - id: "6762f2d81bb69f9f2193bc54" - }] -}); +await client.preview.emails.listEmails(); ```
@@ -20722,15 +28677,7 @@ await client.unstable.tickets.enqueueCreateTicket({
-**request:** `Intercom.unstable.EnqueueCreateTicketRequest` - -
-
- -
-
- -**requestOptions:** `TicketsClient.RequestOptions` +**requestOptions:** `EmailsClient.RequestOptions`
@@ -20742,7 +28689,7 @@ await client.unstable.tickets.enqueueCreateTicket({
-
client.unstable.tickets.getTicket({ ...params }) -> Intercom.Ticket | undefined +
client.preview.emails.retrieveEmail({ ...params }) -> Intercom.EmailSetting
@@ -20754,7 +28701,7 @@ await client.unstable.tickets.enqueueCreateTicket({
-You can fetch the details of a single ticket. +Fetches a specific email setting by its unique identifier
@@ -20769,7 +28716,7 @@ You can fetch the details of a single ticket.
```typescript -await client.unstable.tickets.getTicket({ +await client.preview.emails.retrieveEmail({ id: "id" }); @@ -20787,7 +28734,7 @@ await client.unstable.tickets.getTicket({
-**request:** `Intercom.unstable.GetTicketRequest` +**request:** `Intercom.preview.RetrieveEmailRequest`
@@ -20795,7 +28742,7 @@ await client.unstable.tickets.getTicket({
-**requestOptions:** `TicketsClient.RequestOptions` +**requestOptions:** `EmailsClient.RequestOptions`
@@ -20807,7 +28754,8 @@ await client.unstable.tickets.getTicket({
-
client.unstable.tickets.updateTicket({ ...params }) -> Intercom.Ticket | undefined +## Fin Agent +
client.preview.finAgent.listFinCapabilities({ ...params }) -> Intercom.ListFinCapabilitiesResponse
@@ -20819,7 +28767,12 @@ await client.unstable.tickets.getTicket({
-You can update a ticket. +Return a machine-readable, per-user list of what Fin can do for a given end user, so an +orchestrating agent can decide which endpoint to call. + +The response is audience-matched to the supplied user: each live, API-triggerable +procedure is checked against that user before being included, alongside the static +`reply` and `ask` actions.
@@ -20834,17 +28787,10 @@ You can update a ticket.
```typescript -await client.unstable.tickets.updateTicket({ - id: "id", - ticket_attributes: { - "_default_title_": "example", - "_default_description_": "there is a problem" - }, - ticket_state_id: "123", - open: true, - snoozed_until: 1673609604, - admin_id: 991268011, - assignee_id: "123" +await client.preview.finAgent.listFinCapabilities({ + user: { + id: "123456" + } }); ``` @@ -20861,7 +28807,7 @@ await client.unstable.tickets.updateTicket({
-**request:** `Intercom.unstable.UpdateTicketRequest` +**request:** `Intercom.preview.ListFinCapabilitiesRequest`
@@ -20869,7 +28815,7 @@ await client.unstable.tickets.updateTicket({
-**requestOptions:** `TicketsClient.RequestOptions` +**requestOptions:** `FinAgentClient.RequestOptions`
@@ -20881,7 +28827,7 @@ await client.unstable.tickets.updateTicket({
-
client.unstable.tickets.deleteTicket({ ...params }) -> Intercom.DeleteTicketResponse +
client.preview.finAgent.askFin({ ...params }) -> Intercom.AskFinResponse
@@ -20893,7 +28839,16 @@ await client.unstable.tickets.updateTicket({
-You can delete a ticket using the Intercom provided ID. +Ask Fin a single, self-contained question and receive one informational answer. + +Unlike a conversation, `/fin/ask` is non-conversational: Fin will not ask follow-up +questions, will not run procedures, and will not escalate to a human on its own. You can +still escalate one yourself with `POST /fin/escalate`; the ask conversation is already +closed after its one-shot answer, and escalation leaves it closed while routing the +handoff separately. + +Fin's answer is delivered asynchronously via the `fin_replied` event. The conversation +ends with a `complete` status — there is no `awaiting_user_reply` cycle.
@@ -20908,8 +28863,18 @@ You can delete a ticket using the Intercom provided ID.
```typescript -await client.unstable.tickets.deleteTicket({ - id: "id" +await client.preview.finAgent.askFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How do I reset my password?", + timestamp: "2025-01-24T10:01:20Z" + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com" + } }); ``` @@ -20926,7 +28891,7 @@ await client.unstable.tickets.deleteTicket({
-**request:** `Intercom.unstable.DeleteTicketRequest` +**request:** `Intercom.preview.AskFinRequest`
@@ -20934,7 +28899,7 @@ await client.unstable.tickets.deleteTicket({
-**requestOptions:** `TicketsClient.RequestOptions` +**requestOptions:** `FinAgentClient.RequestOptions`
@@ -20946,7 +28911,7 @@ await client.unstable.tickets.deleteTicket({
-
client.unstable.tickets.searchTickets({ ...params }) -> Intercom.TicketList +
client.preview.finAgent.replyToFin({ ...params }) -> Intercom.ReplyToFinResponse
@@ -20958,75 +28923,9 @@ await client.unstable.tickets.deleteTicket({
-You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. - -To search for tickets, you send a `POST` request to `https://api.intercom.io/tickets/search`. - -This will accept a query object in the body which will define your filters. -{% admonition type="warning" name="Optimizing search queries" %} - Search queries can be complex, so optimizing them can help the performance of your search. - Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize - pagination to limit the number of results returned. The default is `20` results per page. - See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. -{% /admonition %} - -### Nesting & Limitations - -You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). -There are some limitations to the amount of multiples there can be: -- There's a limit of max 2 nested filters -- There's a limit of max 15 filters for each AND or OR group - -### Accepted Fields - -Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). -The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. - -| Field | Type | -| :---------------------------------------- | :--------------------------------------------------------------------------------------- | -| id | String | -| created_at | Date (UNIX timestamp) | -| updated_at | Date (UNIX timestamp) | -| title | String | -| description | String | -| category | String | -| ticket_type_id | String | -| contact_ids | String | -| teammate_ids | String | -| admin_assignee_id | String | -| team_assignee_id | String | -| open | Boolean | -| state | String | -| snoozed_until | Date (UNIX timestamp) | -| ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | - -{% admonition type="info" name="Searching by Category" %} -When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: -* For **Customer** category tickets, use the term `request`. -* For **Back-office** category tickets, use the term `task`. -* For **Tracker** category tickets, use the term `tracker`. -{% /admonition %} - -### Accepted Operators - -{% admonition type="info" name="Searching based on `created_at`" %} - You may use the `<=` or `>=` operators to search by `created_at`. -{% /admonition %} - -The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). - -| Operator | Valid Types | Description | -| :------- | :----------------------------- | :----------------------------------------------------------- | -| = | All | Equals | -| != | All | Doesn't Equal | -| IN | All | In Shortcut for `OR` queries Values most be in Array | -| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | -| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | -| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | -| ~ | String | Contains | -| !~ | String | Doesn't Contain | -| ^ | String | Starts With | -| $ | String | Ends With | +Send a follow-up message in an existing conversation. When Fin needs more information to +complete an action, it sets the conversation to `awaiting_user_reply` — send the user's +response so Fin can continue.
@@ -21041,17 +28940,17 @@ The table below shows the operators you can use to define how you want to search
```typescript -await client.unstable.tickets.searchTickets({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] +await client.preview.finAgent.replyToFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z" }, - pagination: { - per_page: 5 + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com" } }); @@ -21069,7 +28968,7 @@ await client.unstable.tickets.searchTickets({
-**request:** `Intercom.SearchRequest` +**request:** `Intercom.preview.ReplyToFinRequest`
@@ -21077,7 +28976,7 @@ await client.unstable.tickets.searchTickets({
-**requestOptions:** `TicketsClient.RequestOptions` +**requestOptions:** `FinAgentClient.RequestOptions`
@@ -21089,8 +28988,7 @@ await client.unstable.tickets.searchTickets({
-## Visitors -
client.unstable.visitors.retrieveVisitorWithUserId({ ...params }) -> Intercom.Visitor | undefined +
client.preview.finAgent.runFinProcedure({ ...params }) -> Intercom.RunFinProcedureResponse
@@ -21102,7 +29000,12 @@ await client.unstable.tickets.searchTickets({
-You can fetch the details of a single visitor. +Deterministically run a specific procedure on a new conversation. Calling this endpoint +guarantees that the named procedure runs — there is no non-deterministic routing. + +Fin's progress is delivered asynchronously via events or Server-Sent Events. If the +procedure pauses for user input, the conversation status becomes `awaiting_user_reply` — +send the user's response with [`/fin/reply`](/docs/references/preview/rest-api/api.intercom.io/fin-agent/replytofin).
@@ -21117,8 +29020,14 @@ You can fetch the details of a single visitor.
```typescript -await client.unstable.visitors.retrieveVisitorWithUserId({ - user_id: "user_id" +await client.preview.finAgent.runFinProcedure({ + procedure_id: "12345", + conversation_id: "ext-123", + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com" + } }); ``` @@ -21135,7 +29044,7 @@ await client.unstable.visitors.retrieveVisitorWithUserId({
-**request:** `Intercom.unstable.RetrieveVisitorWithUserIdRequest` +**request:** `Intercom.preview.RunFinProcedureRequest`
@@ -21143,7 +29052,7 @@ await client.unstable.visitors.retrieveVisitorWithUserId({
-**requestOptions:** `VisitorsClient.RequestOptions` +**requestOptions:** `FinAgentClient.RequestOptions`
@@ -21155,7 +29064,7 @@ await client.unstable.visitors.retrieveVisitorWithUserId({
-
client.unstable.visitors.updateVisitor({ ...params }) -> Intercom.Visitor | undefined +
client.preview.finAgent.escalateFinConversation({ ...params }) -> Intercom.EscalateFinConversationResponse
@@ -21167,11 +29076,39 @@ await client.unstable.visitors.retrieveVisitorWithUserId({
-Sending a PUT request to `/visitors` will result in an update of an existing Visitor. +Hand a conversation off to a human teammate. If you use the Intercom Helpdesk, the +handoff lands in your team inbox. -**Option 1.** You can update a visitor by passing in the `user_id` of the visitor in the Request body. +Provide either `conversation_id` or `user`: -**Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. +- `conversation_id` — escalate an existing agent conversation, including one started + with `/fin/ask`. On the Intercom Helpdesk, Fin by default summarises the conversation + and opens a new Helpdesk conversation that carries the summary as an internal note. + Escalation does not change the original agent conversation's assignment or open/closed + state. Configure an escalation Operator Workflow to change this default. +- `user` — escalate on behalf of a user with no prior agent conversation. On the Intercom + Helpdesk, a new Helpdesk conversation is created for the teammate. Not supported on Fin + for Platforms — see below. + +In both cases, pass the optional `context` to give the receiving teammate background your +orchestrating agent has and Fin does not. On the Intercom Helpdesk, it appears above the +summary in the internal note of the new conversation the teammate picks up. It is never +shown to the end user. + +Escalating an existing conversation also sets its AI Agent resolution state to +`escalated`, readable as `ai_agent.resolution_state` on the Conversations API. This is a +resolution state, not a billable resolution. + +On Fin for Platforms, `conversation_id` is required — `user` is not supported and is +rejected, because there is no Intercom Helpdesk in which to create a conversation. There +is no Intercom inbox either, so an escalation that no workflow handles does not open a +Helpdesk conversation for a teammate. `context` is not surfaced, and the conversation is +left open for your platform to hand off and continue driving. + +You are notified over the existing webhook or SSE channel with an `escalated` status +followed by `complete`. The `complete` status signals that Fin is done; it does not close +the conversation. On the Intercom Helpdesk, the new human conversation remains open; on +Fin for Platforms, the conversation remains open for whoever handles it on your platform.
@@ -21186,9 +29123,9 @@ Sending a PUT request to `/visitors` will result in an update of an existing Vis
```typescript -await client.unstable.visitors.updateVisitor({ - "id": "6762f30c1bb69f9f2193bc5e", - "name": "Gareth Bale" +await client.preview.finAgent.escalateFinConversation({ + "conversation_id": "ext-123", + "context": "Customer is requesting a refund and is frustrated." }); ``` @@ -21205,7 +29142,7 @@ await client.unstable.visitors.updateVisitor({
-**request:** `Intercom.UpdateVisitorRequestOne` +**request:** `unknown`
@@ -21213,7 +29150,7 @@ await client.unstable.visitors.updateVisitor({
-**requestOptions:** `VisitorsClient.RequestOptions` +**requestOptions:** `FinAgentClient.RequestOptions`
@@ -21225,7 +29162,7 @@ await client.unstable.visitors.updateVisitor({
-
client.unstable.visitors.convertVisitor({ ...params }) -> Intercom.Contact +
client.preview.finAgent.submitFinCsat({ ...params }) -> Intercom.SubmitFinCsatResponse
@@ -21237,11 +29174,19 @@ await client.unstable.visitors.updateVisitor({
-You can merge a Visitor to a Contact of role type `lead` or `user`. +Record a customer's satisfaction rating for a conversation, with an optional free-text +remark. -> 📘 What happens upon a visitor being converted? -> -> If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers. +Fin decides *when* to ask for a rating — this reuses the CSAT settings on your Fin +workflow, not this API. When Fin asks, it fires a `csat_requested` event over webhooks or +SSE carrying the rating options to show the user. Present those options, then submit the +user's choice here. + +Submitting the same rating again, with no new remark, is a no-op and stays successful, +so an at-least-once client can safely retry. Submitting a *different* rating updates the +stored rating while the update window is still open, and a first remark can be added to +an already-rated survey. Once a remark has been recorded the rating is locked and can no +longer be changed.
@@ -21256,14 +29201,9 @@ You can merge a Visitor to a Contact of role type `lead` or `user`.
```typescript -await client.unstable.visitors.convertVisitor({ - type: "user", - user: { - "email": "foo@bar.com" - }, - visitor: { - "user_id": "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" - } +await client.preview.finAgent.submitFinCsat({ + conversation_id: "ext-123", + rating: "amazing" }); ``` @@ -21280,7 +29220,7 @@ await client.unstable.visitors.convertVisitor({
-**request:** `Intercom.unstable.ConvertVisitorRequest` +**request:** `Intercom.preview.SubmitFinCsatRequest`
@@ -21288,7 +29228,7 @@ await client.unstable.visitors.convertVisitor({
-**requestOptions:** `VisitorsClient.RequestOptions` +**requestOptions:** `FinAgentClient.RequestOptions`
@@ -21300,8 +29240,7 @@ await client.unstable.visitors.convertVisitor({
-## Brands -
client.unstable.brands.listBrands() -> Intercom.BrandList +
client.preview.finAgent.startFinConversation({ ...params }) -> Intercom.StartFinConversationResponse
@@ -21313,8 +29252,19 @@ await client.unstable.visitors.convertVisitor({
-Retrieves all brands for the workspace, including the default brand. -The default brand id always matches the workspace +{% admonition type="info" name="Legacy — conversational mode" %} +`/fin/start` powers the conversational model, where your own UI drives a back-and-forth with Fin. This endpoint is no longer actively developed and is maintained only for existing integrations — new functionality lands on the orchestration endpoints. +{% /admonition %} + +Initialize Fin by passing it the user's message along with conversation history and user details. + +These additional pieces of context will be used by Fin to provide a better and more contextual answer to the user. + +Once Fin is initialized, it progresses through a series of statuses such as *thinking*, *replying*, *awaiting_user_reply*, or *resolved* before ending with a status of *complete*. + +During this workflow, the client should allow Fin to continue uninterrupted until a final *complete* status is returned, at which point control of the conversation passes back to the client. + +Events can be received via webhooks or Server-Sent Events (SSE) using the `sse_subscription_url` in the response.
@@ -21329,7 +29279,19 @@ The default brand id always matches the workspace
```typescript -await client.unstable.brands.listBrands(); +await client.preview.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z" + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com" + } +}); ```
@@ -21345,7 +29307,15 @@ await client.unstable.brands.listBrands();
-**requestOptions:** `BrandsClient.RequestOptions` +**request:** `Intercom.preview.StartFinConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `FinAgentClient.RequestOptions`
@@ -21357,7 +29327,8 @@ await client.unstable.brands.listBrands();
-
client.unstable.brands.retrieveBrand({ ...params }) -> Intercom.Brand +## Procedures +
client.preview.procedures.collectProcedureAgentInput({ ...params }) -> Record
@@ -21369,7 +29340,19 @@ await client.unstable.brands.listBrands();
-Fetches a specific brand by its unique identifier +Submit human-collected input to a Fin Procedure that is paused at a Human in the Loop (HITL) step. + +When a procedure reaches a HITL step with the API channel enabled, Intercom sends a `procedure.hitl_notification.created` webhook. Use the `callback_url` from that webhook payload to call this endpoint with the collected attribute values. + +The `step_id` must match the one from the webhook payload, and `attribute_values` must include a value for every attribute listed in `attributes_to_collect`. + +{% admonition type="info" name="Authentication" %} +This endpoint requires an OAuth token with the `write_conversations` scope. The admin associated with the token must have access to the conversation. +{% /admonition %} + +{% admonition type="warning" name="Feature access" %} +This endpoint requires the Procedures HITL API feature to be enabled for your workspace. +{% /admonition %}
@@ -21384,8 +29367,16 @@ Fetches a specific brand by its unique identifier
```typescript -await client.unstable.brands.retrieveBrand({ - id: "id" +await client.preview.procedures.collectProcedureAgentInput({ + conversation_id: "215473853299345", + step_id: "d5b81f72-adb9-4317-b973-75b3c3624c09", + attribute_values: [{ + identifier: "workflow_local_variables.72c5a6b3-3cce-41d8-8e30-14da40791958", + value: true + }, { + identifier: "workflow_local_variables.5adb55fb-f549-44a0-8ee9-7e652ad77c25", + value: "85f00ba7-558c-4b02-a397-6f5c3659941c" + }] }); ``` @@ -21402,7 +29393,7 @@ await client.unstable.brands.retrieveBrand({
-**request:** `Intercom.unstable.RetrieveBrandRequest` +**request:** `Intercom.preview.CollectAgentInputRequest`
@@ -21410,7 +29401,7 @@ await client.unstable.brands.retrieveBrand({
-**requestOptions:** `BrandsClient.RequestOptions` +**requestOptions:** `ProceduresClient.RequestOptions`
@@ -21422,8 +29413,8 @@ await client.unstable.brands.retrieveBrand({
-## Emails -
client.unstable.emails.listEmails() -> Intercom.EmailList +## TicketTypes Attributes +
client.ticketTypes.attributes.create({ ...params }) -> Intercom.TicketTypeAttribute | undefined
@@ -21435,7 +29426,7 @@ await client.unstable.brands.retrieveBrand({
-Lists all sender email address settings for the workspace +You can create a new attribute for a ticket type.
@@ -21450,7 +29441,13 @@ Lists all sender email address settings for the workspace
```typescript -await client.unstable.emails.listEmails(); +await client.ticketTypes.attributes.create({ + ticket_type_id: "ticket_type_id", + name: "Attribute Title", + description: "Attribute Description", + data_type: "string", + required_to_create: false +}); ```
@@ -21466,7 +29463,15 @@ await client.unstable.emails.listEmails();
-**requestOptions:** `EmailsClient.RequestOptions` +**request:** `Intercom.ticketTypes.CreateTicketTypeAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `AttributesClient.RequestOptions`
@@ -21478,7 +29483,7 @@ await client.unstable.emails.listEmails();
-
client.unstable.emails.retrieveEmail({ ...params }) -> Intercom.EmailSetting +
client.ticketTypes.attributes.update({ ...params }) -> Intercom.TicketTypeAttribute | undefined
@@ -21490,7 +29495,7 @@ await client.unstable.emails.listEmails();
-Fetches a specific email setting by its unique identifier +You can update an existing attribute for a ticket type.
@@ -21505,8 +29510,10 @@ Fetches a specific email setting by its unique identifier
```typescript -await client.unstable.emails.retrieveEmail({ - id: "id" +await client.ticketTypes.attributes.update({ + ticket_type_id: "ticket_type_id", + attribute_id: "attribute_id", + description: "New Attribute Description" }); ``` @@ -21523,7 +29530,7 @@ await client.unstable.emails.retrieveEmail({
-**request:** `Intercom.unstable.RetrieveEmailRequest` +**request:** `Intercom.ticketTypes.UpdateTicketTypeAttributeRequest`
@@ -21531,7 +29538,7 @@ await client.unstable.emails.retrieveEmail({
-**requestOptions:** `EmailsClient.RequestOptions` +**requestOptions:** `AttributesClient.RequestOptions`
diff --git a/src/BaseClient.ts b/src/BaseClient.ts index 1c4b0442..fe62a510 100644 --- a/src/BaseClient.ts +++ b/src/BaseClient.ts @@ -32,7 +32,7 @@ export interface BaseClientOptions { | "2.12" | "2.13" | "2.14" - | "Unstable"; + | "Preview"; /** Additional headers to include in requests. */ headers?: Record | null | undefined>; /** The default maximum time to wait for a response in seconds. */ @@ -79,7 +79,7 @@ export interface BaseRequestOptions { | "2.12" | "2.13" | "2.14" - | "Unstable"; + | "Preview"; } export type NormalizedClientOptions = T & { @@ -96,8 +96,8 @@ export function normalizeClientOptions(options: T): { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "7.0.3", - "User-Agent": "intercom-client/7.0.3", + "X-Fern-SDK-Version": "7.0.5-beta.0", + "User-Agent": "intercom-client/7.0.5-beta.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Intercom-Version": options?.version ?? "2.14", diff --git a/src/Client.ts b/src/Client.ts index db9d639f..819cf898 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -8,12 +8,11 @@ import { CallsClient } from "./api/resources/calls/client/Client.js"; import { CompaniesClient } from "./api/resources/companies/client/Client.js"; import { ContactsClient } from "./api/resources/contacts/client/Client.js"; import { ConversationsClient } from "./api/resources/conversations/client/Client.js"; -import { CustomChannelEventsClient } from "./api/resources/customChannelEvents/client/Client.js"; import { CustomObjectInstancesClient } from "./api/resources/customObjectInstances/client/Client.js"; import { DataAttributesClient } from "./api/resources/dataAttributes/client/Client.js"; import { DataExportClient } from "./api/resources/dataExport/client/Client.js"; import { EventsClient } from "./api/resources/events/client/Client.js"; -import { ExportClient } from "./api/resources/export/client/Client.js"; +import { FinAgentClient } from "./api/resources/finAgent/client/Client.js"; import { HelpCentersClient } from "./api/resources/helpCenters/client/Client.js"; import { InternalArticlesClient } from "./api/resources/internalArticles/client/Client.js"; import { IpAllowlistClient } from "./api/resources/ipAllowlist/client/Client.js"; @@ -22,6 +21,8 @@ import { MessagesClient } from "./api/resources/messages/client/Client.js"; import { NewsClient } from "./api/resources/news/client/Client.js"; import { NotesClient } from "./api/resources/notes/client/Client.js"; import { PhoneCallRedirectsClient } from "./api/resources/phoneCallRedirects/client/Client.js"; +import { PreviewClient } from "./api/resources/preview/client/Client.js"; +import { ReportingDataExportClient } from "./api/resources/reportingDataExport/client/Client.js"; import { SegmentsClient } from "./api/resources/segments/client/Client.js"; import { SubscriptionTypesClient } from "./api/resources/subscriptionTypes/client/Client.js"; import { TagsClient } from "./api/resources/tags/client/Client.js"; @@ -29,7 +30,6 @@ import { TeamsClient } from "./api/resources/teams/client/Client.js"; import { TicketStatesClient } from "./api/resources/ticketStates/client/Client.js"; import { TicketsClient } from "./api/resources/tickets/client/Client.js"; import { TicketTypesClient } from "./api/resources/ticketTypes/client/Client.js"; -import { UnstableClient } from "./api/resources/unstable/client/Client.js"; import { VisitorsClient } from "./api/resources/visitors/client/Client.js"; import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js"; import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient.js"; @@ -46,8 +46,9 @@ export class IntercomClient { protected _aiContent: AiContentClient | undefined; protected _articles: ArticlesClient | undefined; protected _awayStatusReasons: AwayStatusReasonsClient | undefined; - protected _export: ExportClient | undefined; + protected _reportingDataExport: ReportingDataExportClient | undefined; protected _dataExport: DataExportClient | undefined; + protected _finAgent: FinAgentClient | undefined; protected _helpCenters: HelpCentersClient | undefined; protected _internalArticles: InternalArticlesClient | undefined; protected _ipAllowlist: IpAllowlistClient | undefined; @@ -56,7 +57,6 @@ export class IntercomClient { protected _notes: NotesClient | undefined; protected _tags: TagsClient | undefined; protected _conversations: ConversationsClient | undefined; - protected _customChannelEvents: CustomChannelEventsClient | undefined; protected _customObjectInstances: CustomObjectInstancesClient | undefined; protected _dataAttributes: DataAttributesClient | undefined; protected _events: EventsClient | undefined; @@ -72,7 +72,7 @@ export class IntercomClient { protected _tickets: TicketsClient | undefined; protected _visitors: VisitorsClient | undefined; protected _news: NewsClient | undefined; - protected _unstable: UnstableClient | undefined; + protected _preview: PreviewClient | undefined; constructor(options: IntercomClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); @@ -94,14 +94,18 @@ export class IntercomClient { return (this._awayStatusReasons ??= new AwayStatusReasonsClient(this._options)); } - public get export(): ExportClient { - return (this._export ??= new ExportClient(this._options)); + public get reportingDataExport(): ReportingDataExportClient { + return (this._reportingDataExport ??= new ReportingDataExportClient(this._options)); } public get dataExport(): DataExportClient { return (this._dataExport ??= new DataExportClient(this._options)); } + public get finAgent(): FinAgentClient { + return (this._finAgent ??= new FinAgentClient(this._options)); + } + public get helpCenters(): HelpCentersClient { return (this._helpCenters ??= new HelpCentersClient(this._options)); } @@ -134,10 +138,6 @@ export class IntercomClient { return (this._conversations ??= new ConversationsClient(this._options)); } - public get customChannelEvents(): CustomChannelEventsClient { - return (this._customChannelEvents ??= new CustomChannelEventsClient(this._options)); - } - public get customObjectInstances(): CustomObjectInstancesClient { return (this._customObjectInstances ??= new CustomObjectInstancesClient(this._options)); } @@ -198,7 +198,7 @@ export class IntercomClient { return (this._news ??= new NewsClient(this._options)); } - public get unstable(): UnstableClient { - return (this._unstable ??= new UnstableClient(this._options)); + public get preview(): PreviewClient { + return (this._preview ??= new PreviewClient(this._options)); } } diff --git a/src/api/resources/admins/client/Client.ts b/src/api/resources/admins/client/Client.ts index f836356f..5bc9604d 100644 --- a/src/api/resources/admins/client/Client.ts +++ b/src/api/resources/admins/client/Client.ts @@ -256,20 +256,33 @@ export class AdminsClient { /** * You can fetch a list of admins for a given workspace. * + * @param {Intercom.ListAdminsRequest} request * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * * @example - * await client.admins.list() + * await client.admins.list({ + * display_avatar: true + * }) */ - public list(requestOptions?: AdminsClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); + public list( + request: Intercom.ListAdminsRequest = {}, + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); } private async __list( + request: Intercom.ListAdminsRequest = {}, requestOptions?: AdminsClient.RequestOptions, ): Promise> { + const { display_avatar: displayAvatar } = request; + const _queryParams: Record = {}; + if (displayAvatar != null) { + _queryParams.display_avatar = displayAvatar.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -286,7 +299,7 @@ export class AdminsClient { ), method: "GET", headers: _headers, - queryParameters: requestOptions?.queryParams, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/admins/client/requests/ListAdminsRequest.ts b/src/api/resources/admins/client/requests/ListAdminsRequest.ts new file mode 100644 index 00000000..784fd1b7 --- /dev/null +++ b/src/api/resources/admins/client/requests/ListAdminsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * display_avatar: true + * } + */ +export interface ListAdminsRequest { + /** If set to true, the response will include the admin's avatar object containing the image URL. Defaults to false. */ + display_avatar?: boolean; +} diff --git a/src/api/resources/admins/client/requests/index.ts b/src/api/resources/admins/client/requests/index.ts index 9d853cb4..a992df91 100644 --- a/src/api/resources/admins/client/requests/index.ts +++ b/src/api/resources/admins/client/requests/index.ts @@ -1,3 +1,4 @@ export type { ConfigureAwayAdminRequest } from "./ConfigureAwayAdminRequest.js"; export type { FindAdminRequest } from "./FindAdminRequest.js"; +export type { ListAdminsRequest } from "./ListAdminsRequest.js"; export type { ListAllActivityLogsRequest } from "./ListAllActivityLogsRequest.js"; diff --git a/src/api/resources/admins/types/index.ts b/src/api/resources/admins/types/index.ts index 838f94f4..a0c4ebf2 100644 --- a/src/api/resources/admins/types/index.ts +++ b/src/api/resources/admins/types/index.ts @@ -1 +1 @@ -export * from "./Admin.js"; +export * from "./types.js"; diff --git a/src/api/resources/admins/types/Admin.ts b/src/api/resources/admins/types/types.ts similarity index 100% rename from src/api/resources/admins/types/Admin.ts rename to src/api/resources/admins/types/types.ts diff --git a/src/api/resources/aiAgent/types/index.ts b/src/api/resources/aiAgent/types/index.ts index 27ef772f..a0c4ebf2 100644 --- a/src/api/resources/aiAgent/types/index.ts +++ b/src/api/resources/aiAgent/types/index.ts @@ -1 +1 @@ -export * from "./AiAgent.js"; +export * from "./types.js"; diff --git a/src/api/resources/aiAgent/types/AiAgent.ts b/src/api/resources/aiAgent/types/types.ts similarity index 100% rename from src/api/resources/aiAgent/types/AiAgent.ts rename to src/api/resources/aiAgent/types/types.ts diff --git a/src/api/resources/aiContent/types/ContentImportSource.ts b/src/api/resources/aiContent/types/ContentImportSource.ts deleted file mode 100644 index e65d8d1a..00000000 --- a/src/api/resources/aiContent/types/ContentImportSource.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An external source for External Pages that you add to your Fin Content Library. - */ -export interface ContentImportSource { - /** Always external_page */ - type: "content_import_source"; - /** The unique identifier for the content import source which is given by Intercom. */ - id: number; - /** The time when the content import source was last synced. */ - last_synced_at: number; - /** If you intend to create or update External Pages via the API, this should be set to `api`. */ - sync_behavior: ContentImportSource.SyncBehavior; - /** The status of the content import source. */ - status: ContentImportSource.Status; - /** The URL of the root of the external source. */ - url: string; - /** The time when the content import source was created. */ - created_at: number; - /** The time when the content import source was last updated. */ - updated_at: number; -} - -export namespace ContentImportSource { - /** If you intend to create or update External Pages via the API, this should be set to `api`. */ - export const SyncBehavior = { - Api: "api", - Automatic: "automatic", - Manual: "manual", - } as const; - export type SyncBehavior = (typeof SyncBehavior)[keyof typeof SyncBehavior]; - /** The status of the content import source. */ - export const Status = { - Active: "active", - Deactivated: "deactivated", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/aiContent/types/ContentImportSourcesList.ts b/src/api/resources/aiContent/types/ContentImportSourcesList.ts deleted file mode 100644 index 8e7018fe..00000000 --- a/src/api/resources/aiContent/types/ContentImportSourcesList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of the content import sources for the App. - */ -export interface ContentImportSourcesList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.PagesLink; - /** A count of the total number of content import sources. */ - total_count?: number; - /** An array of Content Import Source objects */ - data?: Intercom.ContentImportSource[]; -} diff --git a/src/api/resources/aiContent/types/ExternalPage.ts b/src/api/resources/aiContent/types/ExternalPage.ts deleted file mode 100644 index 97afb31c..00000000 --- a/src/api/resources/aiContent/types/ExternalPage.ts +++ /dev/null @@ -1,35 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * External pages that you have added to your Fin Content Library. - */ -export interface ExternalPage { - /** Always external_page */ - type: "external_page"; - /** The unique identifier for the external page which is given by Intercom. */ - id: string; - /** The title of the external page. */ - title: string; - /** The body of the external page in HTML. */ - html: string; - /** The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. */ - url?: string; - /** Whether the external page should be used to answer questions by AI Agent. */ - ai_agent_availability: boolean; - /** Whether the external page should be used to answer questions by AI Copilot. */ - ai_copilot_availability: boolean; - /** Deprecated. Use ai_agent_availability and ai_copilot_availability instead. */ - fin_availability?: boolean; - /** Always en */ - locale: "en"; - /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ - source_id: number; - /** The identifier for the external page which was given by the source. Must be unique for the source. */ - external_id: string; - /** The time when the external page was created. */ - created_at: number; - /** The time when the external page was last updated. */ - updated_at: number; - /** The time when the external page was last ingested. */ - last_ingested_at: number; -} diff --git a/src/api/resources/aiContent/types/ExternalPagesList.ts b/src/api/resources/aiContent/types/ExternalPagesList.ts deleted file mode 100644 index ec5273ca..00000000 --- a/src/api/resources/aiContent/types/ExternalPagesList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of external pages for the App. - */ -export interface ExternalPagesList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.PagesLink; - /** A count of the total number of external pages. */ - total_count?: number; - /** An array of External Page objects */ - data?: Intercom.ExternalPage[]; -} diff --git a/src/api/resources/aiContent/types/index.ts b/src/api/resources/aiContent/types/index.ts index 4a084844..a0c4ebf2 100644 --- a/src/api/resources/aiContent/types/index.ts +++ b/src/api/resources/aiContent/types/index.ts @@ -1,4 +1 @@ -export * from "./ContentImportSource.js"; -export * from "./ContentImportSourcesList.js"; -export * from "./ExternalPage.js"; -export * from "./ExternalPagesList.js"; +export * from "./types.js"; diff --git a/src/api/resources/aiContent/types/types.ts b/src/api/resources/aiContent/types/types.ts new file mode 100644 index 00000000..67491e3c --- /dev/null +++ b/src/api/resources/aiContent/types/types.ts @@ -0,0 +1,103 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../index.js"; + +/** + * An external source for External Pages that you add to your Fin Content Library. + */ +export interface ContentImportSource { + /** Always external_page */ + type: "content_import_source"; + /** The unique identifier for the content import source which is given by Intercom. */ + id: number; + /** The time when the content import source was last synced. */ + last_synced_at: number; + /** If you intend to create or update External Pages via the API, this should be set to `api`. */ + sync_behavior: ContentImportSource.SyncBehavior; + /** The status of the content import source. */ + status: ContentImportSource.Status; + /** The URL of the root of the external source. */ + url: string; + /** The time when the content import source was created. */ + created_at: number; + /** The time when the content import source was last updated. */ + updated_at: number; +} + +export namespace ContentImportSource { + /** If you intend to create or update External Pages via the API, this should be set to `api`. */ + export const SyncBehavior = { + Api: "api", + Automatic: "automatic", + Manual: "manual", + } as const; + export type SyncBehavior = (typeof SyncBehavior)[keyof typeof SyncBehavior]; + /** The status of the content import source. */ + export const Status = { + Active: "active", + Deactivated: "deactivated", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +/** + * This will return a list of the content import sources for the App. + */ +export interface ContentImportSourcesList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.PagesLink; + /** A count of the total number of content import sources. */ + total_count?: number; + /** An array of Content Import Source objects */ + data?: Intercom.ContentImportSource[]; +} + +/** + * External pages that you have added to your Fin Content Library. + */ +export interface ExternalPage { + /** Always external_page */ + type: "external_page"; + /** The unique identifier for the external page which is given by Intercom. */ + id: string; + /** The title of the external page. */ + title: string; + /** The body of the external page in HTML. */ + html: string; + /** The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. */ + url?: string; + /** Whether the external page should be used to answer questions by AI Agent. */ + ai_agent_availability: boolean; + /** Whether the external page should be used to answer questions by AI Copilot. */ + ai_copilot_availability: boolean; + /** Whether the external page should be used to answer questions by AI Sales Agent. */ + ai_sales_agent_availability?: boolean; + /** Deprecated. Use ai_agent_availability and ai_copilot_availability instead. */ + fin_availability?: boolean; + /** Always en */ + locale: "en"; + /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ + source_id: number; + /** The identifier for the external page which was given by the source. Must be unique for the source. */ + external_id: string; + /** The time when the external page was created. */ + created_at: number; + /** The time when the external page was last updated. */ + updated_at: number; + /** The time when the external page was last ingested. */ + last_ingested_at: number; +} + +/** + * This will return a list of external pages for the App. + */ +export interface ExternalPagesList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.PagesLink; + /** A count of the total number of external pages. */ + total_count?: number; + /** An array of External Page objects */ + data?: Intercom.ExternalPage[]; +} diff --git a/src/api/resources/aiContentSource/types/index.ts b/src/api/resources/aiContentSource/types/index.ts index 190780ca..a0c4ebf2 100644 --- a/src/api/resources/aiContentSource/types/index.ts +++ b/src/api/resources/aiContentSource/types/index.ts @@ -1 +1 @@ -export * from "./ContentSource.js"; +export * from "./types.js"; diff --git a/src/api/resources/aiContentSource/types/ContentSource.ts b/src/api/resources/aiContentSource/types/types.ts similarity index 100% rename from src/api/resources/aiContentSource/types/ContentSource.ts rename to src/api/resources/aiContentSource/types/types.ts diff --git a/src/api/resources/articles/client/Client.ts b/src/api/resources/articles/client/Client.ts index e101ba3d..1ccdad44 100644 --- a/src/api/resources/articles/client/Client.ts +++ b/src/api/resources/articles/client/Client.ts @@ -115,6 +115,10 @@ export class ArticlesClient { /** * You can create a new article by making a POST request to `https://api.intercom.io/articles`. * + * > 📘 Tags cannot be managed via the Articles API + * > + * > Article tags are read-only in responses. To create, update, or delete tags, use the Intercom UI or the Tags API endpoints. + * * @param {Intercom.CreateArticleRequest} request * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. * @@ -289,6 +293,10 @@ export class ArticlesClient { /** * You can update the details of a single article by making a PUT request to `https://api.intercom.io/articles/`. * + * > 📘 Tags cannot be managed via the Articles API + * > + * > Article tags are read-only in responses. To create, update, or delete tags, use the Intercom UI or the Tags API endpoints. + * * @param {Intercom.UpdateArticleRequest} request * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. * diff --git a/src/api/resources/articles/client/requests/UpdateArticleRequest.ts b/src/api/resources/articles/client/requests/UpdateArticleRequest.ts index 36209811..24918b76 100644 --- a/src/api/resources/articles/client/requests/UpdateArticleRequest.ts +++ b/src/api/resources/articles/client/requests/UpdateArticleRequest.ts @@ -28,7 +28,7 @@ export interface UpdateArticleRequest { body?: string; /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ author_id?: number; - /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ + /** Whether the article will be `published` or will be a `draft`. Omitting this field leaves the publish state unchanged, so a draft stays a draft and an edit to a published article goes live immediately unless that article already has a pending draft. For multilingual articles, this will be the state of the default language's content. */ state?: UpdateArticleRequest.State; /** The id of the article's parent collection or section. An article without this field stands alone. */ parent_id?: string; @@ -38,7 +38,7 @@ export interface UpdateArticleRequest { } export namespace UpdateArticleRequest { - /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ + /** Whether the article will be `published` or will be a `draft`. Omitting this field leaves the publish state unchanged, so a draft stays a draft and an edit to a published article goes live immediately unless that article already has a pending draft. For multilingual articles, this will be the state of the default language's content. */ export const State = { Published: "published", Draft: "draft", diff --git a/src/api/resources/articles/types/Article.ts b/src/api/resources/articles/types/Article.ts deleted file mode 100644 index 02667c69..00000000 --- a/src/api/resources/articles/types/Article.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The Articles API is a central place to gather all information and take actions on your articles. Articles can live within collections and sections, or alternatively they can stand alone. - */ -export interface Article extends Intercom.ArticleListItem { - statistics?: Intercom.ArticleStatistics; -} diff --git a/src/api/resources/articles/types/ArticleListItem.ts b/src/api/resources/articles/types/ArticleListItem.ts deleted file mode 100644 index 426c862a..00000000 --- a/src/api/resources/articles/types/ArticleListItem.ts +++ /dev/null @@ -1,49 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The data returned about your articles when you list them. - */ -export interface ArticleListItem { - /** The type of object - `article`. */ - type?: "article"; - /** The unique identifier for the article which is given by Intercom. */ - id: string; - /** The id of the workspace which the article belongs to. */ - workspace_id: string; - /** The title of the article. For multilingual articles, this will be the title of the default language's content. */ - title: string; - /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ - description?: string; - /** The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. */ - body?: string; - /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ - author_id: number; - /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ - state: ArticleListItem.State; - /** The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. */ - created_at: number; - /** The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. */ - updated_at: number; - /** The URL of the article. For multilingual articles, this will be the URL of the default language's content. */ - url?: string; - /** The id of the article's parent collection or section. An article without this field stands alone. */ - parent_id?: number; - /** The ids of the article's parent collections or sections. An article without this field stands alone. */ - parent_ids?: number[]; - /** The type of parent, which can either be a `collection` or `section`. */ - parent_type?: string; - /** The default locale of the help center. This field is only returned for multilingual help centers. */ - default_locale?: string; - translated_content?: Intercom.ArticleTranslatedContent; -} - -export namespace ArticleListItem { - /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ - export const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/articles/types/ArticleSearchHighlights.ts b/src/api/resources/articles/types/ArticleSearchHighlights.ts deleted file mode 100644 index c80f22fa..00000000 --- a/src/api/resources/articles/types/ArticleSearchHighlights.ts +++ /dev/null @@ -1,61 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The highlighted results of an Article search. In the examples provided my search query is always "my query". - */ -export interface ArticleSearchHighlights { - /** The ID of the corresponding article. */ - article_id?: string; - /** An Article title highlighted. */ - highlighted_title?: ArticleSearchHighlights.HighlightedTitle.Item[]; - /** An Article description and body text highlighted. */ - highlighted_summary?: ArticleSearchHighlights.HighlightedSummary.Item[][]; -} - -export namespace ArticleSearchHighlights { - export type HighlightedTitle = HighlightedTitle.Item[]; - - export namespace HighlightedTitle { - /** - * A highlighted article title. - */ - export interface Item { - /** The type of text - `highlight` or `plain`. */ - type?: Item.Type; - /** The text of the title. */ - text?: string; - } - - export namespace Item { - /** The type of text - `highlight` or `plain`. */ - export const Type = { - Highlight: "highlight", - Plain: "plain", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } - - export type HighlightedSummary = HighlightedSummary.Item[]; - - export namespace HighlightedSummary { - /** - * An instance of highlighted summary text. - */ - export interface Item { - /** The type of text - `highlight` or `plain`. */ - type?: Item.Type; - /** The text of the title. */ - text?: string; - } - - export namespace Item { - /** The type of text - `highlight` or `plain`. */ - export const Type = { - Highlight: "highlight", - Plain: "plain", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } -} diff --git a/src/api/resources/articles/types/ArticleSearchResponse.ts b/src/api/resources/articles/types/ArticleSearchResponse.ts deleted file mode 100644 index 349062a8..00000000 --- a/src/api/resources/articles/types/ArticleSearchResponse.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The results of an Article search - */ -export interface ArticleSearchResponse { - /** The type of the object - `list`. */ - type?: "list"; - /** The total number of Articles matching the search query */ - total_count?: number; - /** An object containing the results of the search. */ - data?: ArticleSearchResponse.Data; - pages?: Intercom.CursorPages; -} - -export namespace ArticleSearchResponse { - /** - * An object containing the results of the search. - */ - export interface Data { - /** An array of Article objects */ - articles?: Intercom.Article[]; - /** A corresponding array of highlighted Article content */ - highlights?: Intercom.ArticleSearchHighlights[]; - } -} diff --git a/src/api/resources/articles/types/InternalArticle.ts b/src/api/resources/articles/types/InternalArticle.ts deleted file mode 100644 index dec37b5f..00000000 --- a/src/api/resources/articles/types/InternalArticle.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The Internal Articles API is a central place to gather all information and take actions on your internal articles. - */ -export type InternalArticle = Intercom.InternalArticleListItem; diff --git a/src/api/resources/articles/types/index.ts b/src/api/resources/articles/types/index.ts index ac1a15f9..a0c4ebf2 100644 --- a/src/api/resources/articles/types/index.ts +++ b/src/api/resources/articles/types/index.ts @@ -1,5 +1 @@ -export * from "./Article.js"; -export * from "./ArticleListItem.js"; -export * from "./ArticleSearchHighlights.js"; -export * from "./ArticleSearchResponse.js"; -export * from "./InternalArticle.js"; +export * from "./types.js"; diff --git a/src/api/resources/articles/types/types.ts b/src/api/resources/articles/types/types.ts new file mode 100644 index 00000000..c49e80e7 --- /dev/null +++ b/src/api/resources/articles/types/types.ts @@ -0,0 +1,147 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../index.js"; + +/** + * The Articles API is a central place to gather all information and take actions on your articles. Articles can live within collections and sections, or alternatively they can stand alone. + */ +export interface Article extends Intercom.ArticleListItem { + statistics?: Intercom.ArticleStatistics; +} + +/** + * The Internal Articles API is a central place to gather all information and take actions on your internal articles. + */ +export type InternalArticle = Intercom.InternalArticleListItem; + +/** + * The data returned about your articles when you list them. + */ +export interface ArticleListItem { + /** The type of object - `article`. */ + type?: "article"; + /** The unique identifier for the article which is given by Intercom. */ + id: string; + /** The id of the workspace which the article belongs to. */ + workspace_id: string; + /** The title of the article. For multilingual articles, this will be the title of the default language's content. */ + title: string; + /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ + description?: string; + /** The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. */ + body?: string; + /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ + author_id: number; + /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ + state: ArticleListItem.State; + /** The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. */ + created_at: number; + /** The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. */ + updated_at: number; + /** The URL of the article. For multilingual articles, this will be the URL of the default language's content. */ + url?: string; + /** The id of the article's parent collection or section. An article without this field stands alone. */ + parent_id?: number; + /** The ids of the article's parent collections or sections. An article without this field stands alone. */ + parent_ids?: number[]; + /** The type of parent, which can either be a `collection` or `section`. */ + parent_type?: string; + /** The default locale of the help center. This field is only returned for multilingual help centers. */ + default_locale?: string; + translated_content?: Intercom.ArticleTranslatedContent; + tags?: Intercom.Tags; +} + +export namespace ArticleListItem { + /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * The highlighted results of an Article search. In the examples provided my search query is always "my query". + */ +export interface ArticleSearchHighlights { + /** The ID of the corresponding article. */ + article_id?: string; + /** An Article title highlighted. */ + highlighted_title?: ArticleSearchHighlights.HighlightedTitle.Item[]; + /** An Article description and body text highlighted. */ + highlighted_summary?: ArticleSearchHighlights.HighlightedSummary.Item[][]; +} + +export namespace ArticleSearchHighlights { + export type HighlightedTitle = HighlightedTitle.Item[]; + + export namespace HighlightedTitle { + /** + * A highlighted article title. + */ + export interface Item { + /** The type of text - `highlight` or `plain`. */ + type?: Item.Type; + /** The text of the title. */ + text?: string; + } + + export namespace Item { + /** The type of text - `highlight` or `plain`. */ + export const Type = { + Highlight: "highlight", + Plain: "plain", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } + + export type HighlightedSummary = HighlightedSummary.Item[]; + + export namespace HighlightedSummary { + /** + * An instance of highlighted summary text. + */ + export interface Item { + /** The type of text - `highlight` or `plain`. */ + type?: Item.Type; + /** The text of the title. */ + text?: string; + } + + export namespace Item { + /** The type of text - `highlight` or `plain`. */ + export const Type = { + Highlight: "highlight", + Plain: "plain", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } +} + +/** + * The results of an Article search + */ +export interface ArticleSearchResponse { + /** The type of the object - `list`. */ + type?: "list"; + /** The total number of Articles matching the search query */ + total_count?: number; + /** An object containing the results of the search. */ + data?: ArticleSearchResponse.Data; + pages?: Intercom.CursorPages; +} + +export namespace ArticleSearchResponse { + /** + * An object containing the results of the search. + */ + export interface Data { + /** An array of Article objects */ + articles?: Intercom.Article[]; + /** A corresponding array of highlighted Article content */ + highlights?: Intercom.ArticleSearchHighlights[]; + } +} diff --git a/src/api/resources/awayStatusReasons/client/Client.ts b/src/api/resources/awayStatusReasons/client/Client.ts index 22df5064..b710281d 100644 --- a/src/api/resources/awayStatusReasons/client/Client.ts +++ b/src/api/resources/awayStatusReasons/client/Client.ts @@ -37,13 +37,13 @@ export class AwayStatusReasonsClient { */ public listAwayStatusReasons( requestOptions?: AwayStatusReasonsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listAwayStatusReasons(requestOptions)); } private async __listAwayStatusReasons( requestOptions?: AwayStatusReasonsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -68,7 +68,7 @@ export class AwayStatusReasonsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.AwayStatusReason[], rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.AwayStatusReasonList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { diff --git a/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts b/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts deleted file mode 100644 index f37c83bc..00000000 --- a/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ListCallsWithTranscriptsResponse { - type?: string; - data?: ListCallsWithTranscriptsResponse.Data.Item[]; -} - -export namespace ListCallsWithTranscriptsResponse { - export type Data = Data.Item[]; - - export namespace Data { - export interface Item extends Intercom.Call { - /** The call transcript if available, otherwise an empty array. */ - transcript?: Record[]; - /** The status of the transcript if available. */ - transcript_status?: string; - } - } -} diff --git a/src/api/resources/calls/types/index.ts b/src/api/resources/calls/types/index.ts index a7b7c7f7..a0c4ebf2 100644 --- a/src/api/resources/calls/types/index.ts +++ b/src/api/resources/calls/types/index.ts @@ -1,2 +1 @@ -export * from "./Call.js"; -export * from "./ListCallsWithTranscriptsResponse.js"; +export * from "./types.js"; diff --git a/src/api/resources/calls/types/Call.ts b/src/api/resources/calls/types/types.ts similarity index 73% rename from src/api/resources/calls/types/Call.ts rename to src/api/resources/calls/types/types.ts index 33b20803..8f833e51 100644 --- a/src/api/resources/calls/types/Call.ts +++ b/src/api/resources/calls/types/types.ts @@ -2,6 +2,24 @@ import type * as Intercom from "../../../index.js"; +export interface ListCallsWithTranscriptsResponse { + type?: string; + data?: ListCallsWithTranscriptsResponse.Data.Item[]; +} + +export namespace ListCallsWithTranscriptsResponse { + export type Data = Data.Item[]; + + export namespace Data { + export interface Item extends Intercom.Call { + /** The call transcript if available, otherwise an empty array. */ + transcript?: Record[]; + /** The status of the transcript if available. */ + transcript_status?: string; + } + } +} + /** * Represents a phone call in Intercom */ diff --git a/src/api/resources/companies/client/Client.ts b/src/api/resources/companies/client/Client.ts index db9cb03e..eecb224b 100644 --- a/src/api/resources/companies/client/Client.ts +++ b/src/api/resources/companies/client/Client.ts @@ -394,7 +394,15 @@ export class CompaniesClient { } /** - * You can delete a single company. + * Delete a single company. + * + * This endpoint does not permanently remove the company. It archives the company record and detaches any contacts attached to it; the contacts themselves are not deleted. A `company.deleted` webhook is sent once archival completes. + * + * The endpoint returns `200` with `"deleted": true` as soon as the request is accepted — archival is processed asynchronously. + * + * {% admonition type="warning" %} + * Third-party integrations that sync companies into Intercom (for example, Salesforce or Chargebee) will recreate any company deleted through this endpoint on their next sync. To prevent recreation, remove or filter the company at the source integration before deleting it via the API. + * {% /admonition %} * * @param {Intercom.DeleteCompanyRequest} request * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. diff --git a/src/api/resources/companies/types/CompaniesRetrieveResponse.ts b/src/api/resources/companies/types/CompaniesRetrieveResponse.ts deleted file mode 100644 index 97513a72..00000000 --- a/src/api/resources/companies/types/CompaniesRetrieveResponse.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type CompaniesRetrieveResponse = - | Intercom.CompaniesRetrieveResponse.Company - | Intercom.CompaniesRetrieveResponse.List; - -export namespace CompaniesRetrieveResponse { - export interface Company extends Intercom.Company { - type: "company"; - } - - export interface List extends Intercom.CompanyList { - type: "list"; - } -} diff --git a/src/api/resources/companies/types/index.ts b/src/api/resources/companies/types/index.ts index 7e2092d3..a0c4ebf2 100644 --- a/src/api/resources/companies/types/index.ts +++ b/src/api/resources/companies/types/index.ts @@ -1,2 +1 @@ -export * from "./CompaniesRetrieveResponse.js"; -export * from "./Company.js"; +export * from "./types.js"; diff --git a/src/api/resources/companies/types/Company.ts b/src/api/resources/companies/types/types.ts similarity index 86% rename from src/api/resources/companies/types/Company.ts rename to src/api/resources/companies/types/types.ts index cb26b686..af86fa91 100644 --- a/src/api/resources/companies/types/Company.ts +++ b/src/api/resources/companies/types/types.ts @@ -2,6 +2,20 @@ import type * as Intercom from "../../../index.js"; +export type CompaniesRetrieveResponse = + | Intercom.CompaniesRetrieveResponse.Company + | Intercom.CompaniesRetrieveResponse.List; + +export namespace CompaniesRetrieveResponse { + export interface Company extends Intercom.Company { + type: "company"; + } + + export interface List extends Intercom.CompanyList { + type: "list"; + } +} + /** * Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies. */ @@ -61,7 +75,7 @@ export namespace Company { export interface Tags { /** The type of the object */ type?: "tag.list"; - tags?: unknown[]; + tags?: Intercom.TagBasic[]; } /** diff --git a/src/api/resources/contacts/client/Client.ts b/src/api/resources/contacts/client/Client.ts index f5ec64f4..7579af11 100644 --- a/src/api/resources/contacts/client/Client.ts +++ b/src/api/resources/contacts/client/Client.ts @@ -213,6 +213,8 @@ export class ContactsClient { * 1.Opt-out subscription types that the user has opted-out from. * 2.Opt-in subscription types that the user has opted-in to receiving. * + * **Note:** This endpoint only returns subscriptions where the contact has explicitly configured their preference. Subscriptions that are in the default state — where the contact has not made an explicit opt-in or opt-out choice — are not included in the response. + * * @param {Intercom.ListAttachedSubscriptionsRequest} request * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. * @@ -543,6 +545,10 @@ export class ContactsClient { /** * You can fetch the details of a single contact. * + * {% admonition type="warning" name="Merged contacts" %} + * If a contact has been merged into another contact via the Merge endpoint (POST /contacts/merge), requesting it by its original ID will return a `404 Not Found` error. Use the merged-into contact's ID instead. + * {% /admonition %} + * * @param {Intercom.FindContactRequest} request * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. * @@ -777,6 +783,15 @@ export class ContactsClient { /** * You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. * + * {% admonition type="warning" name="Merged contacts are not retrievable via the API" %} + * Once a merge is completed, the source contact (`from`) is permanently removed from the active contact list. This means: + * - **GET /contacts/{id}** — Requesting the source contact by its original ID will return a `404 Not Found` error. + * - **POST /contacts/search** — The source contact will not appear in search results, including queries filtered by `updated_at`. + * - **GET /contacts** — The source contact will not appear in list results. + * + * Only the target contact (`into`) remains accessible. If your application stores contact IDs, update them to use the target contact's ID after a merge. + * {% /admonition %} + * * @param {Intercom.MergeContactsRequest} request * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. * @@ -789,14 +804,14 @@ export class ContactsClient { * }) */ public mergeLeadInUser( - request: Intercom.MergeContactsRequest = {}, + request: Intercom.MergeContactsRequest, requestOptions?: ContactsClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__mergeLeadInUser(request, requestOptions)); } private async __mergeLeadInUser( - request: Intercom.MergeContactsRequest = {}, + request: Intercom.MergeContactsRequest, requestOptions?: ContactsClient.RequestOptions, ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); @@ -864,6 +879,10 @@ export class ContactsClient { * pagination to limit the number of results returned. The default is `50` results per page. * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. * {% /admonition %} + * ### Merged Contacts + * + * Contacts that have been merged (via POST /contacts/merge) are excluded from search results. If a contact was recently merged into another, it will no longer appear in queries filtered by `updated_at` or any other field. Only the target contact from the merge remains searchable. + * * ### Contact Creation Delay * * If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. @@ -877,10 +896,23 @@ export class ContactsClient { * * ### Searching for Timestamp Fields * - * All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. - * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. - * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). - * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly. + * Timestamp fields (`created_at`, `updated_at` etc.) and Date custom attributes are matched by calendar day. Sub-day precision (hour, minute, second) is not supported. + * + * The day boundary uses **your workspace's timezone**, so the same query can return different results on two workspaces in different timezones. + * + * Because the value is truncated to a day: + * + * * `=` matches the whole day. + * * `>` matches from the start of the *next* day, not from the instant you passed. + * * `<` matches everything before the start of that day. + * + * The `!=`, `>=`, `<=`, `IN` and `NIN` operators are not supported on Date fields and return an error. + * + * **Example**, on a workspace set to UTC. Searching for `created_at` greater than `1577869200` (January 1st, 2020 9:00 AM UTC) truncates that value to `1577836800` (January 1st, 2020 12:00 AM UTC). Because `>` starts at the next day, the results begin from January 2nd, 2020 12:00 AM UTC - not from 9:00 AM on January 1st. On a workspace in another timezone, the boundaries fall on that timezone's midnight instead. + * + * To get contacts created on January 1st, 2020, search for `created_at` equal to `1577836800`. + * + * Only search queries behave this way. Responses still carry the full UNIX timestamp, and sorting uses the full value. * * ### Accepted Fields * @@ -933,24 +965,26 @@ export class ContactsClient { * * ### Accepted Operators * - * {% admonition type="warning" name="Searching based on `created_at`" %} - * You cannot use the `<=` or `>=` operators to search by `created_at`. + * {% admonition type="warning" name="Operators not supported on Date fields" %} + * Date fields (`created_at`, `updated_at`, and any Date custom attribute) do not support the `!=`, `>=`, or `<=` operators. Using them returns an error. * {% /admonition %} * - * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). - * - * | Operator | Valid Types | Description | - * | :------- | :------------------------------- | :--------------------------------------------------------------- | - * | = | All | Equals | - * | != | All | Doesn't Equal | - * | IN | All | In
Shortcut for `OR` queries
Values must be in Array | - * | NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | - * | > | Integer
Date (UNIX Timestamp) | Greater than | - * | < | Integer
Date (UNIX Timestamp) | Lower than | - * | ~ | String | Contains | - * | !~ | String | Doesn't Contain | - * | ^ | String | Starts With | - * | $ | String | Ends With | + * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). Which operators are valid depends on the field's type - see the "Valid Types" column below. Searching by `tag_id` supports only the `=` and `!=` operators. + * + * | Operator | Valid Types | Description | + * | :------- | :---------------------------------- | :----------------------------------------------------------------------| + * | = | All | Equals | + * | != | All except Date | Doesn't Equal | + * | IN | All except Date and tag_id | In
Shortcut for `OR` queries
Values must be in Array | + * | NIN | All except Date and tag_id | Not In
Shortcut for `OR !` queries
Values must be in Array | + * | > | Integer
Date | Greater than
On Date fields, matches from the start of the next day | + * | < | Integer
Date | Lower than
On Date fields, matches before the start of the day | + * | >= | Integer | Greater than or equal to
Not supported on Date fields | + * | <= | Integer | Lower than or equal to
Not supported on Date fields | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With | * * @param {Intercom.SearchRequest} request * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. @@ -1046,8 +1080,11 @@ export class ContactsClient { /** * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="info" name="Merged contacts" %} + * Contacts that have been merged (via POST /contacts/merge) will not appear in list results. Only the target contact from the merge remains accessible. + * {% /admonition %} * {% admonition type="warning" name="Pagination" %} - * You can use pagination to limit the number of results returned. The default is `50` results per page. + * You can use pagination to limit the number of results returned. The default is `10` results per page, with a maximum of `150`. * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * diff --git a/src/api/resources/contacts/client/requests/MergeContactsRequest.ts b/src/api/resources/contacts/client/requests/MergeContactsRequest.ts index 520d7f83..dbfed8cd 100644 --- a/src/api/resources/contacts/client/requests/MergeContactsRequest.ts +++ b/src/api/resources/contacts/client/requests/MergeContactsRequest.ts @@ -9,7 +9,7 @@ */ export interface MergeContactsRequest { /** The unique identifier for the contact to merge away from. Must be a lead. */ - from?: string; + from: string; /** The unique identifier for the contact to merge into. Must be a user. */ - into?: string; + into: string; } diff --git a/src/api/resources/contacts/client/requests/UpdateContactRequest.ts b/src/api/resources/contacts/client/requests/UpdateContactRequest.ts index 3f048efd..e6977519 100644 --- a/src/api/resources/contacts/client/requests/UpdateContactRequest.ts +++ b/src/api/resources/contacts/client/requests/UpdateContactRequest.ts @@ -33,9 +33,9 @@ export interface UpdateContactRequest { name?: string; /** An image URL containing the avatar of a contact */ avatar?: string; - /** The time specified for when a contact signed up */ + /** (Unix timestamp in seconds) The time specified for when a contact signed up. */ signed_up_at?: number; - /** The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) */ + /** (Unix timestamp in seconds) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). */ last_seen_at?: number; /** The id of an admin that has been assigned account ownership of the contact */ owner_id?: number; diff --git a/src/api/resources/contacts/types/ContactsCreateResponse.ts b/src/api/resources/contacts/types/ContactsCreateResponse.ts deleted file mode 100644 index c124d661..00000000 --- a/src/api/resources/contacts/types/ContactsCreateResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContactsCreateResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/ContactsFindResponse.ts b/src/api/resources/contacts/types/ContactsFindResponse.ts deleted file mode 100644 index 96ff7ff5..00000000 --- a/src/api/resources/contacts/types/ContactsFindResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContactsFindResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts b/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts deleted file mode 100644 index 95ca8cfb..00000000 --- a/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContactsMergeLeadInUserResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/ContactsUpdateResponse.ts b/src/api/resources/contacts/types/ContactsUpdateResponse.ts deleted file mode 100644 index 736895ee..00000000 --- a/src/api/resources/contacts/types/ContactsUpdateResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContactsUpdateResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts b/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts deleted file mode 100644 index c6dbf5c1..00000000 --- a/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ShowContactByExternalIdResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/index.ts b/src/api/resources/contacts/types/index.ts index adc73bae..a0c4ebf2 100644 --- a/src/api/resources/contacts/types/index.ts +++ b/src/api/resources/contacts/types/index.ts @@ -1,6 +1 @@ -export * from "./Contact.js"; -export * from "./ContactsCreateResponse.js"; -export * from "./ContactsFindResponse.js"; -export * from "./ContactsMergeLeadInUserResponse.js"; -export * from "./ContactsUpdateResponse.js"; -export * from "./ShowContactByExternalIdResponse.js"; +export * from "./types.js"; diff --git a/src/api/resources/contacts/types/Contact.ts b/src/api/resources/contacts/types/types.ts similarity index 66% rename from src/api/resources/contacts/types/Contact.ts rename to src/api/resources/contacts/types/types.ts index 1df7ed44..4accba70 100644 --- a/src/api/resources/contacts/types/Contact.ts +++ b/src/api/resources/contacts/types/types.ts @@ -2,6 +2,31 @@ import type * as Intercom from "../../../index.js"; +export interface ContactsFindResponse extends Intercom.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export interface ContactsUpdateResponse extends Intercom.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export interface ContactsMergeLeadInUserResponse extends Intercom.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export interface ContactsCreateResponse extends Intercom.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export interface ShowContactByExternalIdResponse extends Intercom.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + /** * Contacts represent your leads and users in Intercom. */ @@ -32,21 +57,21 @@ export interface Contact { marked_email_as_spam: boolean; /** Whether the contact is unsubscribed from emails. */ unsubscribed_from_emails: boolean; - /** (UNIX timestamp) The time when the contact was created. */ + /** (Unix timestamp in seconds) The time when the contact was created. */ created_at: number; - /** (UNIX timestamp) The time when the contact was last updated. */ + /** (Unix timestamp in seconds) The time when the contact was last updated. */ updated_at: number; - /** (UNIX timestamp) The time specified for when a contact signed up. */ + /** (Unix timestamp in seconds) The time specified for when a contact signed up. */ signed_up_at?: number; - /** (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). */ + /** (Unix timestamp in seconds) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). */ last_seen_at?: number; - /** (UNIX timestamp) The time when the contact last messaged in. */ + /** (Unix timestamp in seconds) The time when the contact last messaged in. */ last_replied_at?: number; - /** (UNIX timestamp) The time when the contact was last messaged. */ + /** (Unix timestamp in seconds) The time when the contact was last messaged. */ last_contacted_at?: number; - /** (UNIX timestamp) The time when the contact last opened an email. */ + /** (Unix timestamp in seconds) The time when the contact last opened an email. */ last_email_opened_at?: number; - /** (UNIX timestamp) The time when the contact last clicked a link in an email. */ + /** (Unix timestamp in seconds) The time when the contact last clicked a link in an email. */ last_email_clicked_at?: number; /** A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. */ language_override?: string; @@ -68,7 +93,7 @@ export interface Contact { android_os_version?: string; /** The version of the Android SDK which the contact is using. */ android_sdk_version?: string; - /** (UNIX timestamp) The time when the contact was last seen on an Android device. */ + /** (Unix timestamp in seconds) The time when the contact was last seen on an Android device. */ android_last_seen_at?: number; /** The name of the iOS app which the contact is using. */ ios_app_name?: string; @@ -80,7 +105,7 @@ export interface Contact { ios_os_version?: string; /** The version of the iOS SDK which the contact is using. */ ios_sdk_version?: string; - /** (UNIX timestamp) The last time the contact used the iOS app. */ + /** (Unix timestamp in seconds) The last time the contact used the iOS app. */ ios_last_seen_at?: number; /** The custom attributes which are set for the contact. */ custom_attributes?: Record; diff --git a/src/api/resources/conversations/client/Client.ts b/src/api/resources/conversations/client/Client.ts index af9f6fc0..3364d09b 100644 --- a/src/api/resources/conversations/client/Client.ts +++ b/src/api/resources/conversations/client/Client.ts @@ -49,7 +49,7 @@ export class ConversationsClient { public async list( request: Intercom.ListConversationsRequest = {}, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const list = core.HttpResponsePromise.interceptFunction( async ( request: Intercom.ListConversationsRequest, @@ -112,7 +112,7 @@ export class ConversationsClient { }, ); const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ + return new core.Page({ response: dataWithRawResponse.data, rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => @@ -349,6 +349,10 @@ export class ConversationsClient { * See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. * {% /admonition %} * + * {% admonition type="danger" name="Breaking change: duplicate custom attribute names" %} + * The `PUT /conversations/{id}` endpoint now returns a `400 INVALID_PARAMETER` error when the request includes `custom_attributes` and your workspace contains multiple non-archived conversation custom attributes with the same name. Previously, the update would silently apply to a non-deterministic attribute. To resolve, rename or archive the duplicate attribute in your workspace settings, then retry the request. + * {% /admonition %} + * * * @param {Intercom.UpdateConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. @@ -454,7 +458,11 @@ export class ConversationsClient { } /** - * You can delete a single conversation. + * {% admonition type="warning" name="Irreversible operation" %} + * Deleting a conversation is permanent and cannot be reversed. + * {% /admonition %} + * + * Deleting a conversation permanently removes it from the inbox. All sensitive data is deleted, including admin and user replies, conversation attributes, uploads, and related content. The conversation will still appear in reporting, though some data may be incomplete due to the deletion. * * @param {Intercom.DeleteConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. @@ -574,8 +582,8 @@ export class ConversationsClient { * | source.url | String | * | contact_ids | String | * | teammate_ids | String | - * | admin_assignee_id | String | - * | team_assignee_id | String | + * | admin_assignee_id | Integer | + * | team_assignee_id | Integer | * | channel_initiated | String | * | open | Boolean | * | read | Boolean | @@ -654,7 +662,7 @@ export class ConversationsClient { public async search( request: Intercom.SearchRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const list = core.HttpResponsePromise.interceptFunction( async (request: Intercom.SearchRequest): Promise> => { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); @@ -702,7 +710,7 @@ export class ConversationsClient { }, ); const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ + return new core.Page({ response: dataWithRawResponse.data, rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => @@ -723,6 +731,12 @@ export class ConversationsClient { /** * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. * + * {% admonition type="warning" name="Bot replies to inbound email" %} + * By default, bot or Operator replies to an inbound email conversation aren't sent to your customer. The reply is stored as an unnotifiable bot comment, and no `seen` receipt is generated until an email is actually delivered. + * + * To send these replies as outbound emails, reach out to your accounts team to enable the email-reply feature flag for your workspace. + * {% /admonition %} + * * @param {Intercom.ReplyToConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * @@ -1025,14 +1039,14 @@ export class ConversationsClient { public attachContactAsAdmin( request: Intercom.AttachContactToConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__attachContactAsAdmin(request, requestOptions)); } private async __attachContactAsAdmin( request: Intercom.AttachContactToConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const { conversation_id: conversationId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -1061,7 +1075,10 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; + return { + data: _response.body as Intercom.ConversationParticipantsResponse, + rawResponse: _response.rawResponse, + }; } if (_response.error.reason === "status-code") { @@ -1093,10 +1110,10 @@ export class ConversationsClient { } /** - * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * You can remove participants who are contacts from a group conversation, on behalf of an admin. * - * {% admonition type="warning" name="Contacts without an email" %} - * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. + * {% admonition type="warning" name="Removing the last participant" %} + * You cannot remove the last remaining contact from a conversation. * {% /admonition %} * * @@ -1118,14 +1135,14 @@ export class ConversationsClient { public detachContactAsAdmin( request: Intercom.DetachContactFromConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__detachContactAsAdmin(request, requestOptions)); } private async __detachContactAsAdmin( request: Intercom.DetachContactFromConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const { conversation_id: conversationId, contact_id: contactId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -1154,7 +1171,10 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; + return { + data: _response.body as Intercom.ConversationParticipantsResponse, + rawResponse: _response.rawResponse, + }; } if (_response.error.reason === "status-code") { diff --git a/src/api/resources/conversations/client/requests/CreateConversationRequest.ts b/src/api/resources/conversations/client/requests/CreateConversationRequest.ts index 0f8bcd9a..9cf72b64 100644 --- a/src/api/resources/conversations/client/requests/CreateConversationRequest.ts +++ b/src/api/resources/conversations/client/requests/CreateConversationRequest.ts @@ -23,6 +23,10 @@ export interface CreateConversationRequest { from: CreateConversationRequest.From; /** The content of the message. HTML is not supported. */ body: string; + /** The title of the email. Only applicable if the message type is email. */ + subject?: string; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; /** The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom. */ created_at?: number; } diff --git a/src/api/resources/conversations/types/Conversation.ts b/src/api/resources/conversations/types/Conversation.ts deleted file mode 100644 index bf5334b2..00000000 --- a/src/api/resources/conversations/types/Conversation.ts +++ /dev/null @@ -1,67 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. - */ -export interface Conversation { - /** Always conversation. */ - type: string; - /** The id representing the conversation. */ - id: string; - /** The title given to the conversation. */ - title?: string; - /** The time the conversation was created. */ - created_at: number; - /** The last time the conversation was updated. */ - updated_at: number; - /** The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. */ - waiting_since?: number; - /** If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. */ - snoozed_until?: number; - /** Indicates whether a conversation is open (true) or closed (false). */ - open: boolean; - /** Can be set to "open", "closed" or "snoozed". */ - state: Conversation.State; - /** Indicates whether a conversation has been read. */ - read: boolean; - /** If marked as priority, it will return priority or else not_priority. */ - priority?: Conversation.Priority; - /** The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null. */ - admin_assignee_id?: number; - /** The id of the team assigned to the conversation. If it's not assigned to a team it will return null. */ - team_assignee_id?: string; - /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. */ - company_id?: string; - tags?: Intercom.Tags; - conversation_rating?: Intercom.ConversationRating; - source: Intercom.ConversationSource; - contacts: Intercom.ConversationContacts; - teammates?: Intercom.ConversationTeammates; - custom_attributes: Intercom.CustomAttributes; - first_contact_reply?: Intercom.ConversationFirstContactReply; - sla_applied?: Intercom.SlaApplied; - statistics?: Intercom.ConversationStatistics; - conversation_parts?: Intercom.ConversationParts; - linked_objects?: Intercom.LinkedObjectList; - /** Indicates whether the AI Agent participated in the conversation. */ - ai_agent_participated?: boolean; - ai_agent?: Intercom.AiAgent; -} - -export namespace Conversation { - /** Can be set to "open", "closed" or "snoozed". */ - export const State = { - Open: "open", - Closed: "closed", - Snoozed: "snoozed", - } as const; - export type State = (typeof State)[keyof typeof State]; - /** If marked as priority, it will return priority or else not_priority. */ - export const Priority = { - Priority: "priority", - NotPriority: "not_priority", - } as const; - export type Priority = (typeof Priority)[keyof typeof Priority]; -} diff --git a/src/api/resources/conversations/types/ConversationsManageRequestBody.ts b/src/api/resources/conversations/types/ConversationsManageRequestBody.ts deleted file mode 100644 index 7a8ef883..00000000 --- a/src/api/resources/conversations/types/ConversationsManageRequestBody.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type ConversationsManageRequestBody = - | Intercom.ConversationsManageRequestBody.Close - | Intercom.ConversationsManageRequestBody.Snoozed - | Intercom.ConversationsManageRequestBody.Open - | Intercom.ConversationsManageRequestBody.Assignment; - -export namespace ConversationsManageRequestBody { - export interface Close extends Intercom.CloseConversationRequest { - message_type: "close"; - } - - export interface Snoozed extends Intercom.SnoozeConversationRequest { - message_type: "snoozed"; - } - - export interface Open extends Intercom.OpenConversationRequest { - message_type: "open"; - } - - export interface Assignment extends Intercom.AssignConversationRequest { - message_type: "assignment"; - } -} diff --git a/src/api/resources/conversations/types/index.ts b/src/api/resources/conversations/types/index.ts index 062aeafd..a0c4ebf2 100644 --- a/src/api/resources/conversations/types/index.ts +++ b/src/api/resources/conversations/types/index.ts @@ -1,2 +1 @@ -export * from "./Conversation.js"; -export * from "./ConversationsManageRequestBody.js"; +export * from "./types.js"; diff --git a/src/api/resources/conversations/types/types.ts b/src/api/resources/conversations/types/types.ts new file mode 100644 index 00000000..9c4054a3 --- /dev/null +++ b/src/api/resources/conversations/types/types.ts @@ -0,0 +1,150 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../index.js"; + +export type ConversationsManageRequestBody = + | Intercom.ConversationsManageRequestBody.Close + | Intercom.ConversationsManageRequestBody.Snoozed + | Intercom.ConversationsManageRequestBody.Open + | Intercom.ConversationsManageRequestBody.Assignment; + +export namespace ConversationsManageRequestBody { + export interface Close extends Intercom.CloseConversationRequest { + message_type: "close"; + } + + export interface Snoozed extends Intercom.SnoozeConversationRequest { + message_type: "snoozed"; + } + + export interface Open extends Intercom.OpenConversationRequest { + message_type: "open"; + } + + export interface Assignment extends Intercom.AssignConversationRequest { + message_type: "assignment"; + } +} + +/** + * The data returned about your conversations when you list or search them. + */ +export interface ConversationListItem { + /** Always conversation. */ + type: string; + /** The id representing the conversation. */ + id: string; + /** The title given to the conversation. */ + title?: string; + /** The time the conversation was created. */ + created_at: number; + /** The last time the conversation was updated. */ + updated_at: number; + /** The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. */ + waiting_since?: number; + /** If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. */ + snoozed_until?: number; + /** Indicates whether a conversation is open (true) or closed (false). */ + open: boolean; + /** Can be set to "open", "closed" or "snoozed". */ + state: ConversationListItem.State; + /** Indicates whether a conversation has been read. */ + read: boolean; + /** If marked as priority, it will return priority or else not_priority. */ + priority?: ConversationListItem.Priority; + /** The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null. */ + admin_assignee_id?: number; + /** The id of the team assigned to the conversation. If it's not assigned to a team it will return null. */ + team_assignee_id?: number; + tags?: Intercom.Tags; + conversation_rating?: Intercom.ConversationRating; + source: Intercom.ConversationSource; + contacts: Intercom.ConversationContacts; + teammates?: Intercom.ConversationTeammates; + custom_attributes: Intercom.CustomAttributes; + first_contact_reply?: Intercom.ConversationFirstContactReply; + sla_applied?: Intercom.SlaApplied; + statistics?: Intercom.ConversationStatistics; + linked_objects?: Intercom.LinkedObjectList; + /** Indicates whether the AI Agent participated in the conversation. */ + ai_agent_participated?: boolean; + ai_agent?: Intercom.AiAgent; +} + +export namespace ConversationListItem { + /** Can be set to "open", "closed" or "snoozed". */ + export const State = { + Open: "open", + Closed: "closed", + Snoozed: "snoozed", + } as const; + export type State = (typeof State)[keyof typeof State]; + /** If marked as priority, it will return priority or else not_priority. */ + export const Priority = { + Priority: "priority", + NotPriority: "not_priority", + } as const; + export type Priority = (typeof Priority)[keyof typeof Priority]; +} + +/** + * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. + */ +export interface Conversation { + /** Always conversation. */ + type: string; + /** The id representing the conversation. */ + id: string; + /** The title given to the conversation. */ + title?: string; + /** The time the conversation was created. */ + created_at: number; + /** The last time the conversation was updated. */ + updated_at: number; + /** The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. */ + waiting_since?: number; + /** If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. */ + snoozed_until?: number; + /** Indicates whether a conversation is open (true) or closed (false). */ + open: boolean; + /** Can be set to "open", "closed" or "snoozed". */ + state: Conversation.State; + /** Indicates whether a conversation has been read. */ + read: boolean; + /** If marked as priority, it will return priority or else not_priority. */ + priority?: Conversation.Priority; + /** The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null. */ + admin_assignee_id?: number; + /** The id of the team assigned to the conversation. If it's not assigned to a team it will return null. */ + team_assignee_id?: number; + tags?: Intercom.Tags; + conversation_rating?: Intercom.ConversationRating; + source: Intercom.ConversationSource; + contacts: Intercom.ConversationContacts; + teammates?: Intercom.ConversationTeammates; + custom_attributes: Intercom.CustomAttributes; + first_contact_reply?: Intercom.ConversationFirstContactReply; + sla_applied?: Intercom.SlaApplied; + statistics?: Intercom.ConversationStatistics; + conversation_parts?: Intercom.ConversationParts; + linked_objects?: Intercom.LinkedObjectList; + /** Indicates whether the AI Agent participated in the conversation. */ + ai_agent_participated?: boolean; + ai_agent?: Intercom.AiAgent; +} + +export namespace Conversation { + /** Can be set to "open", "closed" or "snoozed". */ + export const State = { + Open: "open", + Closed: "closed", + Snoozed: "snoozed", + } as const; + export type State = (typeof State)[keyof typeof State]; + /** If marked as priority, it will return priority or else not_priority. */ + export const Priority = { + Priority: "priority", + NotPriority: "not_priority", + } as const; + export type Priority = (typeof Priority)[keyof typeof Priority]; +} diff --git a/src/api/resources/customChannelEvents/client/Client.ts b/src/api/resources/customChannelEvents/client/Client.ts deleted file mode 100644 index 4ba0127c..00000000 --- a/src/api/resources/customChannelEvents/client/Client.ts +++ /dev/null @@ -1,423 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace CustomChannelEventsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * With the "Custom Channel" integration, you can bring Fin and Intercom capabilities to your own platform via API, enabling powerful custom integrations. - * - * Intercom treats your integration like any other Intercom channel, allowing your application and Intercom to exchange events seamlessly. This makes it possible, for example, for your users to interact with Fin directly within your own application’s UI. - * - * > **Note:** "Fin over API" is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - */ -export class CustomChannelEventsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CustomChannelEventsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.CustomChannelBaseEvent} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.customChannelEvents.notifyNewConversation({ - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * }) - */ - public notifyNewConversation( - request: Intercom.CustomChannelBaseEvent, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyNewConversation(request, requestOptions)); - } - - private async __notifyNewConversation( - request: Intercom.CustomChannelBaseEvent, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_new_conversation", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.UnauthorizedError( - _response.error.body as Intercom.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_new_conversation", - ); - } - - /** - * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.NotifyNewMessageRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.customChannelEvents.notifyNewMessage({ - * body: "body", - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * }) - */ - public notifyNewMessage( - request: Intercom.NotifyNewMessageRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyNewMessage(request, requestOptions)); - } - - private async __notifyNewMessage( - request: Intercom.NotifyNewMessageRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_new_message", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.UnauthorizedError( - _response.error.body as Intercom.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_new_message", - ); - } - - /** - * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.NotifyQuickReplySelectedRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.customChannelEvents.notifyQuickReplySelected({ - * event_id: "evt_67890", - * external_conversation_id: "conv_13579", - * contact: { - * type: "user", - * external_id: "user_003", - * name: "Alice Example", - * email: "alice@example.com" - * }, - * quick_reply_option_id: "1234" - * }) - */ - public notifyQuickReplySelected( - request: Intercom.NotifyQuickReplySelectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyQuickReplySelected(request, requestOptions)); - } - - private async __notifyQuickReplySelected( - request: Intercom.NotifyQuickReplySelectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_quick_reply_selected", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.UnauthorizedError( - _response.error.body as Intercom.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_quick_reply_selected", - ); - } - - /** - * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.NotifyAttributeCollectedRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.customChannelEvents.notifyAttributeCollected({ - * attribute: { - * id: "id", - * value: "value" - * }, - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * }) - */ - public notifyAttributeCollected( - request: Intercom.NotifyAttributeCollectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyAttributeCollected(request, requestOptions)); - } - - private async __notifyAttributeCollected( - request: Intercom.NotifyAttributeCollectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_attribute_collected", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.UnauthorizedError( - _response.error.body as Intercom.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_attribute_collected", - ); - } -} diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts deleted file mode 100644 index a4a040d9..00000000 --- a/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * attribute: { - * id: "id", - * value: "value" - * }, - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * } - */ -export interface NotifyAttributeCollectedRequest extends Intercom.CustomChannelBaseEvent { - attribute: Intercom.CustomChannelAttribute; -} diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts deleted file mode 100644 index 7f6483df..00000000 --- a/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * body: "body", - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * } - */ -export interface NotifyNewMessageRequest extends Intercom.CustomChannelBaseEvent { - /** The message content sent by the user. */ - body: string; -} diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts deleted file mode 100644 index e6cec3d9..00000000 --- a/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * event_id: "evt_67890", - * external_conversation_id: "conv_13579", - * contact: { - * type: "user", - * external_id: "user_003", - * name: "Alice Example", - * email: "alice@example.com" - * }, - * quick_reply_option_id: "1234" - * } - */ -export interface NotifyQuickReplySelectedRequest extends Intercom.CustomChannelBaseEvent { - /** Id of the selected quick reply option. */ - quick_reply_option_id: string; -} diff --git a/src/api/resources/customChannelEvents/client/requests/index.ts b/src/api/resources/customChannelEvents/client/requests/index.ts deleted file mode 100644 index 702922d9..00000000 --- a/src/api/resources/customChannelEvents/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { NotifyAttributeCollectedRequest } from "./NotifyAttributeCollectedRequest.js"; -export type { NotifyNewMessageRequest } from "./NotifyNewMessageRequest.js"; -export type { NotifyQuickReplySelectedRequest } from "./NotifyQuickReplySelectedRequest.js"; diff --git a/src/api/resources/customObjectInstances/types/index.ts b/src/api/resources/customObjectInstances/types/index.ts index 861f9ce5..a0c4ebf2 100644 --- a/src/api/resources/customObjectInstances/types/index.ts +++ b/src/api/resources/customObjectInstances/types/index.ts @@ -1 +1 @@ -export * from "./CustomObjectInstance.js"; +export * from "./types.js"; diff --git a/src/api/resources/customObjectInstances/types/CustomObjectInstance.ts b/src/api/resources/customObjectInstances/types/types.ts similarity index 100% rename from src/api/resources/customObjectInstances/types/CustomObjectInstance.ts rename to src/api/resources/customObjectInstances/types/types.ts diff --git a/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts b/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts deleted file mode 100644 index 8c42df63..00000000 --- a/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export const DataAttributesListRequestModel = { - Contact: "contact", - Company: "company", - Conversation: "conversation", -} as const; -export type DataAttributesListRequestModel = - (typeof DataAttributesListRequestModel)[keyof typeof DataAttributesListRequestModel]; diff --git a/src/api/resources/dataAttributes/types/index.ts b/src/api/resources/dataAttributes/types/index.ts index cf0add2c..a0c4ebf2 100644 --- a/src/api/resources/dataAttributes/types/index.ts +++ b/src/api/resources/dataAttributes/types/index.ts @@ -1,2 +1 @@ -export * from "./DataAttribute.js"; -export * from "./DataAttributesListRequestModel.js"; +export * from "./types.js"; diff --git a/src/api/resources/dataAttributes/types/DataAttribute.ts b/src/api/resources/dataAttributes/types/types.ts similarity index 90% rename from src/api/resources/dataAttributes/types/DataAttribute.ts rename to src/api/resources/dataAttributes/types/types.ts index a2dbee88..a91b5399 100644 --- a/src/api/resources/dataAttributes/types/DataAttribute.ts +++ b/src/api/resources/dataAttributes/types/types.ts @@ -1,5 +1,13 @@ // This file was auto-generated by Fern from our API Definition. +export const DataAttributesListRequestModel = { + Contact: "contact", + Company: "company", + Conversation: "conversation", +} as const; +export type DataAttributesListRequestModel = + (typeof DataAttributesListRequestModel)[keyof typeof DataAttributesListRequestModel]; + /** * Data Attributes are metadata used to describe your contact, company and conversation models. These include standard and custom attributes. By using the data attributes endpoint, you can get the global list of attributes for your workspace, as well as create and archive custom attributes. */ diff --git a/src/api/resources/dataEvents/types/index.ts b/src/api/resources/dataEvents/types/index.ts index 0272b738..a0c4ebf2 100644 --- a/src/api/resources/dataEvents/types/index.ts +++ b/src/api/resources/dataEvents/types/index.ts @@ -1 +1 @@ -export * from "./DataEvent.js"; +export * from "./types.js"; diff --git a/src/api/resources/dataEvents/types/DataEvent.ts b/src/api/resources/dataEvents/types/types.ts similarity index 96% rename from src/api/resources/dataEvents/types/DataEvent.ts rename to src/api/resources/dataEvents/types/types.ts index 6efc5389..8364a092 100644 --- a/src/api/resources/dataEvents/types/DataEvent.ts +++ b/src/api/resources/dataEvents/types/types.ts @@ -19,5 +19,5 @@ export interface DataEvent { /** An email address for your user. An email should only be used where your application uses email to uniquely identify users. */ email?: string; /** Optional metadata about the event. */ - metadata?: Record; + metadata?: Record; } diff --git a/src/api/resources/dataExport/client/Client.ts b/src/api/resources/dataExport/client/Client.ts index f9ea23e2..268002f7 100644 --- a/src/api/resources/dataExport/client/Client.ts +++ b/src/api/resources/dataExport/client/Client.ts @@ -16,7 +16,7 @@ export declare namespace DataExportClient { } /** - * Everything about your Data Exports + * Export message delivery and engagement statistics (opens, clicks, replies, completions, dismissals, unsubscribes, bounces) for outbound content such as Emails, Posts, Custom Bots, Surveys, Tours, and Series. */ export class DataExportClient { protected readonly _options: NormalizedClientOptionsWithAuth; @@ -190,6 +190,8 @@ export class DataExportClient { /** * To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. * + * This endpoint exports **message delivery and engagement data** for outbound content (Emails, Posts, Custom Bots, Surveys, Tours, Series, and more). The exported data includes who received each message, when they received it, and how they engaged with it (opens, clicks, replies, completions, dismissals, unsubscribes, and bounces). It does not export raw message or conversation content. + * * The only parameters you need to provide are the range of dates that you want exported. * * >🚧 Limit of one active job diff --git a/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts b/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts deleted file mode 100644 index 1eda3ab4..00000000 --- a/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface DataExportExportReportingDataResponse { - job_identifier?: string; - status?: string; - download_url?: string; - download_expires_at?: string; -} diff --git a/src/api/resources/dataExport/types/index.ts b/src/api/resources/dataExport/types/index.ts index 222f0cce..a0c4ebf2 100644 --- a/src/api/resources/dataExport/types/index.ts +++ b/src/api/resources/dataExport/types/index.ts @@ -1,2 +1 @@ -export * from "./DataExport.js"; -export * from "./DataExportExportReportingDataResponse.js"; +export * from "./types.js"; diff --git a/src/api/resources/dataExport/types/DataExport.ts b/src/api/resources/dataExport/types/types.ts similarity index 59% rename from src/api/resources/dataExport/types/DataExport.ts rename to src/api/resources/dataExport/types/types.ts index 002d8072..1f2249bb 100644 --- a/src/api/resources/dataExport/types/DataExport.ts +++ b/src/api/resources/dataExport/types/types.ts @@ -1,7 +1,14 @@ // This file was auto-generated by Fern from our API Definition. +export interface DataExportExportReportingDataResponse { + job_identifier?: string; + status?: string; + download_url?: string; + download_expires_at?: string; +} + /** - * The data export api is used to view all message sent & viewed in a given timeframe. + * The data export API is used to export message delivery and engagement statistics for outbound content (Emails, Posts, Custom Bots, Surveys, Tours, Series, and more) sent in a given timeframe. The exported data includes who received each message, when they received it, and how they engaged with it (opens, clicks, replies, completions, dismissals, unsubscribes, and bounces). */ export interface DataExport { /** The identifier for your job. */ diff --git a/src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts b/src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts deleted file mode 100644 index c15d988e..00000000 --- a/src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface PostExportReportingDataEnqueueResponse { - job_identifier?: string; - status?: string; - download_url?: string; - download_expires_at?: string; -} diff --git a/src/api/resources/export/types/index.ts b/src/api/resources/export/types/index.ts deleted file mode 100644 index 27e82ed3..00000000 --- a/src/api/resources/export/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./GetExportReportingDataGetDatasetsResponse.js"; -export * from "./PostExportReportingDataEnqueueResponse.js"; diff --git a/src/api/resources/finAgent/client/Client.ts b/src/api/resources/finAgent/client/Client.ts new file mode 100644 index 00000000..4194c6b5 --- /dev/null +++ b/src/api/resources/finAgent/client/Client.ts @@ -0,0 +1,418 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import * as environments from "../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; +import * as Intercom from "../../../index.js"; + +export declare namespace FinAgentClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Access Fin programmatically via the Fin Agent API endpoints. + * + *   + * + * {% admonition type="warning" %} + * Please reach out to your accounts team to discuss access and tailored, hands-on support. + * {% /admonition %} + * + *   + * + * Integration is centered around two endpoints (`/fin/start` and `/fin/reply`) and a set of events that notify your application of Fin's status and responses. Events can be delivered via webhooks or Server-Sent Events (SSE). You can also record a customer satisfaction rating with `/fin/csat`. + * + *   + * + * **Events** + * + * Configure a webhook endpoint in the Fin Agent API settings to receive events, or use the `sse_subscription_url` from the API response to subscribe via SSE. See the [setup guide](/docs/guides/fin-agent-api/setup) for configuration details. + * + * - `fin_status_updated` - Fired when Fin's status changes (escalated, resolved, complete) + * - `fin_replied` - Fired when Fin sends a reply to the user + * - `fin_reply_chunk` - SSE-only streaming event fired during reply generation (requires streaming enabled) + * - `csat_requested` - Fired when Fin asks the user to rate the conversation (submit the choice with `POST /fin/csat`) + * + * All webhook requests include an `X-Fin-Agent-API-Webhook-Signature` header for request validation. + */ +export class FinAgentClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: FinAgentClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Initialize Fin by passing it the user's message along with conversation history and user details. + * + * These additional pieces of context will be used by Fin to provide a better and more contextual answer to the user. + * + * {% admonition type="warning" %} + * Please reach out to your accounts team to discuss access. + * {% /admonition %} + * + * Once Fin is initialized, it progresses through a series of statuses such as *thinking*, *awaiting_user_reply*, or *resolved* before ending with a status of *complete*. + * + * During this workflow, the client should allow Fin to continue uninterrupted until a final *complete* status is returned via webhook, at which point control of the conversation passes back to the client. + * + * @param {Intercom.StartFinConversationRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.BadRequestError} + * @throws {@link Intercom.UnauthorizedError} + * + * @example + * await client.finAgent.startFinConversation({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * }) + * + * @example + * await client.finAgent.startFinConversation({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com", + * attributes: { + * "plan_type": "Pro", + * "subscription_status": "active" + * } + * }, + * conversation_metadata: { + * history: [{ + * author: "user", + * body: "I need help", + * timestamp: "2025-01-24T10:00:01Z" + * }, { + * author: "agent", + * body: "What do you need help with?", + * timestamp: "2025-01-24T10:01:00Z" + * }], + * attributes: { + * "priority_level": "high", + * "department": "sales" + * } + * } + * }) + * + * @example + * await client.finAgent.startFinConversation({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here is a screenshot of the issue", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * attachments: [{ + * type: "url", + * url: "https://example.com/document.pdf" + * }, { + * type: "file", + * name: "screenshot.png", + * content_type: "image/png", + * data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk..." + * }] + * }) + */ + public startFinConversation( + request: Intercom.StartFinConversationRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__startFinConversation(request, requestOptions)); + } + + private async __startFinConversation( + request: Intercom.StartFinConversationRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/start", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.StartFinConversationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/start"); + } + + /** + * Once Fin has returned a response to a user's message, its status will be `awaiting_user_reply`. + * + * If a user replies, use this endpoint to send this response to Fin. + * + * {% admonition type="warning" %} + * Please reach out to your accounts team to discuss access. + * {% /admonition %} + * + * @param {Intercom.ReplyToFinRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.BadRequestError} + * @throws {@link Intercom.UnauthorizedError} + * + * @example + * await client.finAgent.replyToFin({ + * conversation_id: "123456", + * message: { + * author: "user", + * body: "Here's the information you requested.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * }) + * + * @example + * await client.finAgent.replyToFin({ + * conversation_id: "123456", + * message: { + * author: "user", + * body: "Here's the invoice you asked for.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * attachments: [{ + * type: "url", + * url: "https://example.com/invoice.pdf" + * }] + * }) + */ + public replyToFin( + request: Intercom.ReplyToFinRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__replyToFin(request, requestOptions)); + } + + private async __replyToFin( + request: Intercom.ReplyToFinRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/reply", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.ReplyToFinResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/reply"); + } + + /** + * Record a customer's satisfaction rating for a conversation, with an optional free-text + * remark. + * + * Fin decides *when* to ask for a rating — this reuses the CSAT settings on your Fin + * workflow, not this API. When Fin asks, it fires a `csat_requested` event over webhooks or + * SSE carrying the rating options to show the user. Present those options, then submit the + * user's choice here. + * + * Submitting the same rating again, with no new remark, is a no-op and stays successful, + * so an at-least-once client can safely retry. Submitting a *different* rating updates the + * stored rating while the update window is still open, and a first remark can be added to + * an already-rated survey. Once a remark has been recorded the rating is locked and can no + * longer be changed. + * + * {% admonition type="warning" %} + * Please reach out to your accounts team to discuss access. + * {% /admonition %} + * + * @param {Intercom.SubmitFinCsatRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.UnauthorizedError} + * @throws {@link Intercom.UnprocessableEntityError} + * + * @example + * await client.finAgent.submitFinCsat({ + * conversation_id: "ext-123", + * rating: "amazing" + * }) + * + * @example + * await client.finAgent.submitFinCsat({ + * conversation_id: "ext-123", + * rating: "amazing", + * remark: "Fin solved my problem in seconds." + * }) + */ + public submitFinCsat( + request: Intercom.SubmitFinCsatRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__submitFinCsat(request, requestOptions)); + } + + private async __submitFinCsat( + request: Intercom.SubmitFinCsatRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/csat", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.SubmitFinCsatResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/csat"); + } +} diff --git a/src/api/resources/customChannelEvents/client/index.ts b/src/api/resources/finAgent/client/index.ts similarity index 100% rename from src/api/resources/customChannelEvents/client/index.ts rename to src/api/resources/finAgent/client/index.ts diff --git a/src/api/resources/finAgent/client/requests/ReplyToFinRequest.ts b/src/api/resources/finAgent/client/requests/ReplyToFinRequest.ts new file mode 100644 index 00000000..f5425c74 --- /dev/null +++ b/src/api/resources/finAgent/client/requests/ReplyToFinRequest.ts @@ -0,0 +1,77 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../index.js"; + +/** + * @example + * { + * conversation_id: "123456", + * message: { + * author: "user", + * body: "Here's the information you requested.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "123456", + * message: { + * author: "user", + * body: "Here's the invoice you asked for.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * attachments: [{ + * type: "url", + * url: "https://example.com/invoice.pdf" + * }] + * } + * + * @example + * { + * conversation_id: "123456", + * message: { + * author: "user", + * body: "Here's the information you requested.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "123456", + * message: { + * author: "user", + * body: "Here's the information you requested.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + */ +export interface ReplyToFinRequest { + /** The ID of the conversation. */ + conversation_id: string; + message: Intercom.FinAgentMessage; + user: Intercom.FinAgentUser; + /** An array of attachments to include with the message. Maximum of 10 attachments. */ + attachments?: Intercom.FinAgentAttachment[]; +} diff --git a/src/api/resources/finAgent/client/requests/StartFinConversationRequest.ts b/src/api/resources/finAgent/client/requests/StartFinConversationRequest.ts new file mode 100644 index 00000000..37be668b --- /dev/null +++ b/src/api/resources/finAgent/client/requests/StartFinConversationRequest.ts @@ -0,0 +1,117 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../index.js"; + +/** + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com", + * attributes: { + * "plan_type": "Pro", + * "subscription_status": "active" + * } + * }, + * conversation_metadata: { + * history: [{ + * author: "user", + * body: "I need help", + * timestamp: "2025-01-24T10:00:01Z" + * }, { + * author: "agent", + * body: "What do you need help with?", + * timestamp: "2025-01-24T10:01:00Z" + * }], + * attributes: { + * "priority_level": "high", + * "department": "sales" + * } + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here is a screenshot of the issue", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * attachments: [{ + * type: "url", + * url: "https://example.com/document.pdf" + * }, { + * type: "file", + * name: "screenshot.png", + * content_type: "image/png", + * data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk..." + * }] + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + */ +export interface StartFinConversationRequest { + /** The ID of the conversation that is calling Fin via this API. */ + conversation_id: string; + message: Intercom.FinAgentMessage; + user: Intercom.FinAgentUser; + /** An array of attachments to include with the message. Maximum of 10 attachments. */ + attachments?: Intercom.FinAgentAttachment[]; + conversation_metadata?: Intercom.FinAgentConversationMetadata; +} diff --git a/src/api/resources/finAgent/client/requests/SubmitFinCsatRequest.ts b/src/api/resources/finAgent/client/requests/SubmitFinCsatRequest.ts new file mode 100644 index 00000000..8d3e7d5a --- /dev/null +++ b/src/api/resources/finAgent/client/requests/SubmitFinCsatRequest.ts @@ -0,0 +1,36 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * conversation_id: "ext-123", + * rating: "amazing" + * } + * + * @example + * { + * conversation_id: "ext-123", + * rating: "amazing", + * remark: "Fin solved my problem in seconds." + * } + */ +export interface SubmitFinCsatRequest { + /** Your external conversation ID — the same ID you started the conversation with, and the one echoed on the `csat_requested` event. */ + conversation_id: string; + /** The rating the user selected — one of the `key` values from the `csat_requested` event's options. */ + rating: SubmitFinCsatRequest.Rating; + /** Optional free-text comment the user left alongside the rating. Can be added to an already-rated survey, but only once — the rating locks after a remark is recorded. */ + remark?: string; +} + +export namespace SubmitFinCsatRequest { + /** The rating the user selected — one of the `key` values from the `csat_requested` event's options. */ + export const Rating = { + Terrible: "terrible", + Bad: "bad", + Ok: "ok", + Good: "good", + Amazing: "amazing", + } as const; + export type Rating = (typeof Rating)[keyof typeof Rating]; +} diff --git a/src/api/resources/finAgent/client/requests/index.ts b/src/api/resources/finAgent/client/requests/index.ts new file mode 100644 index 00000000..7382e562 --- /dev/null +++ b/src/api/resources/finAgent/client/requests/index.ts @@ -0,0 +1,3 @@ +export type { ReplyToFinRequest } from "./ReplyToFinRequest.js"; +export type { StartFinConversationRequest } from "./StartFinConversationRequest.js"; +export type { SubmitFinCsatRequest } from "./SubmitFinCsatRequest.js"; diff --git a/src/api/resources/export/index.ts b/src/api/resources/finAgent/index.ts similarity index 100% rename from src/api/resources/export/index.ts rename to src/api/resources/finAgent/index.ts diff --git a/src/api/resources/finAgent/types/index.ts b/src/api/resources/finAgent/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/finAgent/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/finAgent/types/types.ts b/src/api/resources/finAgent/types/types.ts new file mode 100644 index 00000000..1eec87ad --- /dev/null +++ b/src/api/resources/finAgent/types/types.ts @@ -0,0 +1,387 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../index.js"; + +export interface StartFinConversationResponse { + /** The ID of the conversation. */ + conversation_id?: string; + /** The ID of the user. */ + user_id?: string; + /** Fin's current status in the conversation workflow. */ + status?: StartFinConversationResponse.Status; + /** The timestamp the response was created at, with millisecond precision. */ + created_at_ms?: string; + errors?: Intercom.FinAgentAttributeErrors; + /** Optional. A URL to subscribe to Server-Sent Events (SSE) for this conversation, if SSE is enabled. The access token is a JWT with a 3-minute TTL. The token is revoked when Fin sets the conversation to awaiting_user_reply or complete status. When CSAT is enabled and a survey will follow the resolution, `complete` revocation is deferred until the `csat_requested` event is delivered or the token expires. */ + sse_subscription_url?: string; +} + +export namespace StartFinConversationResponse { + /** Fin's current status in the conversation workflow. */ + export const Status = { + Thinking: "thinking", + AwaitingUserReply: "awaiting_user_reply", + Escalated: "escalated", + Resolved: "resolved", + Complete: "complete", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +export interface ReplyToFinResponse { + /** The ID of the conversation. */ + conversation_id?: string; + /** The ID of the user. */ + user_id?: string; + /** Fin's current status in the conversation workflow. */ + status?: ReplyToFinResponse.Status; + /** The timestamp the response was created at, with millisecond precision. */ + created_at_ms?: string; + errors?: Intercom.FinAgentAttributeErrors; + /** Optional. A URL to subscribe to Server-Sent Events (SSE) for this conversation, if SSE is enabled. The access token is a JWT with a 3-minute TTL. The token is revoked when Fin sets the conversation to awaiting_user_reply or complete status. When CSAT is enabled and a survey will follow the resolution, `complete` revocation is deferred until the `csat_requested` event is delivered or the token expires. */ + sse_subscription_url?: string; +} + +export namespace ReplyToFinResponse { + /** Fin's current status in the conversation workflow. */ + export const Status = { + Thinking: "thinking", + AwaitingUserReply: "awaiting_user_reply", + Escalated: "escalated", + Resolved: "resolved", + Complete: "complete", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +export interface SubmitFinCsatResponse { + /** The external ID of the rated conversation. */ + conversation_id?: string; + /** The rating now recorded on the conversation. */ + rating?: SubmitFinCsatResponse.Rating; + /** The result of the submission. */ + status?: "rated"; +} + +export namespace SubmitFinCsatResponse { + /** The rating now recorded on the conversation. */ + export const Rating = { + Terrible: "terrible", + Bad: "bad", + Ok: "ok", + Good: "good", + Amazing: "amazing", + } as const; + export type Rating = (typeof Rating)[keyof typeof Rating]; +} + +/** + * A message exchanged within a Fin Agent conversation. + */ +export interface FinAgentMessage { + /** The author that created the message. */ + author: FinAgentMessage.Author; + /** + * The body of the message. Accepts both plain text and HTML format. + * When sending a message to Fin, this should contain the user's message. + * Fin's response will be returned as HTML. + */ + body: string; + /** + * The timestamp when the message was created. + * Used to deduplicate messages sent within a 5 minute window. + * Ideally should include milliseconds for higher precision. + */ + timestamp: string; + /** + * The timestamp when the message was created, with millisecond precision. + * Only present in webhook event responses (fin_replied). + */ + timestamp_ms?: string; +} + +export namespace FinAgentMessage { + /** The author that created the message. */ + export const Author = { + User: "user", + Agent: "agent", + Fin: "fin", + } as const; + export type Author = (typeof Author)[keyof typeof Author]; +} + +/** + * A user object representing the user in a Fin Agent conversation. + */ +export interface FinAgentUser { + /** + * The ID of the user. This value will be used to uniquely identify the user + * during a conversation with Fin. Maps to the user_id field on the Intercom User object. + */ + id: string; + /** The name of the user. */ + name?: string; + /** The email of the user. */ + email?: string; + /** + * A hash of attributes associated with the user. + * Attributes can be used by Fin to target content and responses. + * Limit to 10 attributes. + */ + attributes?: Record; +} + +/** + * An attachment object representing a file or URL attachment included with a message. + * Attachments can be used to provide additional context to Fin. + * Maximum of 10 attachments per request. + */ +export interface FinAgentAttachment { + /** The type of attachment. */ + type: FinAgentAttachment.Type; + /** The URL of the attachment. Required when type is 'url'. Must be publicly accessible. */ + url?: string; + /** The name of the file. Required when type is 'file'. */ + name?: string; + /** The MIME type of the file. Required when type is 'file'. */ + content_type?: string; + /** Base64-encoded file data. Required when type is 'file'. */ + data?: string; +} + +export namespace FinAgentAttachment { + /** The type of attachment. */ + export const Type = { + Url: "url", + File: "file", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * Metadata about the conversation, including history and attributes. + */ +export interface FinAgentConversationMetadata { + /** + * An array of previous messages in the conversation before Fin is initialized. + * This data provides context to Fin and helps generate a better answer. + * Limit to the last 10 messages. + */ + history?: Intercom.FinAgentMessage[]; + /** + * A hash of attributes associated with the conversation. + * These attributes can be used by Fin to provide more contextual responses. + * Limit to 10 attributes. + */ + attributes?: Record; +} + +/** + * Contains error details if any user or conversation attribute updates failed. + */ +export interface FinAgentAttributeErrors { + /** User-related attribute errors. */ + user?: FinAgentAttributeErrors.User; + /** Conversation-related attribute errors. */ + conversation?: FinAgentAttributeErrors.Conversation; +} + +export namespace FinAgentAttributeErrors { + /** + * User-related attribute errors. + */ + export interface User { + /** Map of user attribute names to error messages. */ + attributes?: Record; + } + + /** + * Conversation-related attribute errors. + */ + export interface Conversation { + /** Map of conversation attribute names to error messages. */ + attributes?: Record; + } +} + +/** + * Event fired when Fin's status changes during a conversation. + * Delivered via webhooks or SSE. Fin will report its status to the client via this event. + */ +export interface FinAgentStatusUpdatedEvent { + /** The name of the event. */ + event_name: "fin_status_updated"; + /** The ID of the conversation. */ + conversation_id: string; + /** The ID of the user. */ + user_id: string; + /** + * Fin's current status. + * - escalated: The conversation has been escalated to a human + * - resolved: The user's query has been resolved + * - complete: Fin has completed its workflow. When CSAT is enabled a csat_requested event may follow, in which case the SSE stream is held open past complete until it is delivered or the token expires + */ + status: FinAgentStatusUpdatedEvent.Status; + /** + * Optional. A human-readable explanation of why the conversation was escalated. + * Only present when status is 'escalated'. + * Possible values include: + * - "Escalation requested by user" + * - "Escalation rule: {rule_name}" + * - "Escalation rule matched" + * - "Routed to team" + * - "Conversation finished without resolution" + */ + reason?: string; + /** The timestamp the event was created at, with millisecond precision. */ + created_at_ms: string; +} + +export namespace FinAgentStatusUpdatedEvent { + /** + * Fin's current status. + * - escalated: The conversation has been escalated to a human + * - resolved: The user's query has been resolved + * - complete: Fin has completed its workflow. When CSAT is enabled a csat_requested event may follow, in which case the SSE stream is held open past complete until it is delivered or the token expires + */ + export const Status = { + Escalated: "escalated", + Resolved: "resolved", + Complete: "complete", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +/** + * Event fired when Fin replies to a user. + * Delivered via webhooks or SSE. The content of the response will be contained in the message object. + * Fin's status will update to 'awaiting_user_reply'. + */ +export interface FinAgentRepliedEvent { + /** The name of the event. */ + event_name: "fin_replied"; + /** The ID of the conversation. */ + conversation_id: string; + /** The ID of the user. */ + user_id: string; + /** Fin's answer to the user's query. */ + message: FinAgentRepliedEvent.Message; + /** Fin's current status (always 'awaiting_user_reply' for this event). */ + status: "awaiting_user_reply"; + /** + * Optional. Present when the reply was generated via streaming. + * Correlates this event with the fin_reply_chunk events that preceded it. + * Use this to know when to replace streamed chunk_text with the final message body. + */ + stream_id?: string; + /** The timestamp the event was created at, with millisecond precision. */ + created_at_ms: string; +} + +export namespace FinAgentRepliedEvent { + /** + * Fin's answer to the user's query. + */ + export interface Message { + /** A unique identifier for this message. */ + id?: string; + /** The author of the message (always 'fin' for this event). */ + author: "fin"; + /** The HTML body of Fin's response. */ + body: string; + /** The timestamp the message was created at, with millisecond precision. */ + timestamp_ms: string; + } +} + +/** + * SSE-only event fired during streaming reply generation. + * Each chunk contains the full accumulated plain text of Fin's answer so far (cumulative, not a delta). + * Only delivered over SSE when streaming is enabled. Not available via webhooks. + * When the fin_replied event arrives with the same stream_id, replace streamed text with the final HTML body. + */ +export interface FinAgentReplyChunkEvent { + /** The name of the event. */ + event_name: "fin_reply_chunk"; + /** The ID of the conversation. */ + conversation_id: string; + /** + * A unique identifier for this streaming response. + * Correlates chunks with each other and with the eventual fin_replied event. + */ + stream_id: string; + /** 0-based counter for this chunk within the stream. Contiguous. */ + chunk_index: number; + /** + * The full accumulated plain text of Fin's answer so far. + * Each chunk supersedes the previous — replace rather than append. + */ + chunk_text: string; + /** Fin's current status (always 'replying' for this event). */ + status?: "replying"; + /** The timestamp the event was created at, with millisecond precision. */ + created_at_ms: string; +} + +/** + * Event fired when Fin asks the user to rate the conversation. + * Delivered via webhooks or SSE. Carries the rating options to present to the user; submit + * the user's choice with POST /fin/csat. Unlike the reply events it has no message — a + * rating survey is a set of options to choose from, not readable text. + * Over SSE this event arrives after Fin reaches 'complete'. Because a survey is expected, + * 'complete' does not close the stream: the connection is held open so this event can be + * delivered, and the token is revoked once it is sent. + */ +export interface FinAgentCsatRequestedEvent { + /** The name of the event. */ + event_name: "csat_requested"; + /** The ID of the conversation. */ + conversation_id: string; + /** The ID of the user. */ + user_id: string; + /** The rating survey to present to the user. */ + csat: FinAgentCsatRequestedEvent.Csat; + /** The timestamp the event was created at, with millisecond precision. */ + created_at_ms: string; +} + +export namespace FinAgentCsatRequestedEvent { + /** + * The rating survey to present to the user. + */ + export interface Csat { + /** The ordered rating options to show the user. */ + options: Csat.Options.Item[]; + } + + export namespace Csat { + export type Options = Options.Item[]; + + export namespace Options { + export interface Item { + /** The stable key to send back as 'rating' on POST /fin/csat. */ + key: Item.Key; + /** The emoji representing this rating. */ + emoji: string; + /** + * The human-readable label for this rating, localised to the conversation's + * detected language. Distinct from 'key' — display the label, but send back + * the key. + */ + label: string; + } + + export namespace Item { + /** The stable key to send back as 'rating' on POST /fin/csat. */ + export const Key = { + Terrible: "terrible", + Bad: "bad", + Ok: "ok", + Good: "good", + Amazing: "amazing", + } as const; + export type Key = (typeof Key)[keyof typeof Key]; + } + } + } +} diff --git a/src/api/resources/helpCenter/types/HelpCenter.ts b/src/api/resources/helpCenter/types/HelpCenter.ts deleted file mode 100644 index 3715e87f..00000000 --- a/src/api/resources/helpCenter/types/HelpCenter.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Help Centers contain collections - */ -export interface HelpCenter { - /** The unique identifier for the Help Center which is given by Intercom. */ - id?: string; - /** The id of the workspace which the Help Center belongs to. */ - workspace_id?: string; - /** The time when the Help Center was created. */ - created_at?: number; - /** The time when the Help Center was last updated. */ - updated_at?: number; - /** The identifier of the Help Center. This is used in the URL of the Help Center. */ - identifier?: string; - /** Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ - website_turned_on?: boolean; - /** The display name of the Help Center only seen by teammates. */ - display_name?: string; - /** The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. */ - url?: string; - /** Custom domain configured for the help center */ - custom_domain?: string; -} diff --git a/src/api/resources/helpCenter/types/HelpCenterList.ts b/src/api/resources/helpCenter/types/HelpCenterList.ts deleted file mode 100644 index e034eaff..00000000 --- a/src/api/resources/helpCenter/types/HelpCenterList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of Help Centers belonging to the App - */ -export interface HelpCenterList { - /** The type of the object - `list`. */ - type?: "list"; - /** An array of Help Center objects */ - data?: Intercom.HelpCenter[]; -} diff --git a/src/api/resources/helpCenter/types/index.ts b/src/api/resources/helpCenter/types/index.ts index 097e7b49..a0c4ebf2 100644 --- a/src/api/resources/helpCenter/types/index.ts +++ b/src/api/resources/helpCenter/types/index.ts @@ -1,3 +1 @@ -export * from "./Collection.js"; -export * from "./HelpCenter.js"; -export * from "./HelpCenterList.js"; +export * from "./types.js"; diff --git a/src/api/resources/helpCenter/types/Collection.ts b/src/api/resources/helpCenter/types/types.ts similarity index 60% rename from src/api/resources/helpCenter/types/Collection.ts rename to src/api/resources/helpCenter/types/types.ts index 7c9a53b2..261a7a7e 100644 --- a/src/api/resources/helpCenter/types/Collection.ts +++ b/src/api/resources/helpCenter/types/types.ts @@ -32,3 +32,37 @@ export interface Collection { /** The id of the help center the collection is in. */ help_center_id?: number; } + +/** + * Help Centers contain collections + */ +export interface HelpCenter { + /** The unique identifier for the Help Center which is given by Intercom. */ + id: string; + /** The id of the workspace which the Help Center belongs to. */ + workspace_id: string; + /** The time when the Help Center was created. */ + created_at: number; + /** The time when the Help Center was last updated. */ + updated_at: number; + /** The identifier of the Help Center. This is used in the URL of the Help Center. */ + identifier: string; + /** Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ + website_turned_on?: boolean; + /** The display name of the Help Center only seen by teammates. */ + display_name?: string; + /** The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. */ + url?: string; + /** Custom domain configured for the help center */ + custom_domain?: string; +} + +/** + * A list of Help Centers belonging to the App + */ +export interface HelpCenterList { + /** The type of the object - `list`. */ + type?: "list"; + /** An array of Help Center objects */ + data?: Intercom.HelpCenter[]; +} diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 716d6022..92eca7d6 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -24,8 +24,6 @@ export * from "./contacts/types/index.js"; export * from "./conversations/client/requests/index.js"; export * as conversations from "./conversations/index.js"; export * from "./conversations/types/index.js"; -export * from "./customChannelEvents/client/requests/index.js"; -export * as customChannelEvents from "./customChannelEvents/index.js"; export * from "./customObjectInstances/client/requests/index.js"; export * as customObjectInstances from "./customObjectInstances/index.js"; export * from "./customObjectInstances/types/index.js"; @@ -39,9 +37,9 @@ export * as dataExport from "./dataExport/index.js"; export * from "./dataExport/types/index.js"; export * from "./events/client/requests/index.js"; export * as events from "./events/index.js"; -export * from "./export/client/requests/index.js"; -export * as export_ from "./export/index.js"; -export * from "./export/types/index.js"; +export * from "./finAgent/client/requests/index.js"; +export * as finAgent from "./finAgent/index.js"; +export * from "./finAgent/types/index.js"; export * as helpCenter from "./helpCenter/index.js"; export * from "./helpCenter/types/index.js"; export * from "./helpCenters/client/requests/index.js"; @@ -61,6 +59,10 @@ export * from "./notes/client/requests/index.js"; export * as notes from "./notes/index.js"; export * from "./notes/types/index.js"; export * as phoneCallRedirects from "./phoneCallRedirects/index.js"; +export * as preview from "./preview/index.js"; +export * from "./reportingDataExport/client/requests/index.js"; +export * as reportingDataExport from "./reportingDataExport/index.js"; +export * from "./reportingDataExport/types/index.js"; export * from "./segments/client/requests/index.js"; export * as segments from "./segments/index.js"; export * from "./segments/types/index.js"; @@ -78,6 +80,5 @@ export * as tickets from "./tickets/index.js"; export * from "./tickets/types/index.js"; export * from "./ticketTypes/client/requests/index.js"; export * as ticketTypes from "./ticketTypes/index.js"; -export * as unstable from "./unstable/index.js"; export * from "./visitors/client/requests/index.js"; export * as visitors from "./visitors/index.js"; diff --git a/src/api/resources/internalArticles/types/InternalArticleListItem.ts b/src/api/resources/internalArticles/types/InternalArticleListItem.ts deleted file mode 100644 index b906ff6f..00000000 --- a/src/api/resources/internalArticles/types/InternalArticleListItem.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The data returned about your internal articles when you list them. - */ -export interface InternalArticleListItem { - /** The type of object - `internal_article`. */ - type?: "internal_article"; - /** The unique identifier for the article which is given by Intercom. */ - id?: string; - /** The title of the article. */ - title?: string; - /** The body of the article in HTML. */ - body?: string; - /** The id of the owner of the article. */ - owner_id?: number; - /** The id of the author of the article. */ - author_id?: number; - /** The time when the article was created. */ - created_at?: number; - /** The time when the article was last updated. */ - updated_at?: number; - /** The default locale of the article. */ - locale?: string; -} diff --git a/src/api/resources/internalArticles/types/InternalArticleSearchResponse.ts b/src/api/resources/internalArticles/types/InternalArticleSearchResponse.ts deleted file mode 100644 index 9718b94b..00000000 --- a/src/api/resources/internalArticles/types/InternalArticleSearchResponse.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The results of an Internal Article search - */ -export interface InternalArticleSearchResponse { - /** The type of the object - `list`. */ - type?: "list"; - /** The total number of Internal Articles matching the search query */ - total_count?: number; - /** An object containing the results of the search. */ - data?: InternalArticleSearchResponse.Data; - pages?: Intercom.CursorPages; -} - -export namespace InternalArticleSearchResponse { - /** - * An object containing the results of the search. - */ - export interface Data { - /** An array of Internal Article objects */ - internal_articles?: Intercom.InternalArticle[]; - } -} diff --git a/src/api/resources/internalArticles/types/index.ts b/src/api/resources/internalArticles/types/index.ts index aedeb96e..a0c4ebf2 100644 --- a/src/api/resources/internalArticles/types/index.ts +++ b/src/api/resources/internalArticles/types/index.ts @@ -1,2 +1 @@ -export * from "./InternalArticleListItem.js"; -export * from "./InternalArticleSearchResponse.js"; +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/internalArticles/types/InternalArticleListItem.ts b/src/api/resources/internalArticles/types/types.ts similarity index 53% rename from src/api/resources/unstable/resources/internalArticles/types/InternalArticleListItem.ts rename to src/api/resources/internalArticles/types/types.ts index b906ff6f..d0f56b58 100644 --- a/src/api/resources/unstable/resources/internalArticles/types/InternalArticleListItem.ts +++ b/src/api/resources/internalArticles/types/types.ts @@ -1,5 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Intercom from "../../../index.js"; + /** * The data returned about your internal articles when you list them. */ @@ -23,3 +25,26 @@ export interface InternalArticleListItem { /** The default locale of the article. */ locale?: string; } + +/** + * The results of an Internal Article search + */ +export interface InternalArticleSearchResponse { + /** The type of the object - `list`. */ + type?: "list"; + /** The total number of Internal Articles matching the search query */ + total_count?: number; + /** An object containing the results of the search. */ + data?: InternalArticleSearchResponse.Data; + pages?: Intercom.CursorPages; +} + +export namespace InternalArticleSearchResponse { + /** + * An object containing the results of the search. + */ + export interface Data { + /** An array of Internal Article objects */ + internal_articles?: Intercom.InternalArticle[]; + } +} diff --git a/src/api/resources/jobs/types/index.ts b/src/api/resources/jobs/types/index.ts index c4ca9992..a0c4ebf2 100644 --- a/src/api/resources/jobs/types/index.ts +++ b/src/api/resources/jobs/types/index.ts @@ -1 +1 @@ -export * from "./Jobs.js"; +export * from "./types.js"; diff --git a/src/api/resources/jobs/types/Jobs.ts b/src/api/resources/jobs/types/types.ts similarity index 100% rename from src/api/resources/jobs/types/Jobs.ts rename to src/api/resources/jobs/types/types.ts diff --git a/src/api/resources/messages/types/index.ts b/src/api/resources/messages/types/index.ts index e16d36b7..a0c4ebf2 100644 --- a/src/api/resources/messages/types/index.ts +++ b/src/api/resources/messages/types/index.ts @@ -1 +1 @@ -export * from "./Message.js"; +export * from "./types.js"; diff --git a/src/api/resources/messages/types/Message.ts b/src/api/resources/messages/types/types.ts similarity index 100% rename from src/api/resources/messages/types/Message.ts rename to src/api/resources/messages/types/types.ts diff --git a/src/api/resources/news/types/Newsfeed.ts b/src/api/resources/news/types/Newsfeed.ts deleted file mode 100644 index a42f6306..00000000 --- a/src/api/resources/news/types/Newsfeed.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A newsfeed is a collection of news items, targeted to a specific audience. - * - * Newsfeeds currently cannot be edited through the API, please refer to [this article](https://www.intercom.com/help/en/articles/6362267-getting-started-with-news) to set up your newsfeeds in Intercom. - */ -export interface Newsfeed { - /** The unique identifier for the newsfeed which is given by Intercom. */ - id?: string; - /** The type of object. */ - type?: "newsfeed"; - /** The name of the newsfeed. This name will never be visible to your users. */ - name?: string; - /** Timestamp for when the newsfeed was created. */ - created_at?: number; - /** Timestamp for when the newsfeed was last updated. */ - updated_at?: number; -} diff --git a/src/api/resources/news/types/NewsfeedAssignment.ts b/src/api/resources/news/types/NewsfeedAssignment.ts deleted file mode 100644 index 064483c9..00000000 --- a/src/api/resources/news/types/NewsfeedAssignment.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Assigns a news item to a newsfeed. - */ -export interface NewsfeedAssignment { - /** The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). */ - newsfeed_id?: number; - /** Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". */ - published_at?: number; -} diff --git a/src/api/resources/news/types/index.ts b/src/api/resources/news/types/index.ts index fe7a29c8..a0c4ebf2 100644 --- a/src/api/resources/news/types/index.ts +++ b/src/api/resources/news/types/index.ts @@ -1,3 +1 @@ -export * from "./Newsfeed.js"; -export * from "./NewsfeedAssignment.js"; -export * from "./NewsItem.js"; +export * from "./types.js"; diff --git a/src/api/resources/news/types/NewsItem.ts b/src/api/resources/news/types/types.ts similarity index 56% rename from src/api/resources/news/types/NewsItem.ts rename to src/api/resources/news/types/types.ts index 7ae7b3f9..689e5a1f 100644 --- a/src/api/resources/news/types/NewsItem.ts +++ b/src/api/resources/news/types/types.ts @@ -7,19 +7,19 @@ import type * as Intercom from "../../../index.js"; */ export interface NewsItem { /** The type of object. */ - type?: "news-item"; + type: "news-item"; /** The unique identifier for the news item which is given by Intercom. */ - id?: string; + id: string; /** The id of the workspace which the news item belongs to. */ - workspace_id?: string; + workspace_id: string; /** The title of the news item. */ - title?: string; + title: string; /** The news item body, which may contain HTML. */ body?: string; /** The id of the sender of the news item. Must be a teammate on the workspace. */ sender_id?: number; /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ - state?: NewsItem.State; + state: NewsItem.State; /** A list of newsfeed_assignments to assign to the specified newsfeed. */ newsfeed_assignments?: Intercom.NewsfeedAssignment[]; /** Label names displayed to users to categorize the news item. */ @@ -31,9 +31,9 @@ export interface NewsItem { /** When set to true, the news item will appear in the messenger newsfeed without showing a notification badge. */ deliver_silently?: boolean; /** Timestamp for when the news item was created. */ - created_at?: number; + created_at: number; /** Timestamp for when the news item was last updated. */ - updated_at?: number; + updated_at: number; } export namespace NewsItem { @@ -44,3 +44,31 @@ export namespace NewsItem { } as const; export type State = (typeof State)[keyof typeof State]; } + +/** + * A newsfeed is a collection of news items, targeted to a specific audience. + * + * Newsfeeds currently cannot be edited through the API, please refer to [this article](https://www.intercom.com/help/en/articles/6362267-getting-started-with-news) to set up your newsfeeds in Intercom. + */ +export interface Newsfeed { + /** The unique identifier for the newsfeed which is given by Intercom. */ + id: string; + /** The type of object. */ + type: "newsfeed"; + /** The name of the newsfeed. This name will never be visible to your users. */ + name: string; + /** Timestamp for when the newsfeed was created. */ + created_at: number; + /** Timestamp for when the newsfeed was last updated. */ + updated_at: number; +} + +/** + * Assigns a news item to a newsfeed. + */ +export interface NewsfeedAssignment { + /** The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). */ + newsfeed_id: number; + /** Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". */ + published_at?: number; +} diff --git a/src/api/resources/notes/types/index.ts b/src/api/resources/notes/types/index.ts index e0e2f407..a0c4ebf2 100644 --- a/src/api/resources/notes/types/index.ts +++ b/src/api/resources/notes/types/index.ts @@ -1 +1 @@ -export * from "./Note.js"; +export * from "./types.js"; diff --git a/src/api/resources/notes/types/Note.ts b/src/api/resources/notes/types/types.ts similarity index 100% rename from src/api/resources/notes/types/Note.ts rename to src/api/resources/notes/types/types.ts diff --git a/src/api/resources/unstable/client/Client.ts b/src/api/resources/preview/client/Client.ts similarity index 63% rename from src/api/resources/unstable/client/Client.ts rename to src/api/resources/preview/client/Client.ts index f42b2732..c908e3a0 100644 --- a/src/api/resources/unstable/client/Client.ts +++ b/src/api/resources/preview/client/Client.ts @@ -5,26 +5,41 @@ import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } import { AdminsClient } from "../resources/admins/client/Client.js"; import { AiContentClient } from "../resources/aiContent/client/Client.js"; import { ArticlesClient } from "../resources/articles/client/Client.js"; +import { AudiencesClient } from "../resources/audiences/client/Client.js"; +import { AuthTokensClient } from "../resources/authTokens/client/Client.js"; import { AwayStatusReasonsClient } from "../resources/awayStatusReasons/client/Client.js"; +import { BannersClient } from "../resources/banners/client/Client.js"; import { BrandsClient } from "../resources/brands/client/Client.js"; import { CallsClient } from "../resources/calls/client/Client.js"; import { CompaniesClient } from "../resources/companies/client/Client.js"; import { ContactsClient } from "../resources/contacts/client/Client.js"; +import { ContentClient } from "../resources/content/client/Client.js"; +import { ContentSnippetsClient } from "../resources/contentSnippets/client/Client.js"; +import { ConversationParticipantsClient } from "../resources/conversationParticipants/client/Client.js"; +import { ConversationPartsClient } from "../resources/conversationParts/client/Client.js"; import { ConversationsClient } from "../resources/conversations/client/Client.js"; -import { CustomChannelEventsClient } from "../resources/customChannelEvents/client/Client.js"; +import { ConversationsAttributesClient } from "../resources/conversationsAttributes/client/Client.js"; import { CustomObjectInstancesClient } from "../resources/customObjectInstances/client/Client.js"; import { DataAttributesClient } from "../resources/dataAttributes/client/Client.js"; +import { DataConnectorsClient } from "../resources/dataConnectors/client/Client.js"; import { DataEventsClient } from "../resources/dataEvents/client/Client.js"; import { DataExportClient } from "../resources/dataExport/client/Client.js"; +import { EcommerceConnectorsClient } from "../resources/ecommerceConnectors/client/Client.js"; import { EmailsClient } from "../resources/emails/client/Client.js"; -import { ExportClient } from "../resources/export/client/Client.js"; +import { FinAgentClient } from "../resources/finAgent/client/Client.js"; +import { FoldersClient } from "../resources/folders/client/Client.js"; import { HelpCenterClient } from "../resources/helpCenter/client/Client.js"; +import { IdentityVerificationSecretsClient } from "../resources/identityVerificationSecrets/client/Client.js"; import { InternalArticlesClient } from "../resources/internalArticles/client/Client.js"; import { JobsClient } from "../resources/jobs/client/Client.js"; import { MacrosClient } from "../resources/macros/client/Client.js"; import { MessagesClient } from "../resources/messages/client/Client.js"; import { NewsClient } from "../resources/news/client/Client.js"; import { NotesClient } from "../resources/notes/client/Client.js"; +import { OfficeHoursClient } from "../resources/officeHours/client/Client.js"; +import { ProceduresClient } from "../resources/procedures/client/Client.js"; +import { ReportingDataExportClient } from "../resources/reportingDataExport/client/Client.js"; +import { RolesClient } from "../resources/roles/client/Client.js"; import { SegmentsClient } from "../resources/segments/client/Client.js"; import { SubscriptionTypesClient } from "../resources/subscriptionTypes/client/Client.js"; import { SwitchClient } from "../resources/switch/client/Client.js"; @@ -37,39 +52,52 @@ import { TicketTypesClient } from "../resources/ticketTypes/client/Client.js"; import { VisitorsClient } from "../resources/visitors/client/Client.js"; import { WorkflowsClient } from "../resources/workflows/client/Client.js"; -export declare namespace UnstableClient { +export declare namespace PreviewClient { export interface Options extends BaseClientOptions {} } -export class UnstableClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class PreviewClient { + protected readonly _options: NormalizedClientOptionsWithAuth; protected _admins: AdminsClient | undefined; protected _aiContent: AiContentClient | undefined; protected _articles: ArticlesClient | undefined; protected _awayStatusReasons: AwayStatusReasonsClient | undefined; - protected _export: ExportClient | undefined; + protected _audiences: AudiencesClient | undefined; + protected _officeHours: OfficeHoursClient | undefined; + protected _reportingDataExport: ReportingDataExportClient | undefined; protected _helpCenter: HelpCenterClient | undefined; protected _internalArticles: InternalArticlesClient | undefined; + protected _folders: FoldersClient | undefined; protected _companies: CompaniesClient | undefined; protected _notes: NotesClient | undefined; protected _contacts: ContactsClient | undefined; protected _subscriptionTypes: SubscriptionTypesClient | undefined; protected _tags: TagsClient | undefined; + protected _banners: BannersClient | undefined; + protected _content: ContentClient | undefined; + protected _contentSnippets: ContentSnippetsClient | undefined; protected _conversations: ConversationsClient | undefined; - protected _customChannelEvents: CustomChannelEventsClient | undefined; + protected _conversationParts: ConversationPartsClient | undefined; + protected _conversationParticipants: ConversationParticipantsClient | undefined; + protected _conversationsAttributes: ConversationsAttributesClient | undefined; protected _customObjectInstances: CustomObjectInstancesClient | undefined; protected _dataAttributes: DataAttributesClient | undefined; + protected _authTokens: AuthTokensClient | undefined; + protected _dataConnectors: DataConnectorsClient | undefined; + protected _ecommerceConnectors: EcommerceConnectorsClient | undefined; protected _dataEvents: DataEventsClient | undefined; protected _dataExport: DataExportClient | undefined; protected _workflows: WorkflowsClient | undefined; protected _jobs: JobsClient | undefined; protected _macros: MacrosClient | undefined; protected _messages: MessagesClient | undefined; + protected _teams: TeamsClient | undefined; protected _news: NewsClient | undefined; + protected _roles: RolesClient | undefined; + protected _identityVerificationSecrets: IdentityVerificationSecretsClient | undefined; protected _segments: SegmentsClient | undefined; protected _switch: SwitchClient | undefined; protected _calls: CallsClient | undefined; - protected _teams: TeamsClient | undefined; protected _ticketStates: TicketStatesClient | undefined; protected _ticketTypeAttributes: TicketTypeAttributesClient | undefined; protected _ticketTypes: TicketTypesClient | undefined; @@ -77,8 +105,10 @@ export class UnstableClient { protected _visitors: VisitorsClient | undefined; protected _brands: BrandsClient | undefined; protected _emails: EmailsClient | undefined; + protected _finAgent: FinAgentClient | undefined; + protected _procedures: ProceduresClient | undefined; - constructor(options: UnstableClient.Options = {}) { + constructor(options: PreviewClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } @@ -98,8 +128,16 @@ export class UnstableClient { return (this._awayStatusReasons ??= new AwayStatusReasonsClient(this._options)); } - public get export(): ExportClient { - return (this._export ??= new ExportClient(this._options)); + public get audiences(): AudiencesClient { + return (this._audiences ??= new AudiencesClient(this._options)); + } + + public get officeHours(): OfficeHoursClient { + return (this._officeHours ??= new OfficeHoursClient(this._options)); + } + + public get reportingDataExport(): ReportingDataExportClient { + return (this._reportingDataExport ??= new ReportingDataExportClient(this._options)); } public get helpCenter(): HelpCenterClient { @@ -110,6 +148,10 @@ export class UnstableClient { return (this._internalArticles ??= new InternalArticlesClient(this._options)); } + public get folders(): FoldersClient { + return (this._folders ??= new FoldersClient(this._options)); + } + public get companies(): CompaniesClient { return (this._companies ??= new CompaniesClient(this._options)); } @@ -130,12 +172,32 @@ export class UnstableClient { return (this._tags ??= new TagsClient(this._options)); } + public get banners(): BannersClient { + return (this._banners ??= new BannersClient(this._options)); + } + + public get content(): ContentClient { + return (this._content ??= new ContentClient(this._options)); + } + + public get contentSnippets(): ContentSnippetsClient { + return (this._contentSnippets ??= new ContentSnippetsClient(this._options)); + } + public get conversations(): ConversationsClient { return (this._conversations ??= new ConversationsClient(this._options)); } - public get customChannelEvents(): CustomChannelEventsClient { - return (this._customChannelEvents ??= new CustomChannelEventsClient(this._options)); + public get conversationParts(): ConversationPartsClient { + return (this._conversationParts ??= new ConversationPartsClient(this._options)); + } + + public get conversationParticipants(): ConversationParticipantsClient { + return (this._conversationParticipants ??= new ConversationParticipantsClient(this._options)); + } + + public get conversationsAttributes(): ConversationsAttributesClient { + return (this._conversationsAttributes ??= new ConversationsAttributesClient(this._options)); } public get customObjectInstances(): CustomObjectInstancesClient { @@ -146,6 +208,18 @@ export class UnstableClient { return (this._dataAttributes ??= new DataAttributesClient(this._options)); } + public get authTokens(): AuthTokensClient { + return (this._authTokens ??= new AuthTokensClient(this._options)); + } + + public get dataConnectors(): DataConnectorsClient { + return (this._dataConnectors ??= new DataConnectorsClient(this._options)); + } + + public get ecommerceConnectors(): EcommerceConnectorsClient { + return (this._ecommerceConnectors ??= new EcommerceConnectorsClient(this._options)); + } + public get dataEvents(): DataEventsClient { return (this._dataEvents ??= new DataEventsClient(this._options)); } @@ -170,10 +244,22 @@ export class UnstableClient { return (this._messages ??= new MessagesClient(this._options)); } + public get teams(): TeamsClient { + return (this._teams ??= new TeamsClient(this._options)); + } + public get news(): NewsClient { return (this._news ??= new NewsClient(this._options)); } + public get roles(): RolesClient { + return (this._roles ??= new RolesClient(this._options)); + } + + public get identityVerificationSecrets(): IdentityVerificationSecretsClient { + return (this._identityVerificationSecrets ??= new IdentityVerificationSecretsClient(this._options)); + } + public get segments(): SegmentsClient { return (this._segments ??= new SegmentsClient(this._options)); } @@ -186,10 +272,6 @@ export class UnstableClient { return (this._calls ??= new CallsClient(this._options)); } - public get teams(): TeamsClient { - return (this._teams ??= new TeamsClient(this._options)); - } - public get ticketStates(): TicketStatesClient { return (this._ticketStates ??= new TicketStatesClient(this._options)); } @@ -217,4 +299,12 @@ export class UnstableClient { public get emails(): EmailsClient { return (this._emails ??= new EmailsClient(this._options)); } + + public get finAgent(): FinAgentClient { + return (this._finAgent ??= new FinAgentClient(this._options)); + } + + public get procedures(): ProceduresClient { + return (this._procedures ??= new ProceduresClient(this._options)); + } } diff --git a/src/api/resources/unstable/client/index.ts b/src/api/resources/preview/client/index.ts similarity index 100% rename from src/api/resources/unstable/client/index.ts rename to src/api/resources/preview/client/index.ts diff --git a/src/api/resources/unstable/errors/BadRequestError.ts b/src/api/resources/preview/errors/BadRequestError.ts similarity index 100% rename from src/api/resources/unstable/errors/BadRequestError.ts rename to src/api/resources/preview/errors/BadRequestError.ts diff --git a/src/api/resources/unstable/errors/ConflictError.ts b/src/api/resources/preview/errors/ConflictError.ts similarity index 86% rename from src/api/resources/unstable/errors/ConflictError.ts rename to src/api/resources/preview/errors/ConflictError.ts index afd826b8..8d019bdd 100644 --- a/src/api/resources/unstable/errors/ConflictError.ts +++ b/src/api/resources/preview/errors/ConflictError.ts @@ -5,7 +5,7 @@ import * as errors from "../../../../errors/index.js"; import type * as Intercom from "../../../index.js"; export class ConflictError extends errors.IntercomError { - constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + constructor(body: Intercom.preview.Error_, rawResponse?: core.RawResponse) { super({ message: "ConflictError", statusCode: 409, diff --git a/src/api/resources/unstable/errors/ForbiddenError.ts b/src/api/resources/preview/errors/ForbiddenError.ts similarity index 86% rename from src/api/resources/unstable/errors/ForbiddenError.ts rename to src/api/resources/preview/errors/ForbiddenError.ts index a5eefa5f..f7e2be79 100644 --- a/src/api/resources/unstable/errors/ForbiddenError.ts +++ b/src/api/resources/preview/errors/ForbiddenError.ts @@ -5,7 +5,7 @@ import * as errors from "../../../../errors/index.js"; import type * as Intercom from "../../../index.js"; export class ForbiddenError extends errors.IntercomError { - constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + constructor(body: Intercom.preview.Error_, rawResponse?: core.RawResponse) { super({ message: "ForbiddenError", statusCode: 403, diff --git a/src/api/resources/preview/errors/GoneError.ts b/src/api/resources/preview/errors/GoneError.ts new file mode 100644 index 00000000..0e56b76c --- /dev/null +++ b/src/api/resources/preview/errors/GoneError.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../core/index.js"; +import * as errors from "../../../../errors/index.js"; +import type * as Intercom from "../../../index.js"; + +export class GoneError extends errors.IntercomError { + constructor(body: Intercom.preview.Error_, rawResponse?: core.RawResponse) { + super({ + message: "GoneError", + statusCode: 410, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, GoneError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/InternalServerError.ts b/src/api/resources/preview/errors/InternalServerError.ts similarity index 86% rename from src/api/resources/unstable/errors/InternalServerError.ts rename to src/api/resources/preview/errors/InternalServerError.ts index 05de1b39..76540679 100644 --- a/src/api/resources/unstable/errors/InternalServerError.ts +++ b/src/api/resources/preview/errors/InternalServerError.ts @@ -5,7 +5,7 @@ import * as errors from "../../../../errors/index.js"; import type * as Intercom from "../../../index.js"; export class InternalServerError extends errors.IntercomError { - constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + constructor(body: Intercom.preview.Error_, rawResponse?: core.RawResponse) { super({ message: "InternalServerError", statusCode: 500, diff --git a/src/api/resources/preview/errors/MethodNotAllowedError.ts b/src/api/resources/preview/errors/MethodNotAllowedError.ts new file mode 100644 index 00000000..e3903b68 --- /dev/null +++ b/src/api/resources/preview/errors/MethodNotAllowedError.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../core/index.js"; +import * as errors from "../../../../errors/index.js"; +import type * as Intercom from "../../../index.js"; + +export class MethodNotAllowedError extends errors.IntercomError { + constructor(body: Intercom.preview.Error_, rawResponse?: core.RawResponse) { + super({ + message: "MethodNotAllowedError", + statusCode: 405, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, MethodNotAllowedError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/NotFoundError.ts b/src/api/resources/preview/errors/NotFoundError.ts similarity index 100% rename from src/api/resources/unstable/errors/NotFoundError.ts rename to src/api/resources/preview/errors/NotFoundError.ts diff --git a/src/api/resources/preview/errors/ServiceUnavailableError.ts b/src/api/resources/preview/errors/ServiceUnavailableError.ts new file mode 100644 index 00000000..48e74e3c --- /dev/null +++ b/src/api/resources/preview/errors/ServiceUnavailableError.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../core/index.js"; +import * as errors from "../../../../errors/index.js"; +import type * as Intercom from "../../../index.js"; + +export class ServiceUnavailableError extends errors.IntercomError { + constructor(body: Intercom.preview.Error_, rawResponse?: core.RawResponse) { + super({ + message: "ServiceUnavailableError", + statusCode: 503, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, ServiceUnavailableError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/TooManyRequestsError.ts b/src/api/resources/preview/errors/TooManyRequestsError.ts similarity index 86% rename from src/api/resources/unstable/errors/TooManyRequestsError.ts rename to src/api/resources/preview/errors/TooManyRequestsError.ts index 8213e523..a30f97ff 100644 --- a/src/api/resources/unstable/errors/TooManyRequestsError.ts +++ b/src/api/resources/preview/errors/TooManyRequestsError.ts @@ -5,7 +5,7 @@ import * as errors from "../../../../errors/index.js"; import type * as Intercom from "../../../index.js"; export class TooManyRequestsError extends errors.IntercomError { - constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + constructor(body: Intercom.preview.Error_, rawResponse?: core.RawResponse) { super({ message: "TooManyRequestsError", statusCode: 429, diff --git a/src/api/resources/unstable/errors/UnauthorizedError.ts b/src/api/resources/preview/errors/UnauthorizedError.ts similarity index 86% rename from src/api/resources/unstable/errors/UnauthorizedError.ts rename to src/api/resources/preview/errors/UnauthorizedError.ts index 15ea9d4f..08e8b39a 100644 --- a/src/api/resources/unstable/errors/UnauthorizedError.ts +++ b/src/api/resources/preview/errors/UnauthorizedError.ts @@ -5,7 +5,7 @@ import * as errors from "../../../../errors/index.js"; import type * as Intercom from "../../../index.js"; export class UnauthorizedError extends errors.IntercomError { - constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + constructor(body: Intercom.preview.Error_, rawResponse?: core.RawResponse) { super({ message: "UnauthorizedError", statusCode: 401, diff --git a/src/api/resources/unstable/errors/UnprocessableEntityError.ts b/src/api/resources/preview/errors/UnprocessableEntityError.ts similarity index 100% rename from src/api/resources/unstable/errors/UnprocessableEntityError.ts rename to src/api/resources/preview/errors/UnprocessableEntityError.ts diff --git a/src/api/resources/unstable/errors/index.ts b/src/api/resources/preview/errors/index.ts similarity index 72% rename from src/api/resources/unstable/errors/index.ts rename to src/api/resources/preview/errors/index.ts index 200c43d1..5b3227c6 100644 --- a/src/api/resources/unstable/errors/index.ts +++ b/src/api/resources/preview/errors/index.ts @@ -1,8 +1,11 @@ export * from "./BadRequestError.js"; export * from "./ConflictError.js"; export * from "./ForbiddenError.js"; +export * from "./GoneError.js"; export * from "./InternalServerError.js"; +export * from "./MethodNotAllowedError.js"; export * from "./NotFoundError.js"; +export * from "./ServiceUnavailableError.js"; export * from "./TooManyRequestsError.js"; export * from "./UnauthorizedError.js"; export * from "./UnprocessableEntityError.js"; diff --git a/src/api/resources/unstable/index.ts b/src/api/resources/preview/index.ts similarity index 100% rename from src/api/resources/unstable/index.ts rename to src/api/resources/preview/index.ts diff --git a/src/api/resources/preview/resources/admins/client/Client.ts b/src/api/resources/preview/resources/admins/client/Client.ts new file mode 100644 index 00000000..cc759fae --- /dev/null +++ b/src/api/resources/preview/resources/admins/client/Client.ts @@ -0,0 +1,678 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace AdminsClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Everything about your Admins + */ +export class AdminsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: AdminsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + * + * > 🚧 Single Sign On + * > + * > If you are building a custom "Log in with Intercom" flow for your site, and you call the `/me` endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk. + * + * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.preview.admins.identifyAdmin() + */ + public identifyAdmin( + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__identifyAdmin(requestOptions)); + } + + private async __identifyAdmin( + requestOptions?: AdminsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "me", + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.AdminWithApp | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/me"); + } + + /** + * You can set an Admin as away for the Inbox. + * + * @param {Intercom.preview.SetAwayAdminRequest} request + * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.admins.setAwayAdmin({ + * id: 1, + * away_mode_enabled: true, + * away_mode_reassign: true, + * away_status_reason_id: 12345 + * }) + * + * @example + * await client.preview.admins.setAwayAdmin({ + * id: 1, + * away_mode_enabled: true, + * away_mode_reassign: true + * }) + */ + public setAwayAdmin( + request: Intercom.preview.SetAwayAdminRequest, + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__setAwayAdmin(request, requestOptions)); + } + + private async __setAwayAdmin( + request: Intercom.preview.SetAwayAdminRequest, + requestOptions?: AdminsClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `admins/${core.url.encodePathParam(id)}/away`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Admin | undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/admins/{id}/away"); + } + + /** + * You can get a log of activities by all admins in an app. + * + * @param {Intercom.preview.ListActivityLogsRequest} request + * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.admins.listActivityLogs({ + * created_at_after: "1677253093", + * created_at_before: "1677861493" + * }) + */ + public listActivityLogs( + request: Intercom.preview.ListActivityLogsRequest, + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listActivityLogs(request, requestOptions)); + } + + private async __listActivityLogs( + request: Intercom.preview.ListActivityLogsRequest, + requestOptions?: AdminsClient.RequestOptions, + ): Promise> { + const { created_at_after: createdAtAfter, created_at_before: createdAtBefore } = request; + const _queryParams: Record = {}; + _queryParams.created_at_after = createdAtAfter; + if (createdAtBefore != null) { + _queryParams.created_at_before = createdAtBefore; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "admins/activity_logs", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ActivityLogList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins/activity_logs"); + } + + /** + * Search and filter admin activity logs using a POST request with event type filter in the request body. You can find more details about the available event types in the List all activity log event types endpoint. + * + * @param {Intercom.preview.SearchActivityLogsRequest} request + * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.admins.searchActivityLogs({ + * created_at_after: 1677253093, + * created_at_before: 1677861493, + * event_types: ["app_name_change", "message_state_change"] + * }) + * + * @example + * await client.preview.admins.searchActivityLogs({ + * created_at_after: 1677253093, + * created_at_before: 1677861493 + * }) + */ + public searchActivityLogs( + request: Intercom.preview.SearchActivityLogsRequest, + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchActivityLogs(request, requestOptions)); + } + + private async __searchActivityLogs( + request: Intercom.preview.SearchActivityLogsRequest, + requestOptions?: AdminsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "admins/activity_logs/search", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ActivityLogList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/admins/activity_logs/search"); + } + + /** + * You can get a list of all activity log event types. This is useful for discovering valid values to use with the `event_types` filter on the List all activity logs endpoint. + * + * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.admins.listActivityLogEventTypes() + */ + public listActivityLogEventTypes( + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listActivityLogEventTypes(requestOptions)); + } + + private async __listActivityLogEventTypes( + requestOptions?: AdminsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "admins/activity_log_event_types", + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ActivityLogEventTypeList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/admins/activity_log_event_types", + ); + } + + /** + * You can fetch a list of admins for a given workspace. + * + * @param {Intercom.preview.ListAdminsRequest} request + * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.admins.listAdmins({ + * display_avatar: true + * }) + */ + public listAdmins( + request: Intercom.preview.ListAdminsRequest = {}, + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAdmins(request, requestOptions)); + } + + private async __listAdmins( + request: Intercom.preview.ListAdminsRequest = {}, + requestOptions?: AdminsClient.RequestOptions, + ): Promise> { + const { display_avatar: displayAvatar } = request; + const _queryParams: Record = {}; + if (displayAvatar != null) { + _queryParams.display_avatar = displayAvatar.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "admins", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.AdminList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins"); + } + + /** + * You can retrieve the details of a single admin. + * + * @param {Intercom.preview.RetrieveAdminRequest} request + * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.admins.retrieveAdmin({ + * id: 1 + * }) + */ + public retrieveAdmin( + request: Intercom.preview.RetrieveAdminRequest, + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveAdmin(request, requestOptions)); + } + + private async __retrieveAdmin( + request: Intercom.preview.RetrieveAdminRequest, + requestOptions?: AdminsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `admins/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Admin | undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins/{id}"); + } + + /** + * You can remove a single admin (teammate) from your workspace. + * Requires the `remove_admins` OAuth scope. + * + * This removes the admin's access to the workspace and reassigns their + * work — auto-messages, ownership, article authorship, and conversation + * replies — to the admins named by the `reassign_*` parameters. + * + * @param {Intercom.preview.RemoveAdminRequest} request + * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.MethodNotAllowedError} + * + * @example + * await client.preview.admins.removeAdmin({ + * admin_id: 1, + * reassign_messages_admin_id: 1, + * reassign_owner_admin_id: 1, + * reassign_articles_author_id: 1, + * reassign_conversations_admin_id: 1 + * }) + */ + public removeAdmin( + request: Intercom.preview.RemoveAdminRequest, + requestOptions?: AdminsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__removeAdmin(request, requestOptions)); + } + + private async __removeAdmin( + request: Intercom.preview.RemoveAdminRequest, + requestOptions?: AdminsClient.RequestOptions, + ): Promise> { + const { + admin_id: adminId, + reassign_messages_admin_id: reassignMessagesAdminId, + reassign_owner_admin_id: reassignOwnerAdminId, + reassign_articles_author_id: reassignArticlesAuthorId, + reassign_conversations_admin_id: reassignConversationsAdminId, + reassign_replies_teams: reassignRepliesTeams, + } = request; + const _queryParams: Record = {}; + _queryParams.admin_id = adminId.toString(); + _queryParams.reassign_messages_admin_id = reassignMessagesAdminId.toString(); + _queryParams.reassign_owner_admin_id = reassignOwnerAdminId.toString(); + _queryParams.reassign_articles_author_id = reassignArticlesAuthorId.toString(); + _queryParams.reassign_conversations_admin_id = reassignConversationsAdminId.toString(); + if (reassignRepliesTeams != null) { + if (Array.isArray(reassignRepliesTeams)) { + _queryParams.reassign_replies_teams = reassignRepliesTeams.map((item) => item); + } else { + _queryParams.reassign_replies_teams = reassignRepliesTeams; + } + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "admins/remove", + ), + method: "DELETE", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.RemoveAdminResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 405: + throw new Intercom.preview.MethodNotAllowedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/admins/remove"); + } +} diff --git a/src/api/resources/export/client/index.ts b/src/api/resources/preview/resources/admins/client/index.ts similarity index 100% rename from src/api/resources/export/client/index.ts rename to src/api/resources/preview/resources/admins/client/index.ts diff --git a/src/api/resources/unstable/resources/admins/client/requests/ListActivityLogsRequest.ts b/src/api/resources/preview/resources/admins/client/requests/ListActivityLogsRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/admins/client/requests/ListActivityLogsRequest.ts rename to src/api/resources/preview/resources/admins/client/requests/ListActivityLogsRequest.ts diff --git a/src/api/resources/preview/resources/admins/client/requests/ListAdminsRequest.ts b/src/api/resources/preview/resources/admins/client/requests/ListAdminsRequest.ts new file mode 100644 index 00000000..784fd1b7 --- /dev/null +++ b/src/api/resources/preview/resources/admins/client/requests/ListAdminsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * display_avatar: true + * } + */ +export interface ListAdminsRequest { + /** If set to true, the response will include the admin's avatar object containing the image URL. Defaults to false. */ + display_avatar?: boolean; +} diff --git a/src/api/resources/preview/resources/admins/client/requests/RemoveAdminRequest.ts b/src/api/resources/preview/resources/admins/client/requests/RemoveAdminRequest.ts new file mode 100644 index 00000000..3289cb94 --- /dev/null +++ b/src/api/resources/preview/resources/admins/client/requests/RemoveAdminRequest.ts @@ -0,0 +1,30 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * admin_id: 1, + * reassign_messages_admin_id: 1, + * reassign_owner_admin_id: 1, + * reassign_articles_author_id: 1, + * reassign_conversations_admin_id: 1 + * } + */ +export interface RemoveAdminRequest { + /** The unique identifier of the admin to remove. */ + admin_id: number; + /** The unique identifier of a human admin to reassign the removed admin's auto-message ownership to. */ + reassign_messages_admin_id: number; + /** The unique identifier of a human admin to reassign the removed admin's ownership (of users and leads) to. */ + reassign_owner_admin_id: number; + /** The unique identifier of a human admin to reassign the removed admin's article authorship to. */ + reassign_articles_author_id: number; + /** The unique identifier of a human admin with Inbox access to reassign the removed admin's conversation replies to. Pass `0` to leave conversations unassigned. */ + reassign_conversations_admin_id: number; + /** A list of teams and the admin each team's conversation replies should be reassigned to. */ + reassign_replies_teams?: + | Intercom.preview.RemoveAdminRequestReassignRepliesTeamsItem + | Intercom.preview.RemoveAdminRequestReassignRepliesTeamsItem[]; +} diff --git a/src/api/resources/unstable/resources/admins/client/requests/RetrieveAdminRequest.ts b/src/api/resources/preview/resources/admins/client/requests/RetrieveAdminRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/admins/client/requests/RetrieveAdminRequest.ts rename to src/api/resources/preview/resources/admins/client/requests/RetrieveAdminRequest.ts diff --git a/src/api/resources/preview/resources/admins/client/requests/SearchActivityLogsRequest.ts b/src/api/resources/preview/resources/admins/client/requests/SearchActivityLogsRequest.ts new file mode 100644 index 00000000..60cab75b --- /dev/null +++ b/src/api/resources/preview/resources/admins/client/requests/SearchActivityLogsRequest.ts @@ -0,0 +1,28 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * created_at_after: 1677253093, + * created_at_before: 1677861493, + * event_types: ["app_name_change", "message_state_change"] + * } + * + * @example + * { + * created_at_after: 1677253093, + * created_at_before: 1677861493 + * } + */ +export interface SearchActivityLogsRequest { + /** The start date that you request data for. It must be formatted as a UNIX timestamp. */ + created_at_after: number; + /** The end date that you request data for. It must be formatted as a UNIX timestamp. */ + created_at_before?: number; + /** An optional list of event types to filter activity logs by. Use the list all activity log event types endpoint to retrieve available values. */ + event_types?: string[]; + /** The page number of results to return. */ + page?: number; + /** The number of results per page. Must be between 1 and 250. */ + per_page?: number; +} diff --git a/src/api/resources/unstable/resources/admins/client/requests/SetAwayAdminRequest.ts b/src/api/resources/preview/resources/admins/client/requests/SetAwayAdminRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/admins/client/requests/SetAwayAdminRequest.ts rename to src/api/resources/preview/resources/admins/client/requests/SetAwayAdminRequest.ts diff --git a/src/api/resources/unstable/resources/admins/client/requests/index.ts b/src/api/resources/preview/resources/admins/client/requests/index.ts similarity index 50% rename from src/api/resources/unstable/resources/admins/client/requests/index.ts rename to src/api/resources/preview/resources/admins/client/requests/index.ts index 48a61029..d1b5e84c 100644 --- a/src/api/resources/unstable/resources/admins/client/requests/index.ts +++ b/src/api/resources/preview/resources/admins/client/requests/index.ts @@ -1,3 +1,6 @@ export type { ListActivityLogsRequest } from "./ListActivityLogsRequest.js"; +export type { ListAdminsRequest } from "./ListAdminsRequest.js"; +export type { RemoveAdminRequest } from "./RemoveAdminRequest.js"; export type { RetrieveAdminRequest } from "./RetrieveAdminRequest.js"; +export type { SearchActivityLogsRequest } from "./SearchActivityLogsRequest.js"; export type { SetAwayAdminRequest } from "./SetAwayAdminRequest.js"; diff --git a/src/api/resources/unstable/resources/admins/index.ts b/src/api/resources/preview/resources/admins/index.ts similarity index 100% rename from src/api/resources/unstable/resources/admins/index.ts rename to src/api/resources/preview/resources/admins/index.ts diff --git a/src/api/resources/preview/resources/admins/types/index.ts b/src/api/resources/preview/resources/admins/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/admins/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/admins/types/types.ts b/src/api/resources/preview/resources/admins/types/types.ts new file mode 100644 index 00000000..904db9b5 --- /dev/null +++ b/src/api/resources/preview/resources/admins/types/types.ts @@ -0,0 +1,71 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +export interface RemoveAdminRequestReassignRepliesTeamsItem { + team_id?: number; + assignee_id?: number; +} + +export interface RemoveAdminResponse { + /** The unique identifier of the removed admin. */ + id?: string; + object?: "admin"; + /** Whether the admin was removed. Returned as the string `"true"`. */ + removed?: "true"; +} + +/** + * A list of all activity log event types. + */ +export interface ActivityLogEventTypeList { + /** String representing the object's type. Always has the value `activity_log_event_type.list`. */ + type?: string; + /** An array of activity log event type strings. */ + event_types?: string[]; +} + +/** + * Admins are teammate accounts that have access to a workspace. + */ +export interface Admin { + /** String representing the object's type. Always has the value `admin`. */ + type?: string; + /** The id representing the admin. */ + id?: string; + /** The name of the admin. */ + name?: string; + /** The email of the admin. */ + email?: string; + /** The job title of the admin. */ + job_title?: string; + /** Identifies if this admin is currently set in away mode. */ + away_mode_enabled?: boolean; + /** Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ + away_mode_reassign?: boolean; + /** The unique identifier of the away status reason */ + away_status_reason_id?: number; + /** Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ + has_inbox_seat?: boolean; + /** This object represents the avatar associated with the admin. */ + team_ids?: number[]; + /** Image for the associated team or teammate */ + avatar?: string; + team_priority_level?: Intercom.preview.TeamPriorityLevel; + /** The role assigned to this admin. Only present if the admin has a role assigned. */ + role?: Admin.Role; +} + +export namespace Admin { + /** + * The role assigned to this admin. Only present if the admin has a role assigned. + */ + export interface Role { + /** String representing the object's type. Always has the value `role`. */ + type?: string; + /** The id of the role. */ + id?: string; + /** The name of the role. */ + name?: string; + } +} diff --git a/src/api/resources/unstable/resources/aiAgent/index.ts b/src/api/resources/preview/resources/aiAgent/index.ts similarity index 100% rename from src/api/resources/unstable/resources/aiAgent/index.ts rename to src/api/resources/preview/resources/aiAgent/index.ts diff --git a/src/api/resources/preview/resources/aiAgent/types/index.ts b/src/api/resources/preview/resources/aiAgent/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/aiAgent/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts b/src/api/resources/preview/resources/aiAgent/types/types.ts similarity index 97% rename from src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts rename to src/api/resources/preview/resources/aiAgent/types/types.ts index 868b1cd9..2e68fee3 100644 --- a/src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts +++ b/src/api/resources/preview/resources/aiAgent/types/types.ts @@ -22,7 +22,7 @@ export interface AiAgent { created_at?: number; /** The time when the AI agent rating was last updated. */ updated_at?: number; - content_sources?: Intercom.unstable.ContentSourcesList; + content_sources?: Intercom.preview.ContentSourcesList; } export namespace AiAgent { diff --git a/src/api/resources/unstable/resources/aiContent/client/Client.ts b/src/api/resources/preview/resources/aiContent/client/Client.ts similarity index 80% rename from src/api/resources/unstable/resources/aiContent/client/Client.ts rename to src/api/resources/preview/resources/aiContent/client/Client.ts index cdb6bcae..8d8f2242 100644 --- a/src/api/resources/unstable/resources/aiContent/client/Client.ts +++ b/src/api/resources/preview/resources/aiContent/client/Client.ts @@ -42,20 +42,20 @@ export class AiContentClient { * * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.listContentImportSources() + * await client.preview.aiContent.listContentImportSources() */ public listContentImportSources( requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listContentImportSources(requestOptions)); } private async __listContentImportSources( requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -81,7 +81,7 @@ export class AiContentClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.ContentImportSourcesList, + data: _response.body as Intercom.preview.ContentImportSourcesList, rawResponse: _response.rawResponse, }; } @@ -89,8 +89,8 @@ export class AiContentClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -108,27 +108,27 @@ export class AiContentClient { /** * You can create a new content import source by sending a POST request to this endpoint. * - * @param {Intercom.unstable.CreateContentImportSourceRequest} request + * @param {Intercom.preview.CreateContentImportSourceRequest} request * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.createContentImportSource({ + * await client.preview.aiContent.createContentImportSource({ * url: "https://www.example.com" * }) */ public createContentImportSource( - request: Intercom.unstable.CreateContentImportSourceRequest, + request: Intercom.preview.CreateContentImportSourceRequest, requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createContentImportSource(request, requestOptions)); } private async __createContentImportSource( - request: Intercom.unstable.CreateContentImportSourceRequest, + request: Intercom.preview.CreateContentImportSourceRequest, requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -156,17 +156,14 @@ export class AiContentClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ContentImportSource, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.ContentImportSource, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -182,27 +179,27 @@ export class AiContentClient { } /** - * @param {Intercom.unstable.GetContentImportSourceRequest} request + * @param {Intercom.preview.GetContentImportSourceRequest} request * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.getContentImportSource({ + * await client.preview.aiContent.getContentImportSource({ * id: "id" * }) */ public getContentImportSource( - request: Intercom.unstable.GetContentImportSourceRequest, + request: Intercom.preview.GetContentImportSourceRequest, requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getContentImportSource(request, requestOptions)); } private async __getContentImportSource( - request: Intercom.unstable.GetContentImportSourceRequest, + request: Intercom.preview.GetContentImportSourceRequest, requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -228,17 +225,14 @@ export class AiContentClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ContentImportSource, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.ContentImportSource, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -261,29 +255,29 @@ export class AiContentClient { /** * You can update an existing content import source. * - * @param {Intercom.unstable.UpdateContentImportSourceRequest} request + * @param {Intercom.preview.UpdateContentImportSourceRequest} request * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.updateContentImportSource({ + * await client.preview.aiContent.updateContentImportSource({ * id: "id", * sync_behavior: "api", * url: "https://www.example.com" * }) */ public updateContentImportSource( - request: Intercom.unstable.UpdateContentImportSourceRequest, + request: Intercom.preview.UpdateContentImportSourceRequest, requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateContentImportSource(request, requestOptions)); } private async __updateContentImportSource( - request: Intercom.unstable.UpdateContentImportSourceRequest, + request: Intercom.preview.UpdateContentImportSourceRequest, requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -312,17 +306,14 @@ export class AiContentClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ContentImportSource, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.ContentImportSource, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -345,25 +336,25 @@ export class AiContentClient { /** * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. * - * @param {Intercom.unstable.DeleteContentImportSourceRequest} request + * @param {Intercom.preview.DeleteContentImportSourceRequest} request * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.deleteContentImportSource({ + * await client.preview.aiContent.deleteContentImportSource({ * id: "id" * }) */ public deleteContentImportSource( - request: Intercom.unstable.DeleteContentImportSourceRequest, + request: Intercom.preview.DeleteContentImportSourceRequest, requestOptions?: AiContentClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteContentImportSource(request, requestOptions)); } private async __deleteContentImportSource( - request: Intercom.unstable.DeleteContentImportSourceRequest, + request: Intercom.preview.DeleteContentImportSourceRequest, requestOptions?: AiContentClient.RequestOptions, ): Promise> { const { id } = request; @@ -397,8 +388,8 @@ export class AiContentClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -423,20 +414,20 @@ export class AiContentClient { * * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.listExternalPages() + * await client.preview.aiContent.listExternalPages() */ public listExternalPages( requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listExternalPages(requestOptions)); } private async __listExternalPages( requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -461,14 +452,14 @@ export class AiContentClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ExternalPagesList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ExternalPagesList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -486,13 +477,13 @@ export class AiContentClient { /** * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. * - * @param {Intercom.unstable.CreateExternalPageRequest} request + * @param {Intercom.preview.CreateExternalPageRequest} request * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.createExternalPage({ + * await client.preview.aiContent.createExternalPage({ * title: "Test", * html: "

Test

", * url: "https://www.example.com", @@ -501,16 +492,16 @@ export class AiContentClient { * }) */ public createExternalPage( - request: Intercom.unstable.CreateExternalPageRequest, + request: Intercom.preview.CreateExternalPageRequest, requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createExternalPage(request, requestOptions)); } private async __createExternalPage( - request: Intercom.unstable.CreateExternalPageRequest, + request: Intercom.preview.CreateExternalPageRequest, requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -538,14 +529,14 @@ export class AiContentClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ExternalPage, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ExternalPage, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -563,27 +554,27 @@ export class AiContentClient { /** * You can retrieve an external page. * - * @param {Intercom.unstable.GetExternalPageRequest} request + * @param {Intercom.preview.GetExternalPageRequest} request * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.getExternalPage({ + * await client.preview.aiContent.getExternalPage({ * id: "id" * }) */ public getExternalPage( - request: Intercom.unstable.GetExternalPageRequest, + request: Intercom.preview.GetExternalPageRequest, requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getExternalPage(request, requestOptions)); } private async __getExternalPage( - request: Intercom.unstable.GetExternalPageRequest, + request: Intercom.preview.GetExternalPageRequest, requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -609,14 +600,14 @@ export class AiContentClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ExternalPage, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ExternalPage, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -634,13 +625,13 @@ export class AiContentClient { /** * You can update an existing external page (if it was created via the API). * - * @param {Intercom.unstable.UpdateExternalPageRequest} request + * @param {Intercom.preview.UpdateExternalPageRequest} request * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.updateExternalPage({ + * await client.preview.aiContent.updateExternalPage({ * id: "id", * title: "Test", * html: "

Test

", @@ -650,16 +641,16 @@ export class AiContentClient { * }) */ public updateExternalPage( - request: Intercom.unstable.UpdateExternalPageRequest, + request: Intercom.preview.UpdateExternalPageRequest, requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateExternalPage(request, requestOptions)); } private async __updateExternalPage( - request: Intercom.unstable.UpdateExternalPageRequest, + request: Intercom.preview.UpdateExternalPageRequest, requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -688,14 +679,14 @@ export class AiContentClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ExternalPage, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ExternalPage, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -713,27 +704,27 @@ export class AiContentClient { /** * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. * - * @param {Intercom.unstable.DeleteExternalPageRequest} request + * @param {Intercom.preview.DeleteExternalPageRequest} request * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.aiContent.deleteExternalPage({ + * await client.preview.aiContent.deleteExternalPage({ * id: "id" * }) */ public deleteExternalPage( - request: Intercom.unstable.DeleteExternalPageRequest, + request: Intercom.preview.DeleteExternalPageRequest, requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteExternalPage(request, requestOptions)); } private async __deleteExternalPage( - request: Intercom.unstable.DeleteExternalPageRequest, + request: Intercom.preview.DeleteExternalPageRequest, requestOptions?: AiContentClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -759,14 +750,14 @@ export class AiContentClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ExternalPage, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ExternalPage, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/unstable/resources/admins/client/index.ts b/src/api/resources/preview/resources/aiContent/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/admins/client/index.ts rename to src/api/resources/preview/resources/aiContent/client/index.ts diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts b/src/api/resources/preview/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts similarity index 60% rename from src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts rename to src/api/resources/preview/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts index f487b162..d42281b0 100644 --- a/src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts +++ b/src/api/resources/preview/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts @@ -11,6 +11,8 @@ export interface CreateContentImportSourceRequest { status?: CreateContentImportSourceRequest.Status; /** The URL of the content import source. */ url: string; + /** The unique identifiers for the audiences to associate with this content import source. Can be a single integer or an array of integers. */ + audience_ids?: CreateContentImportSourceRequest.AudienceIds; } export namespace CreateContentImportSourceRequest { @@ -20,4 +22,8 @@ export namespace CreateContentImportSourceRequest { Deactivated: "deactivated", } as const; export type Status = (typeof Status)[keyof typeof Status]; + /** + * The unique identifiers for the audiences to associate with this content import source. Can be a single integer or an array of integers. + */ + export type AudienceIds = number | number[]; } diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts b/src/api/resources/preview/resources/aiContent/client/requests/CreateExternalPageRequest.ts similarity index 89% rename from src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts rename to src/api/resources/preview/resources/aiContent/client/requests/CreateExternalPageRequest.ts index c4f5e914..13219b15 100644 --- a/src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts +++ b/src/api/resources/preview/resources/aiContent/client/requests/CreateExternalPageRequest.ts @@ -21,6 +21,8 @@ export interface CreateExternalPageRequest { ai_agent_availability?: boolean; /** Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page. */ ai_copilot_availability?: boolean; + /** Whether the external page should be used to answer questions by AI Sales Agent. Will not default when updating an existing external page. */ + ai_sales_agent_availability?: boolean; /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ source_id: number; /** The identifier for the external page which was given by the source. Must be unique for the source. */ diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts b/src/api/resources/preview/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts rename to src/api/resources/preview/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/DeleteExternalPageRequest.ts b/src/api/resources/preview/resources/aiContent/client/requests/DeleteExternalPageRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/aiContent/client/requests/DeleteExternalPageRequest.ts rename to src/api/resources/preview/resources/aiContent/client/requests/DeleteExternalPageRequest.ts diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/GetContentImportSourceRequest.ts b/src/api/resources/preview/resources/aiContent/client/requests/GetContentImportSourceRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/aiContent/client/requests/GetContentImportSourceRequest.ts rename to src/api/resources/preview/resources/aiContent/client/requests/GetContentImportSourceRequest.ts diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/GetExternalPageRequest.ts b/src/api/resources/preview/resources/aiContent/client/requests/GetExternalPageRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/aiContent/client/requests/GetExternalPageRequest.ts rename to src/api/resources/preview/resources/aiContent/client/requests/GetExternalPageRequest.ts diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts b/src/api/resources/preview/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts similarity index 67% rename from src/api/resources/unstable/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts rename to src/api/resources/preview/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts index 48401914..6c9312d2 100644 --- a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts +++ b/src/api/resources/preview/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts @@ -17,6 +17,10 @@ export interface UpdateContentImportSourceRequest { status?: UpdateContentImportSourceRequest.Status; /** The URL of the content import source. This may only be different from the existing value if the sync behavior is API. */ url: string; + /** The unique identifiers for the audiences to associate with this content import source. Can be a single integer or an array of integers. Set to null or an empty array to remove all audiences. */ + audience_ids?: UpdateContentImportSourceRequest.AudienceIds; + /** When true, the audience will be applied to all existing external pages belonging to this content import source. */ + apply_audience_to_existing_content?: boolean; } export namespace UpdateContentImportSourceRequest { @@ -33,4 +37,8 @@ export namespace UpdateContentImportSourceRequest { Deactivated: "deactivated", } as const; export type Status = (typeof Status)[keyof typeof Status]; + /** + * The unique identifiers for the audiences to associate with this content import source. Can be a single integer or an array of integers. Set to null or an empty array to remove all audiences. + */ + export type AudienceIds = number | number[]; } diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts b/src/api/resources/preview/resources/aiContent/client/requests/UpdateExternalPageRequest.ts similarity index 76% rename from src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts rename to src/api/resources/preview/resources/aiContent/client/requests/UpdateExternalPageRequest.ts index ccfddc5e..580f1a3a 100644 --- a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts +++ b/src/api/resources/preview/resources/aiContent/client/requests/UpdateExternalPageRequest.ts @@ -20,7 +20,13 @@ export interface UpdateExternalPageRequest { html: string; /** The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. */ url: string; - /** Whether the external page should be used to answer questions by Fin. */ + /** Whether the external page should be used to answer questions by AI Agent. */ + ai_agent_availability?: boolean; + /** Whether the external page should be used to answer questions by AI Copilot. */ + ai_copilot_availability?: boolean; + /** Whether the external page should be used to answer questions by AI Sales Agent. */ + ai_sales_agent_availability?: boolean; + /** Deprecated. Use ai_agent_availability, ai_copilot_availability, and ai_sales_agent_availability instead. */ fin_availability?: boolean; /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ source_id: number; diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/index.ts b/src/api/resources/preview/resources/aiContent/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/aiContent/client/requests/index.ts rename to src/api/resources/preview/resources/aiContent/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/aiContent/index.ts b/src/api/resources/preview/resources/aiContent/index.ts similarity index 100% rename from src/api/resources/unstable/resources/aiContent/index.ts rename to src/api/resources/preview/resources/aiContent/index.ts diff --git a/src/api/resources/preview/resources/aiContent/types/index.ts b/src/api/resources/preview/resources/aiContent/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/aiContent/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/aiContent/types/types.ts b/src/api/resources/preview/resources/aiContent/types/types.ts new file mode 100644 index 00000000..a25d98f5 --- /dev/null +++ b/src/api/resources/preview/resources/aiContent/types/types.ts @@ -0,0 +1,105 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * An external source for External Pages that you add to your Fin Content Library. + */ +export interface ContentImportSource { + /** Always external_page */ + type: "content_import_source"; + /** The unique identifier for the content import source which is given by Intercom. */ + id: number; + /** The time when the content import source was last synced. */ + last_synced_at: number; + /** If you intend to create or update External Pages via the API, this should be set to `api`. */ + sync_behavior: ContentImportSource.SyncBehavior; + /** The status of the content import source. */ + status: ContentImportSource.Status; + /** The URL of the root of the external source. */ + url: string; + /** The time when the content import source was created. */ + created_at: number; + /** The time when the content import source was last updated. */ + updated_at: number; + /** The unique identifiers for the audiences associated with this content import source. */ + audience_ids?: number[]; +} + +export namespace ContentImportSource { + /** If you intend to create or update External Pages via the API, this should be set to `api`. */ + export const SyncBehavior = { + Api: "api", + Automatic: "automatic", + Manual: "manual", + } as const; + export type SyncBehavior = (typeof SyncBehavior)[keyof typeof SyncBehavior]; + /** The status of the content import source. */ + export const Status = { + Active: "active", + Deactivated: "deactivated", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +/** + * This will return a list of the content import sources for the App. + */ +export interface ContentImportSourcesList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.preview.PagesLink; + /** A count of the total number of content import sources. */ + total_count?: number; + /** An array of Content Import Source objects */ + data?: Intercom.preview.ContentImportSource[]; +} + +/** + * External pages that you have added to your Fin Content Library. + */ +export interface ExternalPage { + /** Always external_page */ + type: "external_page"; + /** The unique identifier for the external page which is given by Intercom. */ + id: string; + /** The title of the external page. */ + title: string; + /** The body of the external page in HTML. */ + html: string; + /** The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. */ + url?: string; + /** Whether the external page should be used to answer questions by AI Agent. */ + ai_agent_availability: boolean; + /** Whether the external page should be used to answer questions by AI Copilot. */ + ai_copilot_availability: boolean; + /** Whether the external page should be used to answer questions by AI Sales Agent. */ + ai_sales_agent_availability?: boolean; + /** Deprecated. Use ai_agent_availability, ai_copilot_availability, and ai_sales_agent_availability instead. */ + fin_availability?: boolean; + /** Always en */ + locale: "en"; + /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ + source_id: number; + /** The identifier for the external page which was given by the source. Must be unique for the source. */ + external_id: string; + /** The time when the external page was created. */ + created_at: number; + /** The time when the external page was last updated. */ + updated_at: number; + /** The time when the external page was last ingested. */ + last_ingested_at: number; +} + +/** + * This will return a list of external pages for the App. + */ +export interface ExternalPagesList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.preview.PagesLink; + /** A count of the total number of external pages. */ + total_count?: number; + /** An array of External Page objects */ + data?: Intercom.preview.ExternalPage[]; +} diff --git a/src/api/resources/unstable/resources/aiContentSource/index.ts b/src/api/resources/preview/resources/aiContentSource/index.ts similarity index 100% rename from src/api/resources/unstable/resources/aiContentSource/index.ts rename to src/api/resources/preview/resources/aiContentSource/index.ts diff --git a/src/api/resources/preview/resources/aiContentSource/types/index.ts b/src/api/resources/preview/resources/aiContentSource/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/aiContentSource/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts b/src/api/resources/preview/resources/aiContentSource/types/types.ts similarity index 95% rename from src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts rename to src/api/resources/preview/resources/aiContentSource/types/types.ts index 9b504015..4702b980 100644 --- a/src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts +++ b/src/api/resources/preview/resources/aiContentSource/types/types.ts @@ -22,6 +22,7 @@ export namespace ContentSource { ExternalContent: "external_content", ContentSnippet: "content_snippet", WorkflowConnectorAction: "workflow_connector_action", + InternalArticle: "internal_article", } as const; export type ContentType = (typeof ContentType)[keyof typeof ContentType]; } diff --git a/src/api/resources/preview/resources/aiTopics/index.ts b/src/api/resources/preview/resources/aiTopics/index.ts new file mode 100644 index 00000000..2f88e301 --- /dev/null +++ b/src/api/resources/preview/resources/aiTopics/index.ts @@ -0,0 +1 @@ +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/aiTopics/types/index.ts b/src/api/resources/preview/resources/aiTopics/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/aiTopics/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/aiTopics/types/types.ts b/src/api/resources/preview/resources/aiTopics/types/types.ts new file mode 100644 index 00000000..605773d6 --- /dev/null +++ b/src/api/resources/preview/resources/aiTopics/types/types.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * AI-generated topics and subtopics for the conversation. + */ +export interface AiTopics { + /** Always ai_topics. */ + type?: string; + /** The list of AI-generated topics for this conversation. */ + topics?: Intercom.preview.AiTopic[]; +} diff --git a/src/api/resources/preview/resources/articles/client/Client.ts b/src/api/resources/preview/resources/articles/client/Client.ts new file mode 100644 index 00000000..8511540d --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/Client.ts @@ -0,0 +1,1090 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace ArticlesClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Everything about your Articles + */ +export class ArticlesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ArticlesClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * You can fetch a list of all articles by making a GET request to `https://api.intercom.io/articles`. + * + * > 📘 How are the articles sorted and ordered? + * > + * > Articles will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated articles first. + * + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.articles.listArticles() + */ + public listArticles( + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listArticles(requestOptions)); + } + + private async __listArticles( + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "articles", + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ArticleList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles"); + } + + /** + * You can create a new article by making a POST request to `https://api.intercom.io/articles`. + * + * > 📘 Tags cannot be managed via the Articles API + * > + * > Article tags are read-only in responses. To create, update, or delete tags, use the Intercom UI or the Tags API endpoints. + * + * @param {unknown} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.articles.createArticle({ + * "key": "value" + * }) + */ + public createArticle( + request?: unknown, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createArticle(request, requestOptions)); + } + + private async __createArticle( + request?: unknown, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "articles", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Article, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/articles"); + } + + /** + * You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. + * + * @param {Intercom.preview.RetrieveArticleRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.articles.retrieveArticle({ + * id: 1 + * }) + */ + public retrieveArticle( + request: Intercom.preview.RetrieveArticleRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveArticle(request, requestOptions)); + } + + private async __retrieveArticle( + request: Intercom.preview.RetrieveArticleRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Article, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/{id}"); + } + + /** + * You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. + * + * @param {Intercom.preview.DeleteArticleRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.articles.deleteArticle({ + * id: 1 + * }) + */ + public deleteArticle( + request: Intercom.preview.DeleteArticleRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteArticle(request, requestOptions)); + } + + private async __deleteArticle( + request: Intercom.preview.DeleteArticleRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.DeletedArticleObject, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/articles/{id}"); + } + + /** + * Fetch the staged draft of a published article by making a GET request to + * `https://api.intercom.io/articles//draft`. The response is the article + * rendered with its draft content, leaving the live article untouched. + * + * A draft exists only when a published article has unpublished changes staged + * on top of it. Returns `404` when the article has no staged draft. + * + * Requires the `read_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.RetrieveArticleDraftRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.articles.retrieveArticleDraft({ + * id: 1 + * }) + */ + public retrieveArticleDraft( + request: Intercom.preview.RetrieveArticleDraftRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveArticleDraft(request, requestOptions)); + } + + private async __retrieveArticleDraft( + request: Intercom.preview.RetrieveArticleDraftRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(id)}/draft`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Article, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/{id}/draft"); + } + + /** + * Stage changes to a published article as a draft by making a PUT request to + * `https://api.intercom.io/articles//draft`. The live article remains + * unchanged until the draft is published. + * + * The article must already be published; staging a draft on an article that + * has never been published returns `422`. + * + * Only versioned text content (such as `title` and `body`) is staged. + * Non-versioned fields like AI availability are ignored, leaving the live + * values untouched. + * + * Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.StageArticleDraftRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.articles.stageArticleDraft({ + * id: 1, + * body: { + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

" + * } + * }) + */ + public stageArticleDraft( + request: Intercom.preview.StageArticleDraftRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__stageArticleDraft(request, requestOptions)); + } + + private async __stageArticleDraft( + request: Intercom.preview.StageArticleDraftRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { id, body: _body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(id)}/draft`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body != null ? _body : undefined, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Article, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/articles/{id}/draft"); + } + + /** + * Publish a staged draft by making a POST request to + * `https://api.intercom.io/articles//draft/publish`, promoting the draft + * content to live. + * + * On a single-language workspace no body is required. On a multilingual + * workspace you must list which locales to publish via the `locales` array; + * omitting it returns `422`. Returns `422` when there is no staged draft to + * publish, or when a requested locale has no pending changes. + * + * Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.PublishArticleDraftRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.articles.publishArticleDraft({ + * id: 1, + * body: { + * locales: ["en", "fr"] + * } + * }) + */ + public publishArticleDraft( + request: Intercom.preview.PublishArticleDraftRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__publishArticleDraft(request, requestOptions)); + } + + private async __publishArticleDraft( + request: Intercom.preview.PublishArticleDraftRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { id, body: _body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(id)}/draft/publish`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body != null ? _body : undefined, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Article, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/articles/{id}/draft/publish"); + } + + /** + * Fetch the version history of an article by making a GET request to + * `https://api.intercom.io/articles//versions`. Versions are + * returned newest-first as a paginated list of metadata. Use + * `GET /articles/{article_id}/versions/{id}` to retrieve a single version + * with its full content. + * + * Requires the `read_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.ListArticleVersionsRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.articles.listVersions({ + * article_id: 1, + * page: 1, + * per_page: 1, + * locale: "en" + * }) + */ + public async listVersions( + request: Intercom.preview.ListArticleVersionsRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Intercom.preview.ListArticleVersionsRequest, + ): Promise> => { + const { article_id: articleId, page, per_page: perPage, locale } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams.page = page.toString(); + } + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + if (locale != null) { + _queryParams.locale = locale; + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(articleId)}/versions`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ArticleVersionList, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError( + _response.error.body as unknown, + _response.rawResponse, + ); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/articles/{article_id}/versions", + ); + }, + ); + let _offset = request?.page != null ? request?.page : 1; + const dataWithRawResponse = await list(request).withRawResponse(); + return new core.Page({ + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, + hasNextPage: (response) => (response?.data ?? []).length > 0, + getItems: (response) => response?.data ?? [], + loadPage: (_response) => { + _offset += 1; + return list(core.setObjectProperty(request, "page", _offset)); + }, + }); + } + + /** + * Fetch a single prior version of an article, including its body content, + * by making a GET request to + * `https://api.intercom.io/articles//versions/`. Returns + * the version's full content; the live article remains untouched. + * + * Requires the `read_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.FindArticleVersionRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.articles.findVersion({ + * article_id: 1, + * id: "301", + * locale: "en" + * }) + */ + public findVersion( + request: Intercom.preview.FindArticleVersionRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__findVersion(request, requestOptions)); + } + + private async __findVersion( + request: Intercom.preview.FindArticleVersionRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { article_id: articleId, id, locale } = request; + const _queryParams: Record = {}; + if (locale != null) { + _queryParams.locale = locale; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(articleId)}/versions/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ArticleVersion, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/articles/{article_id}/versions/{id}", + ); + } + + /** + * Apply an existing tag to an article. Returns the tag that was applied. + * + * The tag must already exist in the workspace (create tags with the Tags API), + * and the authenticating teammate must have the `manage_knowledge_base_content` + * permission. + * + * Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.AttachTagToArticleRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.articles.attachTagToArticle({ + * article_id: 1, + * id: "7522907" + * }) + */ + public attachTagToArticle( + request: Intercom.preview.AttachTagToArticleRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachTagToArticle(request, requestOptions)); + } + + private async __attachTagToArticle( + request: Intercom.preview.AttachTagToArticleRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { article_id: articleId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(articleId)}/tags`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/articles/{article_id}/tags"); + } + + /** + * Remove a tag from an article. Returns the tag that was removed, with null + * `applied_at` and `applied_by`. + * + * The authenticating teammate must have the `manage_knowledge_base_content` + * permission. + * + * Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.DetachTagFromArticleRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.articles.detachTagFromArticle({ + * article_id: 1, + * id: "7522907" + * }) + */ + public detachTagFromArticle( + request: Intercom.preview.DetachTagFromArticleRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachTagFromArticle(request, requestOptions)); + } + + private async __detachTagFromArticle( + request: Intercom.preview.DetachTagFromArticleRequest, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { article_id: articleId, id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${core.url.encodePathParam(articleId)}/tags/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/articles/{article_id}/tags/{id}", + ); + } + + /** + * You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. + * + * @param {Intercom.preview.SearchArticlesRequest} request + * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.articles.searchArticles({ + * phrase: "Getting started", + * state: "published", + * help_center_id: 1, + * highlight: true + * }) + */ + public searchArticles( + request: Intercom.preview.SearchArticlesRequest = {}, + requestOptions?: ArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchArticles(request, requestOptions)); + } + + private async __searchArticles( + request: Intercom.preview.SearchArticlesRequest = {}, + requestOptions?: ArticlesClient.RequestOptions, + ): Promise> { + const { phrase, state, help_center_id: helpCenterId, highlight } = request; + const _queryParams: Record = {}; + if (phrase != null) { + _queryParams.phrase = phrase; + } + + if (state != null) { + _queryParams.state = state; + } + + if (helpCenterId != null) { + _queryParams.help_center_id = helpCenterId.toString(); + } + + if (highlight != null) { + _queryParams.highlight = highlight.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "articles/search", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ArticleSearchResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/search"); + } +} diff --git a/src/api/resources/unstable/resources/aiContent/client/index.ts b/src/api/resources/preview/resources/articles/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/aiContent/client/index.ts rename to src/api/resources/preview/resources/articles/client/index.ts diff --git a/src/api/resources/preview/resources/articles/client/requests/AttachTagToArticleRequest.ts b/src/api/resources/preview/resources/articles/client/requests/AttachTagToArticleRequest.ts new file mode 100644 index 00000000..5c544b0d --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/requests/AttachTagToArticleRequest.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * article_id: 1, + * id: "7522907" + * } + */ +export interface AttachTagToArticleRequest { + /** The unique identifier for the article which is given by Intercom. */ + article_id: number; + /** The unique identifier of the tag to apply, as given by Intercom. */ + id: string; + /** Optional id of the teammate to attribute the tagging to. Defaults to the authenticating teammate. Does not affect authorization. */ + admin_id?: string; +} diff --git a/src/api/resources/unstable/resources/articles/client/requests/DeleteArticleRequest.ts b/src/api/resources/preview/resources/articles/client/requests/DeleteArticleRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/articles/client/requests/DeleteArticleRequest.ts rename to src/api/resources/preview/resources/articles/client/requests/DeleteArticleRequest.ts diff --git a/src/api/resources/preview/resources/articles/client/requests/DetachTagFromArticleRequest.ts b/src/api/resources/preview/resources/articles/client/requests/DetachTagFromArticleRequest.ts new file mode 100644 index 00000000..6b4946ba --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/requests/DetachTagFromArticleRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * article_id: 1, + * id: "7522907" + * } + */ +export interface DetachTagFromArticleRequest { + /** The unique identifier for the article which is given by Intercom. */ + article_id: number; + /** The unique identifier of the tag to remove, as given by Intercom. */ + id: string; +} diff --git a/src/api/resources/preview/resources/articles/client/requests/FindArticleVersionRequest.ts b/src/api/resources/preview/resources/articles/client/requests/FindArticleVersionRequest.ts new file mode 100644 index 00000000..1612ed82 --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/requests/FindArticleVersionRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * article_id: 1, + * id: "301", + * locale: "en" + * } + */ +export interface FindArticleVersionRequest { + /** The unique identifier for the article. */ + article_id: number; + /** The unique identifier for the version. */ + id: string; + /** Return the version's content for a specific locale. If the locale is not configured for the workspace, a `400` is returned. */ + locale?: string; +} diff --git a/src/api/resources/preview/resources/articles/client/requests/ListArticleVersionsRequest.ts b/src/api/resources/preview/resources/articles/client/requests/ListArticleVersionsRequest.ts new file mode 100644 index 00000000..cc2643f5 --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/requests/ListArticleVersionsRequest.ts @@ -0,0 +1,21 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * article_id: 1, + * page: 1, + * per_page: 1, + * locale: "en" + * } + */ +export interface ListArticleVersionsRequest { + /** The unique identifier for the article whose versions you are listing. */ + article_id: number; + /** The page of results to fetch. Defaults to the first page. */ + page?: number; + /** The number of results to return per page. */ + per_page?: number; + /** Filter versions to a specific locale. Use the locale identifier (for example `en`, `fr`). If the locale is not configured for the workspace, a `400` is returned. */ + locale?: string; +} diff --git a/src/api/resources/preview/resources/articles/client/requests/PublishArticleDraftRequest.ts b/src/api/resources/preview/resources/articles/client/requests/PublishArticleDraftRequest.ts new file mode 100644 index 00000000..b0ebe5d4 --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/requests/PublishArticleDraftRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * id: 1, + * body: { + * locales: ["en", "fr"] + * } + * } + */ +export interface PublishArticleDraftRequest { + /** The unique identifier for the article which is given by Intercom. */ + id: number; + body?: Intercom.preview.PublishArticleDraftRequestBody; +} diff --git a/src/api/resources/preview/resources/articles/client/requests/RetrieveArticleDraftRequest.ts b/src/api/resources/preview/resources/articles/client/requests/RetrieveArticleDraftRequest.ts new file mode 100644 index 00000000..70c8e1eb --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/requests/RetrieveArticleDraftRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1 + * } + */ +export interface RetrieveArticleDraftRequest { + /** The unique identifier for the article which is given by Intercom. */ + id: number; +} diff --git a/src/api/resources/unstable/resources/articles/client/requests/RetrieveArticleRequest.ts b/src/api/resources/preview/resources/articles/client/requests/RetrieveArticleRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/articles/client/requests/RetrieveArticleRequest.ts rename to src/api/resources/preview/resources/articles/client/requests/RetrieveArticleRequest.ts diff --git a/src/api/resources/unstable/resources/articles/client/requests/SearchArticlesRequest.ts b/src/api/resources/preview/resources/articles/client/requests/SearchArticlesRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/articles/client/requests/SearchArticlesRequest.ts rename to src/api/resources/preview/resources/articles/client/requests/SearchArticlesRequest.ts diff --git a/src/api/resources/preview/resources/articles/client/requests/StageArticleDraftRequest.ts b/src/api/resources/preview/resources/articles/client/requests/StageArticleDraftRequest.ts new file mode 100644 index 00000000..dfb21c11 --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/requests/StageArticleDraftRequest.ts @@ -0,0 +1,19 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * id: 1, + * body: { + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

" + * } + * } + */ +export interface StageArticleDraftRequest { + /** The unique identifier for the article which is given by Intercom. */ + id: number; + body?: Intercom.preview.UpdateArticleRequestBody; +} diff --git a/src/api/resources/preview/resources/articles/client/requests/index.ts b/src/api/resources/preview/resources/articles/client/requests/index.ts new file mode 100644 index 00000000..ebb96f4f --- /dev/null +++ b/src/api/resources/preview/resources/articles/client/requests/index.ts @@ -0,0 +1,10 @@ +export type { AttachTagToArticleRequest } from "./AttachTagToArticleRequest.js"; +export type { DeleteArticleRequest } from "./DeleteArticleRequest.js"; +export type { DetachTagFromArticleRequest } from "./DetachTagFromArticleRequest.js"; +export type { FindArticleVersionRequest } from "./FindArticleVersionRequest.js"; +export type { ListArticleVersionsRequest } from "./ListArticleVersionsRequest.js"; +export type { PublishArticleDraftRequest } from "./PublishArticleDraftRequest.js"; +export type { RetrieveArticleDraftRequest } from "./RetrieveArticleDraftRequest.js"; +export type { RetrieveArticleRequest } from "./RetrieveArticleRequest.js"; +export type { SearchArticlesRequest } from "./SearchArticlesRequest.js"; +export type { StageArticleDraftRequest } from "./StageArticleDraftRequest.js"; diff --git a/src/api/resources/unstable/resources/articles/index.ts b/src/api/resources/preview/resources/articles/index.ts similarity index 100% rename from src/api/resources/unstable/resources/articles/index.ts rename to src/api/resources/preview/resources/articles/index.ts diff --git a/src/api/resources/preview/resources/articles/types/index.ts b/src/api/resources/preview/resources/articles/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/articles/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/articles/types/types.ts b/src/api/resources/preview/resources/articles/types/types.ts new file mode 100644 index 00000000..641716c8 --- /dev/null +++ b/src/api/resources/preview/resources/articles/types/types.ts @@ -0,0 +1,259 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * The Articles API is a central place to gather all information and take actions on your articles. Articles can live within collections and sections, or alternatively they can stand alone. + */ +export interface Article extends Intercom.preview.ArticleListItem { + statistics?: Intercom.preview.ArticleStatistics; +} + +/** + * The Internal Articles API is a central place to gather all information and take actions on your internal articles. + */ +export type InternalArticle = Intercom.preview.InternalArticleListItem; + +/** + * The data returned about your articles when you list them. + */ +export interface ArticleListItem { + /** The type of object - `article`. */ + type?: "article"; + /** The unique identifier for the article which is given by Intercom. */ + id?: string; + /** The id of the workspace which the article belongs to. */ + workspace_id?: string; + /** The title of the article. For multilingual articles, this will be the title of the default language's content. */ + title?: string; + /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ + description?: string; + /** The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. */ + body?: string; + /** The body of the article in markdown. For multilingual articles, this will be the body of the default language's content. */ + body_markdown?: string; + /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ + author_id?: number; + /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ + state?: ArticleListItem.State; + /** The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. */ + created_at?: number; + /** The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. */ + updated_at?: number; + /** Whether the published article has unpublished changes staged as a draft on top of its live content. Only returned on the `Preview` API version. For multilingual articles this reflects the default language's content; a pure draft (never published) reports `false`. */ + has_unpublished_changes?: boolean; + /** The time, in seconds, when the staged draft was last edited, or `null` when there is no staged draft. Only returned on the `Preview` API version. */ + draft_updated_at?: number; + /** The URL of the article. For multilingual articles, this will be the URL of the default language's content. */ + url?: string; + /** The ids of the article's parent collections or sections. An article without this field stands alone. */ + parent_ids?: number[]; + /** The default locale of the help center. This field is only returned for multilingual help centers. */ + default_locale?: string; + translated_content?: Intercom.preview.ArticleTranslatedContent; + tags?: Intercom.preview.Tags; + /** The ID of the folder this article belongs to, or null if not in a folder. */ + folder_id?: number; + /** Whether the article is available for AI Chatbot. For multilingual articles, this will be the value of the default language's content. */ + ai_chatbot_availability?: boolean; + /** Whether the article is available for AI Copilot. For multilingual articles, this will be the value of the default language's content. */ + ai_copilot_availability?: boolean; + /** Whether the article is available for AI Sales Agent. For multilingual articles, this will be the value of the default language's content. */ + ai_sales_agent_availability?: boolean; + /** The ID of the teammate who created the article. For multilingual articles, this will be the creator of the default language's content. */ + created_by_id?: number; + /** The ID of the teammate who last updated the article. For multilingual articles, this will be the last editor of the default language's content. */ + updated_by_id?: number; + /** Whether the article is excluded from Fin AI Agent article suggestions. */ + exclude_from_article_suggestions?: boolean; + /** The audience that can view this article in the Help Center. `everyone` means all users and visitors can view it; `restricted` indicates a custom audience ruleset. For multilingual articles, this is the article-level audience. */ + help_center_audience?: ArticleListItem.HelpCenterAudience; + /** The Unix timestamp (in seconds) at which the article is scheduled to be published. `null` when no publish is scheduled. Mutually exclusive with `scheduled_unpublish_at` — at most one pending schedule exists per article. */ + scheduled_publish_at?: number; + /** The Unix timestamp (in seconds) at which the article is scheduled to be unpublished. `null` when no unpublish is scheduled. Mutually exclusive with `scheduled_publish_at` — at most one pending schedule exists per article. */ + scheduled_unpublish_at?: number; +} + +export namespace ArticleListItem { + /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; + /** The audience that can view this article in the Help Center. `everyone` means all users and visitors can view it; `restricted` indicates a custom audience ruleset. For multilingual articles, this is the article-level audience. */ + export const HelpCenterAudience = { + Everyone: "everyone", + AllUsers: "all_users", + AllVisitors: "all_visitors", + AllLeads: "all_leads", + AllVisitorsAndLeads: "all_visitors_and_leads", + Restricted: "restricted", + } as const; + export type HelpCenterAudience = (typeof HelpCenterAudience)[keyof typeof HelpCenterAudience]; +} + +/** + * The highlighted results of an Article search. In the examples provided my search query is always "my query". + */ +export interface ArticleSearchHighlights { + /** The ID of the corresponding article. */ + article_id?: string; + /** An Article title highlighted. */ + highlighted_title?: ArticleSearchHighlights.HighlightedTitle.Item[]; + /** An Article description and body text highlighted. */ + highlighted_summary?: ArticleSearchHighlights.HighlightedSummary.Item[][]; +} + +export namespace ArticleSearchHighlights { + export type HighlightedTitle = HighlightedTitle.Item[]; + + export namespace HighlightedTitle { + /** + * A highlighted article title. + */ + export interface Item { + /** The type of text - `highlight` or `plain`. */ + type?: Item.Type; + /** The text of the title. */ + text?: string; + } + + export namespace Item { + /** The type of text - `highlight` or `plain`. */ + export const Type = { + Highlight: "highlight", + Plain: "plain", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } + + export type HighlightedSummary = HighlightedSummary.Item[]; + + export namespace HighlightedSummary { + /** + * An instance of highlighted summary text. + */ + export interface Item { + /** The type of text - `highlight` or `plain`. */ + type?: Item.Type; + /** The text of the title. */ + text?: string; + } + + export namespace Item { + /** The type of text - `highlight` or `plain`. */ + export const Type = { + Highlight: "highlight", + Plain: "plain", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } +} + +/** + * The results of an Article search + */ +export interface ArticleSearchResponse { + /** The type of the object - `list`. */ + type?: "list"; + /** The total number of Articles matching the search query */ + total_count?: number; + /** An object containing the results of the search. */ + data?: ArticleSearchResponse.Data; + pages?: Intercom.preview.CursorPages; +} + +export namespace ArticleSearchResponse { + /** + * An object containing the results of the search. + */ + export interface Data { + /** An array of Article objects */ + articles?: Intercom.preview.Article[]; + /** A corresponding array of highlighted Article content */ + highlights?: Intercom.preview.ArticleSearchHighlights[]; + } +} + +/** + * A historical version of an article, including its content. + */ +export interface ArticleVersion { + /** String representing the object's type. Always has the value `article_version`. */ + type?: "article_version"; + /** The unique identifier for the version. */ + id?: string; + /** The unique identifier of the article this version belongs to. */ + article_id?: string; + /** The title of the article at this version. */ + title?: string; + /** The description of the article at this version. */ + description?: string; + /** The HTML body of the article at this version. */ + body?: string; + /** The Markdown body of the article at this version. */ + body_markdown?: string; + /** The id of the teammate listed as the article's author at this version. */ + author_id?: string; + /** The id of the teammate who created this version. */ + created_by_id?: string; + /** How this version was created (for example `web`, `api`). */ + created_via?: string; + /** The id of the version this version was created from, or `null` if this is the first version. */ + from_version_id?: string; + /** Whether this version is the currently published version of the article (`published`) or an earlier non-live version (`draft`). */ + state?: ArticleVersion.State; + /** The time the version was created, as a UTC Unix timestamp. */ + created_at?: number; + /** The time the version was last updated, as a UTC Unix timestamp. */ + updated_at?: number; +} + +export namespace ArticleVersion { + /** Whether this version is the currently published version of the article (`published`) or an earlier non-live version (`draft`). */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * A metadata summary of an article version, as returned by the version-history list endpoint. Omits the version's body content - fetch a single version to retrieve its `body` and `body_markdown`. + */ +export interface ArticleVersionSummary { + /** String representing the object's type. Always has the value `article_version`. */ + type?: "article_version"; + /** The unique identifier for the version. */ + id?: string; + /** The unique identifier of the article this version belongs to. */ + article_id?: string; + /** The title of the article at this version. */ + title?: string; + /** The description of the article at this version. */ + description?: string; + /** The id of the teammate listed as the article's author at this version. */ + author_id?: string; + /** The id of the teammate who created this version. */ + created_by_id?: string; + /** How this version was created (for example `web`, `api`). */ + created_via?: string; + /** The id of the version this version was created from, or `null` if this is the first version. */ + from_version_id?: string; + /** Whether this version is the currently published version of the article (`published`) or an earlier non-live version (`draft`). */ + state?: ArticleVersionSummary.State; + /** The time the version was created, as a UTC Unix timestamp. */ + created_at?: number; +} + +export namespace ArticleVersionSummary { + /** Whether this version is the currently published version of the article (`published`) or an earlier non-live version (`draft`). */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; +} diff --git a/src/api/resources/unstable/resources/admins/client/Client.ts b/src/api/resources/preview/resources/audiences/client/Client.ts similarity index 52% rename from src/api/resources/unstable/resources/admins/client/Client.ts rename to src/api/resources/preview/resources/audiences/client/Client.ts index ece2566e..b8f57837 100644 --- a/src/api/resources/unstable/resources/admins/client/Client.ts +++ b/src/api/resources/preview/resources/audiences/client/Client.ts @@ -9,44 +9,57 @@ import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStat import * as errors from "../../../../../../errors/index.js"; import * as Intercom from "../../../../../index.js"; -export declare namespace AdminsClient { +export declare namespace AudiencesClient { export interface Options extends BaseClientOptions {} export interface RequestOptions extends BaseRequestOptions {} } /** - * Everything about your Admins + * Everything about your Audiences */ -export class AdminsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class AudiencesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; - constructor(options: AdminsClient.Options = {}) { + constructor(options: AudiencesClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } /** + * You can fetch a list of all audiences for the workspace. * - * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + * @param {Intercom.preview.ListAudiencesRequest} request + * @param {AudiencesClient.RequestOptions} requestOptions - Request-specific configuration. * - * > 🚧 Single Sign On - * > - * > If you are building a custom "Log in with Intercom" flow for your site, and you call the `/me` endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk. - * - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.admins.identifyAdmin() + * await client.preview.audiences.listAudiences({ + * page: 1, + * per_page: 1 + * }) */ - public identifyAdmin( - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__identifyAdmin(requestOptions)); + public listAudiences( + request: Intercom.preview.ListAudiencesRequest = {}, + requestOptions?: AudiencesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAudiences(request, requestOptions)); } - private async __identifyAdmin( - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { + private async __listAudiences( + request: Intercom.preview.ListAudiencesRequest = {}, + requestOptions?: AudiencesClient.RequestOptions, + ): Promise> { + const { page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -59,11 +72,11 @@ export class AdminsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "me", + "audiences", ), method: "GET", headers: _headers, - queryParameters: requestOptions?.queryParams, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -71,60 +84,65 @@ export class AdminsClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.AdminWithApp | undefined, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.AudienceList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/me"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/audiences"); } /** - * You can set an Admin as away for the Inbox. - * - * @param {Intercom.unstable.SetAwayAdminRequest} request - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * You can create a new audience by making a POST request to `https://api.intercom.io/audiences`. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @param {Intercom.preview.CreateAudienceRequest} request + * @param {AudiencesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @example - * await client.unstable.admins.setAwayAdmin({ - * id: 1, - * away_mode_enabled: true, - * away_mode_reassign: true, - * away_status_reason_id: 12345 - * }) + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.admins.setAwayAdmin({ - * id: 1, - * away_mode_enabled: true, - * away_mode_reassign: true + * await client.preview.audiences.createAudience({ + * name: "VIP Customers", + * predicates: [{ + * attribute: "company.name", + * type: "string", + * comparison: "contains", + * value: "Acme" + * }], + * role_predicates: [{ + * attribute: "role", + * type: "role", + * comparison: "eq", + * value: "user" + * }] * }) */ - public setAwayAdmin( - request: Intercom.unstable.SetAwayAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__setAwayAdmin(request, requestOptions)); + public createAudience( + request: Intercom.preview.CreateAudienceRequest, + requestOptions?: AudiencesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createAudience(request, requestOptions)); } - private async __setAwayAdmin( - request: Intercom.unstable.SetAwayAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; + private async __createAudience( + request: Intercom.preview.CreateAudienceRequest, + requestOptions?: AudiencesClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -137,14 +155,14 @@ export class AdminsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `admins/${core.url.encodePathParam(id)}/away`, + "audiences", ), - method: "PUT", + method: "POST", headers: _headers, contentType: "application/json", queryParameters: requestOptions?.queryParams, requestType: "json", - body: _body, + body: request, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -152,20 +170,21 @@ export class AdminsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Admin | undefined, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Audience, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { - case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -175,41 +194,35 @@ export class AdminsClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/admins/{id}/away"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/audiences"); } /** - * You can get a log of activities by all admins in an app. + * You can fetch the details of a single audience by making a GET request to `https://api.intercom.io/audiences/{id}`. * - * @param {Intercom.unstable.ListActivityLogsRequest} request - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.RetrieveAudienceRequest} request + * @param {AudiencesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.admins.listActivityLogs({ - * created_at_after: "1677253093", - * created_at_before: "1677861493" + * await client.preview.audiences.retrieveAudience({ + * id: "123" * }) */ - public listActivityLogs( - request: Intercom.unstable.ListActivityLogsRequest, - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listActivityLogs(request, requestOptions)); + public retrieveAudience( + request: Intercom.preview.RetrieveAudienceRequest, + requestOptions?: AudiencesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveAudience(request, requestOptions)); } - private async __listActivityLogs( - request: Intercom.unstable.ListActivityLogsRequest, - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const { created_at_after: createdAtAfter, created_at_before: createdAtBefore } = request; - const _queryParams: Record = {}; - _queryParams.created_at_after = createdAtAfter; - if (createdAtBefore != null) { - _queryParams.created_at_before = createdAtBefore; - } - + private async __retrieveAudience( + request: Intercom.preview.RetrieveAudienceRequest, + requestOptions?: AudiencesClient.RequestOptions, + ): Promise> { + const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -222,11 +235,11 @@ export class AdminsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "admins/activity_logs", + `audiences/${core.url.encodePathParam(id)}`, ), method: "GET", headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + queryParameters: requestOptions?.queryParams, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -234,16 +247,18 @@ export class AdminsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ActivityLogList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Audience, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -253,28 +268,43 @@ export class AdminsClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins/activity_logs"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/audiences/{id}"); } /** - * You can fetch a list of admins for a given workspace. + * You can update the details of a single audience by making a PUT request to `https://api.intercom.io/audiences/{id}`. * - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.UpdateAudienceRequest} request + * @param {AudiencesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.admins.listAdmins() + * await client.preview.audiences.updateAudience({ + * id: "123", + * name: "Enterprise Accounts", + * predicates: [{ + * attribute: "custom_attributes.plan", + * type: "string", + * comparison: "eq", + * value: "enterprise" + * }] + * }) */ - public listAdmins( - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAdmins(requestOptions)); + public updateAudience( + request: Intercom.preview.UpdateAudienceRequest, + requestOptions?: AudiencesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateAudience(request, requestOptions)); } - private async __listAdmins( - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { + private async __updateAudience( + request: Intercom.preview.UpdateAudienceRequest, + requestOptions?: AudiencesClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -287,11 +317,14 @@ export class AdminsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "admins", + `audiences/${core.url.encodePathParam(id)}`, ), - method: "GET", + method: "PUT", headers: _headers, + contentType: "application/json", queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -299,14 +332,21 @@ export class AdminsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.AdminList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Audience, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); default: @@ -318,34 +358,34 @@ export class AdminsClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/audiences/{id}"); } /** - * You can retrieve the details of a single admin. + * You can delete a single audience by making a DELETE request to `https://api.intercom.io/audiences/{id}`. * - * @param {Intercom.unstable.RetrieveAdminRequest} request - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.DeleteAudienceRequest} request + * @param {AudiencesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.admins.retrieveAdmin({ - * id: 1 + * await client.preview.audiences.deleteAudience({ + * id: "123" * }) */ - public retrieveAdmin( - request: Intercom.unstable.RetrieveAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveAdmin(request, requestOptions)); + public deleteAudience( + request: Intercom.preview.DeleteAudienceRequest, + requestOptions?: AudiencesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteAudience(request, requestOptions)); } - private async __retrieveAdmin( - request: Intercom.unstable.RetrieveAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { + private async __deleteAudience( + request: Intercom.preview.DeleteAudienceRequest, + requestOptions?: AudiencesClient.RequestOptions, + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -359,9 +399,9 @@ export class AdminsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `admins/${core.url.encodePathParam(id)}`, + `audiences/${core.url.encodePathParam(id)}`, ), - method: "GET", + method: "DELETE", headers: _headers, queryParameters: requestOptions?.queryParams, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, @@ -371,18 +411,18 @@ export class AdminsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Admin | undefined, rawResponse: _response.rawResponse }; + return { data: undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -392,6 +432,6 @@ export class AdminsClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins/{id}"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/audiences/{id}"); } } diff --git a/src/api/resources/unstable/resources/articles/client/index.ts b/src/api/resources/preview/resources/audiences/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/articles/client/index.ts rename to src/api/resources/preview/resources/audiences/client/index.ts diff --git a/src/api/resources/preview/resources/audiences/client/requests/CreateAudienceRequest.ts b/src/api/resources/preview/resources/audiences/client/requests/CreateAudienceRequest.ts new file mode 100644 index 00000000..bece77b0 --- /dev/null +++ b/src/api/resources/preview/resources/audiences/client/requests/CreateAudienceRequest.ts @@ -0,0 +1,30 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * name: "VIP Customers", + * predicates: [{ + * attribute: "company.name", + * type: "string", + * comparison: "contains", + * value: "Acme" + * }], + * role_predicates: [{ + * attribute: "role", + * type: "role", + * comparison: "eq", + * value: "user" + * }] + * } + */ +export interface CreateAudienceRequest { + /** The name of the audience. */ + name: string; + /** The predicates that define which contacts belong to the audience. */ + predicates?: Intercom.preview.Predicate[]; + /** Role-based predicates that further filter audience membership by contact role. */ + role_predicates?: Intercom.preview.Predicate[]; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ShowContactRequest.ts b/src/api/resources/preview/resources/audiences/client/requests/DeleteAudienceRequest.ts similarity index 51% rename from src/api/resources/unstable/resources/contacts/client/requests/ShowContactRequest.ts rename to src/api/resources/preview/resources/audiences/client/requests/DeleteAudienceRequest.ts index 170a185f..1874e2a0 100644 --- a/src/api/resources/unstable/resources/contacts/client/requests/ShowContactRequest.ts +++ b/src/api/resources/preview/resources/audiences/client/requests/DeleteAudienceRequest.ts @@ -3,10 +3,10 @@ /** * @example * { - * id: "63a07ddf05a32042dffac965" + * id: "123" * } */ -export interface ShowContactRequest { - /** id */ +export interface DeleteAudienceRequest { + /** The unique identifier for the audience. */ id: string; } diff --git a/src/api/resources/preview/resources/audiences/client/requests/ListAudiencesRequest.ts b/src/api/resources/preview/resources/audiences/client/requests/ListAudiencesRequest.ts new file mode 100644 index 00000000..c9cad19b --- /dev/null +++ b/src/api/resources/preview/resources/audiences/client/requests/ListAudiencesRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * page: 1, + * per_page: 1 + * } + */ +export interface ListAudiencesRequest { + /** The page of results to fetch. Defaults to first page. */ + page?: number; + /** The number of results to return per page. Defaults to 50. Maximum is 50. */ + per_page?: number; +} diff --git a/src/api/resources/preview/resources/audiences/client/requests/RetrieveAudienceRequest.ts b/src/api/resources/preview/resources/audiences/client/requests/RetrieveAudienceRequest.ts new file mode 100644 index 00000000..e6d491f3 --- /dev/null +++ b/src/api/resources/preview/resources/audiences/client/requests/RetrieveAudienceRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123" + * } + */ +export interface RetrieveAudienceRequest { + /** The unique identifier for the audience. */ + id: string; +} diff --git a/src/api/resources/preview/resources/audiences/client/requests/UpdateAudienceRequest.ts b/src/api/resources/preview/resources/audiences/client/requests/UpdateAudienceRequest.ts new file mode 100644 index 00000000..458555dc --- /dev/null +++ b/src/api/resources/preview/resources/audiences/client/requests/UpdateAudienceRequest.ts @@ -0,0 +1,27 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * id: "123", + * name: "Enterprise Accounts", + * predicates: [{ + * attribute: "custom_attributes.plan", + * type: "string", + * comparison: "eq", + * value: "enterprise" + * }] + * } + */ +export interface UpdateAudienceRequest { + /** The unique identifier for the audience. */ + id: string; + /** The name of the audience. */ + name?: string; + /** The predicates that define which contacts belong to the audience. */ + predicates?: Intercom.preview.Predicate[]; + /** Role-based predicates that further filter audience membership by contact role. */ + role_predicates?: Intercom.preview.Predicate[]; +} diff --git a/src/api/resources/preview/resources/audiences/client/requests/index.ts b/src/api/resources/preview/resources/audiences/client/requests/index.ts new file mode 100644 index 00000000..6efe77b9 --- /dev/null +++ b/src/api/resources/preview/resources/audiences/client/requests/index.ts @@ -0,0 +1,5 @@ +export type { CreateAudienceRequest } from "./CreateAudienceRequest.js"; +export type { DeleteAudienceRequest } from "./DeleteAudienceRequest.js"; +export type { ListAudiencesRequest } from "./ListAudiencesRequest.js"; +export type { RetrieveAudienceRequest } from "./RetrieveAudienceRequest.js"; +export type { UpdateAudienceRequest } from "./UpdateAudienceRequest.js"; diff --git a/src/api/resources/unstable/resources/brands/index.ts b/src/api/resources/preview/resources/audiences/index.ts similarity index 100% rename from src/api/resources/unstable/resources/brands/index.ts rename to src/api/resources/preview/resources/audiences/index.ts diff --git a/src/api/resources/preview/resources/audiences/types/index.ts b/src/api/resources/preview/resources/audiences/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/audiences/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/audiences/types/types.ts b/src/api/resources/preview/resources/audiences/types/types.ts new file mode 100644 index 00000000..66264c74 --- /dev/null +++ b/src/api/resources/preview/resources/audiences/types/types.ts @@ -0,0 +1,23 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * An audience represents a group of contacts that can be targeted by Fin. + */ +export interface Audience { + /** The type of object. */ + type?: "audience"; + /** The unique identifier representing the audience. */ + id?: string; + /** The name of the audience. */ + name?: string; + /** The predicates that define which contacts belong to the audience. */ + predicates?: Intercom.preview.Predicate[]; + /** Role-based predicates that further filter audience membership by contact role. */ + role_predicates?: Intercom.preview.Predicate[]; + /** The time the audience was created as a Unix timestamp. */ + created_at?: number; + /** The time the audience was last updated as a Unix timestamp. */ + updated_at?: number; +} diff --git a/src/api/resources/preview/resources/authTokens/client/Client.ts b/src/api/resources/preview/resources/authTokens/client/Client.ts new file mode 100644 index 00000000..b7353352 --- /dev/null +++ b/src/api/resources/preview/resources/authTokens/client/Client.ts @@ -0,0 +1,366 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace AuthTokensClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Read and write the third-party credentials stored in your workspace, so you can find the + * id of the credential a data connector should authenticate with, and store a new one + * without leaving your integration. These endpoints are part of the `Preview` API version. + * Reading requires an OAuth token with the `read_auth_tokens` scope; creating and updating + * require the `write_auth_tokens` scope and an access token associated with a teammate. + * Only credentials with a `token_type` of `text` can be created or updated. No endpoint + * ever returns a credential value, refresh configuration, or OAuth configuration. + */ +export class AuthTokensClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: AuthTokensClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Returns a paginated list of the workspace's stored third-party credentials. Use this to discover the id of a credential you want a data connector to authenticate with — that id is not otherwise available over REST. Only metadata is returned; credential values are never exposed. The list is not exhaustive: credentials a teammate created are listed, as are those created by some Intercom integrations, but credentials installed by an app package, those created by most other integrations, and those minted for an individual teammate's MCP access are not. + * + * @param {Intercom.preview.ListAuthTokensRequest} request + * @param {AuthTokensClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.authTokens.listAuthTokens({ + * per_page: 1, + * starting_after: "starting_after" + * }) + */ + public listAuthTokens( + request: Intercom.preview.ListAuthTokensRequest = {}, + requestOptions?: AuthTokensClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAuthTokens(request, requestOptions)); + } + + private async __listAuthTokens( + request: Intercom.preview.ListAuthTokensRequest = {}, + requestOptions?: AuthTokensClient.RequestOptions, + ): Promise> { + const { per_page: perPage, starting_after: startingAfter } = request; + const _queryParams: Record = {}; + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (startingAfter != null) { + _queryParams.starting_after = startingAfter; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "auth_tokens", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.AuthTokenList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/auth_tokens"); + } + + /** + * Stores a third-party credential in your workspace so a data connector can authenticate outbound requests with it. Only credentials with a `token_type` of `text` can be created here — the credential value is sent as a request header. The value you supply is stored encrypted and is never returned by any endpoint, including this one. + * + * @param {Intercom.preview.CreateAuthTokenRequest} request + * @param {AuthTokensClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * + * @example + * await client.preview.authTokens.createAuthToken({ + * name: "Fulfilment API key", + * token_value: "sk_live_9f3c2a7b41e8", + * request_header_key: "Authorization", + * token_prefix: "Bearer", + * description: "Used by the order status connector", + * domain: "api.fulfilment.example.com" + * }) + */ + public createAuthToken( + request: Intercom.preview.CreateAuthTokenRequest, + requestOptions?: AuthTokensClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createAuthToken(request, requestOptions)); + } + + private async __createAuthToken( + request: Intercom.preview.CreateAuthTokenRequest, + requestOptions?: AuthTokensClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "auth_tokens", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.AuthToken, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/auth_tokens"); + } + + /** + * Returns the metadata for a single stored third-party credential. A credential that the list endpoint does not return is also not retrievable here, and responds with 404. + * + * @param {Intercom.preview.RetrieveAuthTokenRequest} request + * @param {AuthTokensClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.authTokens.retrieveAuthToken({ + * id: "12345" + * }) + */ + public retrieveAuthToken( + request: Intercom.preview.RetrieveAuthTokenRequest, + requestOptions?: AuthTokensClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveAuthToken(request, requestOptions)); + } + + private async __retrieveAuthToken( + request: Intercom.preview.RetrieveAuthTokenRequest, + requestOptions?: AuthTokensClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `auth_tokens/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.AuthToken, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/auth_tokens/{id}"); + } + + /** + * Updates the metadata of a stored third-party credential. A field you omit keeps its current value. The credential value itself cannot be changed here and is never returned. Only credentials with a `token_type` of `text` can be updated; any other type responds with `400`. A credential the list endpoint does not return is also not updatable, and responds with `404`. + * + * @param {Intercom.preview.UpdateAuthTokenRequest} request + * @param {AuthTokensClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.authTokens.updateAuthToken({ + * id: "12345", + * name: "Fulfilment API key (rotated host)", + * description: "Used by the order status connector" + * }) + */ + public updateAuthToken( + request: Intercom.preview.UpdateAuthTokenRequest, + requestOptions?: AuthTokensClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateAuthToken(request, requestOptions)); + } + + private async __updateAuthToken( + request: Intercom.preview.UpdateAuthTokenRequest, + requestOptions?: AuthTokensClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `auth_tokens/${core.url.encodePathParam(id)}`, + ), + method: "PATCH", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.AuthToken, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/auth_tokens/{id}"); + } +} diff --git a/src/api/resources/unstable/resources/brands/client/index.ts b/src/api/resources/preview/resources/authTokens/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/brands/client/index.ts rename to src/api/resources/preview/resources/authTokens/client/index.ts diff --git a/src/api/resources/preview/resources/authTokens/client/requests/CreateAuthTokenRequest.ts b/src/api/resources/preview/resources/authTokens/client/requests/CreateAuthTokenRequest.ts new file mode 100644 index 00000000..fcb147e4 --- /dev/null +++ b/src/api/resources/preview/resources/authTokens/client/requests/CreateAuthTokenRequest.ts @@ -0,0 +1,27 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * name: "Fulfilment API key", + * token_value: "sk_live_9f3c2a7b41e8", + * request_header_key: "Authorization", + * token_prefix: "Bearer", + * description: "Used by the order status connector", + * domain: "api.fulfilment.example.com" + * } + */ +export interface CreateAuthTokenRequest { + /** A name for the credential, so a teammate can identify it later. */ + name: string; + /** The credential value. Stored encrypted and never returned by any endpoint. */ + token_value: string; + /** The request header the credential is sent in. */ + request_header_key: string; + /** An optional prefix placed before the credential value in the header, for example `Bearer`. */ + token_prefix?: string; + /** An optional description of what the credential is used for. */ + description?: string; + /** An optional domain to scope the credential to. */ + domain?: string; +} diff --git a/src/api/resources/preview/resources/authTokens/client/requests/ListAuthTokensRequest.ts b/src/api/resources/preview/resources/authTokens/client/requests/ListAuthTokensRequest.ts new file mode 100644 index 00000000..c38cf8fa --- /dev/null +++ b/src/api/resources/preview/resources/authTokens/client/requests/ListAuthTokensRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * per_page: 1, + * starting_after: "starting_after" + * } + */ +export interface ListAuthTokensRequest { + /** The number of results to return per page. Defaults to 20, minimum 1, maximum 50. */ + per_page?: number; + /** The cursor value from `pages.next.starting_after` in a previous response. Used to paginate through results. */ + starting_after?: string; +} diff --git a/src/api/resources/preview/resources/authTokens/client/requests/RetrieveAuthTokenRequest.ts b/src/api/resources/preview/resources/authTokens/client/requests/RetrieveAuthTokenRequest.ts new file mode 100644 index 00000000..737de276 --- /dev/null +++ b/src/api/resources/preview/resources/authTokens/client/requests/RetrieveAuthTokenRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "12345" + * } + */ +export interface RetrieveAuthTokenRequest { + /** The unique identifier for the auth token. */ + id: string; +} diff --git a/src/api/resources/preview/resources/authTokens/client/requests/UpdateAuthTokenRequest.ts b/src/api/resources/preview/resources/authTokens/client/requests/UpdateAuthTokenRequest.ts new file mode 100644 index 00000000..ce95cf0a --- /dev/null +++ b/src/api/resources/preview/resources/authTokens/client/requests/UpdateAuthTokenRequest.ts @@ -0,0 +1,24 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "12345", + * name: "Fulfilment API key (rotated host)", + * description: "Used by the order status connector" + * } + */ +export interface UpdateAuthTokenRequest { + /** The unique identifier for the auth token. */ + id: string; + /** A name for the credential, so a teammate can identify it later. */ + name?: string; + /** The request header the credential is sent in. */ + request_header_key?: string; + /** An optional prefix placed before the credential value in the header, for example `Bearer`. */ + token_prefix?: string; + /** An optional description of what the credential is used for. */ + description?: string; + /** An optional domain to scope the credential to. */ + domain?: string; +} diff --git a/src/api/resources/preview/resources/authTokens/client/requests/index.ts b/src/api/resources/preview/resources/authTokens/client/requests/index.ts new file mode 100644 index 00000000..d8a63c46 --- /dev/null +++ b/src/api/resources/preview/resources/authTokens/client/requests/index.ts @@ -0,0 +1,4 @@ +export type { CreateAuthTokenRequest } from "./CreateAuthTokenRequest.js"; +export type { ListAuthTokensRequest } from "./ListAuthTokensRequest.js"; +export type { RetrieveAuthTokenRequest } from "./RetrieveAuthTokenRequest.js"; +export type { UpdateAuthTokenRequest } from "./UpdateAuthTokenRequest.js"; diff --git a/src/api/resources/unstable/resources/calls/index.ts b/src/api/resources/preview/resources/authTokens/index.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/index.ts rename to src/api/resources/preview/resources/authTokens/index.ts diff --git a/src/api/resources/preview/resources/authTokens/types/index.ts b/src/api/resources/preview/resources/authTokens/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/authTokens/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/authTokens/types/types.ts b/src/api/resources/preview/resources/authTokens/types/types.ts new file mode 100644 index 00000000..aedef91b --- /dev/null +++ b/src/api/resources/preview/resources/authTokens/types/types.ts @@ -0,0 +1,27 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Metadata for a stored third-party credential that data connectors use to authenticate outbound requests. Only metadata is returned — the credential value itself, and its refresh and OAuth configuration, are never exposed. + */ +export interface AuthToken { + /** The type of object - `auth_token`. */ + type?: "auth_token"; + /** The unique identifier for the auth token. */ + id?: string; + /** The name given to the credential when it was created. */ + name?: string; + /** An optional description of what the credential is used for. */ + description?: string; + /** How the credential is presented to the external API, for example as a header value or an HMAC signature. */ + token_type?: string; + /** The request header the credential is sent in. */ + request_header_key?: string; + /** The prefix placed before the credential value in the header, for example `Bearer`. */ + token_prefix?: string; + /** The domain the credential is scoped to, if one was set. */ + domain?: string; + /** The time the credential was created, as an ISO 8601 timestamp. */ + created_at?: string; + /** The time the credential was last updated, as an ISO 8601 timestamp. */ + updated_at?: string; +} diff --git a/src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts b/src/api/resources/preview/resources/awayStatusReasons/client/Client.ts similarity index 86% rename from src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts rename to src/api/resources/preview/resources/awayStatusReasons/client/Client.ts index 5be942d3..2596b9ea 100644 --- a/src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts +++ b/src/api/resources/preview/resources/awayStatusReasons/client/Client.ts @@ -30,20 +30,20 @@ export class AwayStatusReasonsClient { * * @param {AwayStatusReasonsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.awayStatusReasons.listAwayStatusReasons() + * await client.preview.awayStatusReasons.listAwayStatusReasons() */ public listAwayStatusReasons( requestOptions?: AwayStatusReasonsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listAwayStatusReasons(requestOptions)); } private async __listAwayStatusReasons( requestOptions?: AwayStatusReasonsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -68,14 +68,17 @@ export class AwayStatusReasonsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.AwayStatusReason[], rawResponse: _response.rawResponse }; + return { + data: _response.body as Intercom.preview.AwayStatusReasonList, + rawResponse: _response.rawResponse, + }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/unstable/resources/awayStatusReasons/client/index.ts b/src/api/resources/preview/resources/awayStatusReasons/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/awayStatusReasons/client/index.ts rename to src/api/resources/preview/resources/awayStatusReasons/client/index.ts diff --git a/src/api/resources/customChannelEvents/index.ts b/src/api/resources/preview/resources/awayStatusReasons/index.ts similarity index 100% rename from src/api/resources/customChannelEvents/index.ts rename to src/api/resources/preview/resources/awayStatusReasons/index.ts diff --git a/src/api/resources/preview/resources/banners/client/Client.ts b/src/api/resources/preview/resources/banners/client/Client.ts new file mode 100644 index 00000000..8f1f942a --- /dev/null +++ b/src/api/resources/preview/resources/banners/client/Client.ts @@ -0,0 +1,184 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace BannersClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Retrieve the banners a contact matches and record dismissals, so you can display + * banners on surfaces outside the Messenger (native mobile apps, kiosks, embedded + * tools). These endpoints are part of the `Preview` API version and require an OAuth + * token with the `read_write_users` scope. Requesting a contact's banners records an + * impression for each banner returned, and dismissals are shared with the web Messenger. + */ +export class BannersClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: BannersClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Returns the banners a contact currently matches, so you can display them on + * surfaces outside the Messenger (native mobile apps, kiosks, embedded tools). + * + * Each banner in the response includes a `view_id`. Use it to record a dismissal + * with the dismiss endpoint. A returned banner is treated as shown: requesting + * this endpoint records an impression for each banner returned, so call it at the + * point you are about to display the banners, not speculatively. + * + * @param {Intercom.preview.ListContactBannersRequest} request + * @param {BannersClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.banners.listContactBanners({ + * id: "id" + * }) + */ + public listContactBanners( + request: Intercom.preview.ListContactBannersRequest, + requestOptions?: BannersClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listContactBanners(request, requestOptions)); + } + + private async __listContactBanners( + request: Intercom.preview.ListContactBannersRequest, + requestOptions?: BannersClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/banners`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.BannerList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}/banners"); + } + + /** + * Records that a contact has dismissed a banner. Dismissals are shared across + * surfaces, so a banner dismissed through this endpoint will also stop appearing + * in the web Messenger for that contact, and vice versa. + * + * The request is idempotent: dismissing an already-dismissed banner succeeds and + * returns the same response. + * + * @param {Intercom.preview.DismissContactBannerRequest} request + * @param {BannersClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.banners.dismissContactBanner({ + * id: "id", + * view_id: "view_id" + * }) + */ + public dismissContactBanner( + request: Intercom.preview.DismissContactBannerRequest, + requestOptions?: BannersClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__dismissContactBanner(request, requestOptions)); + } + + private async __dismissContactBanner( + request: Intercom.preview.DismissContactBannerRequest, + requestOptions?: BannersClient.RequestOptions, + ): Promise> { + const { id, view_id: viewId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/banners/${core.url.encodePathParam(viewId)}/dismiss`, + ), + method: "POST", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.BannerDismiss, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/contacts/{id}/banners/{view_id}/dismiss", + ); + } +} diff --git a/src/api/resources/unstable/resources/calls/client/index.ts b/src/api/resources/preview/resources/banners/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/index.ts rename to src/api/resources/preview/resources/banners/client/index.ts diff --git a/src/api/resources/preview/resources/banners/client/requests/DismissContactBannerRequest.ts b/src/api/resources/preview/resources/banners/client/requests/DismissContactBannerRequest.ts new file mode 100644 index 00000000..ddf9a593 --- /dev/null +++ b/src/api/resources/preview/resources/banners/client/requests/DismissContactBannerRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "id", + * view_id: "view_id" + * } + */ +export interface DismissContactBannerRequest { + /** The unique identifier of a contact. */ + id: string; + /** The `view_id` of the banner to dismiss, as returned by the list banners endpoint. */ + view_id: string; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/GetTicketRequest.ts b/src/api/resources/preview/resources/banners/client/requests/ListContactBannersRequest.ts similarity index 55% rename from src/api/resources/unstable/resources/tickets/client/requests/GetTicketRequest.ts rename to src/api/resources/preview/resources/banners/client/requests/ListContactBannersRequest.ts index c48305e2..8761178a 100644 --- a/src/api/resources/unstable/resources/tickets/client/requests/GetTicketRequest.ts +++ b/src/api/resources/preview/resources/banners/client/requests/ListContactBannersRequest.ts @@ -6,7 +6,7 @@ * id: "id" * } */ -export interface GetTicketRequest { - /** The unique identifier for the ticket which is given by Intercom. */ +export interface ListContactBannersRequest { + /** The unique identifier of a contact. */ id: string; } diff --git a/src/api/resources/preview/resources/banners/client/requests/index.ts b/src/api/resources/preview/resources/banners/client/requests/index.ts new file mode 100644 index 00000000..e2bb4516 --- /dev/null +++ b/src/api/resources/preview/resources/banners/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { DismissContactBannerRequest } from "./DismissContactBannerRequest.js"; +export type { ListContactBannersRequest } from "./ListContactBannersRequest.js"; diff --git a/src/api/resources/unstable/resources/companies/index.ts b/src/api/resources/preview/resources/banners/index.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/index.ts rename to src/api/resources/preview/resources/banners/index.ts diff --git a/src/api/resources/preview/resources/banners/types/index.ts b/src/api/resources/preview/resources/banners/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/banners/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/banners/types/types.ts b/src/api/resources/preview/resources/banners/types/types.ts new file mode 100644 index 00000000..2a226a30 --- /dev/null +++ b/src/api/resources/preview/resources/banners/types/types.ts @@ -0,0 +1,86 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A banner the contact currently matches, with the content and view identifier needed to display and dismiss it. + */ +export interface Banner { + /** String representing the object's type. Always has the value `banner`. */ + type?: string; + /** The id of the banner. */ + id?: string; + /** The id of the contact's view of this banner. Pass this to the dismiss endpoint to record a dismissal. */ + view_id?: string; + /** The banner's title. `null` when the banner has no title. */ + title?: string; + /** The banner's body content as HTML. */ + body?: string; + /** How the banner is displayed. */ + style?: string; + /** Where the banner is positioned. */ + position?: string; + /** Whether the banner should display a dismiss control. */ + show_dismiss_button?: boolean; + /** + * The action a contact can take on the banner, or `null` when the banner has + * no action. The fields present depend on `type`: + * `url` (`label`, `target`), `reaction` (`reaction_set`), + * `email_collector`, or `product_tour` (`tour_id`, `tour_url`). + */ + action?: Banner.Action; + /** + * Reserved for future use. Always `null` in the current version — banners + * that depend on client-side targeting rules (such as page URL or time on + * page) are not returned by this endpoint. + */ + client_targeting?: Record[]; + /** The time the contact's view of this banner was created. */ + created_at?: number; +} + +export namespace Banner { + /** + * The action a contact can take on the banner, or `null` when the banner has + * no action. The fields present depend on `type`: + * `url` (`label`, `target`), `reaction` (`reaction_set`), + * `email_collector`, or `product_tour` (`tour_id`, `tour_url`). + */ + export interface Action { + /** The kind of action. One of `url`, `reaction`, `email_collector`, or `product_tour`. */ + type?: string; + /** For `url` actions, the label shown on the action link or button. */ + label?: string; + /** For `url` actions, the URL the contact is sent to. */ + target?: string; + /** For `reaction` actions, the reactions a contact can choose from. */ + reaction_set?: Action.ReactionSet.Item[]; + /** For `product_tour` actions, the id of the product tour to launch. */ + tour_id?: string; + /** For `product_tour` actions, the URL that launches the product tour. */ + tour_url?: string; + } + + export namespace Action { + export type ReactionSet = ReactionSet.Item[]; + + export namespace ReactionSet { + export interface Item { + /** The reaction's position in the set. */ + index?: number; + /** The reaction's unicode emoji. */ + unicode_emoticon?: string; + } + } + } +} + +/** + * The result of dismissing a banner for a contact. + */ +export interface BannerDismiss { + /** String representing the object's type. Always has the value `banner_dismiss`. */ + type?: string; + /** The id of the dismissed banner view. */ + view_id?: string; + /** Whether the banner view is dismissed. */ + dismissed?: boolean; +} diff --git a/src/api/resources/unstable/resources/brands/client/Client.ts b/src/api/resources/preview/resources/brands/client/Client.ts similarity index 81% rename from src/api/resources/unstable/resources/brands/client/Client.ts rename to src/api/resources/preview/resources/brands/client/Client.ts index 29540dc4..a2d938bb 100644 --- a/src/api/resources/unstable/resources/brands/client/Client.ts +++ b/src/api/resources/preview/resources/brands/client/Client.ts @@ -31,20 +31,20 @@ export class BrandsClient { * * @param {BrandsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.brands.listBrands() + * await client.preview.brands.listBrands() */ public listBrands( requestOptions?: BrandsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listBrands(requestOptions)); } private async __listBrands( requestOptions?: BrandsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -69,14 +69,14 @@ export class BrandsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.BrandList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.BrandList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -94,28 +94,28 @@ export class BrandsClient { /** * Fetches a specific brand by its unique identifier * - * @param {Intercom.unstable.RetrieveBrandRequest} request + * @param {Intercom.preview.RetrieveBrandRequest} request * @param {BrandsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.brands.retrieveBrand({ + * await client.preview.brands.retrieveBrand({ * id: "id" * }) */ public retrieveBrand( - request: Intercom.unstable.RetrieveBrandRequest, + request: Intercom.preview.RetrieveBrandRequest, requestOptions?: BrandsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__retrieveBrand(request, requestOptions)); } private async __retrieveBrand( - request: Intercom.unstable.RetrieveBrandRequest, + request: Intercom.preview.RetrieveBrandRequest, requestOptions?: BrandsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -141,18 +141,18 @@ export class BrandsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Brand, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Brand, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/unstable/resources/companies/client/index.ts b/src/api/resources/preview/resources/brands/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/index.ts rename to src/api/resources/preview/resources/brands/client/index.ts diff --git a/src/api/resources/unstable/resources/brands/client/requests/RetrieveBrandRequest.ts b/src/api/resources/preview/resources/brands/client/requests/RetrieveBrandRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/brands/client/requests/RetrieveBrandRequest.ts rename to src/api/resources/preview/resources/brands/client/requests/RetrieveBrandRequest.ts diff --git a/src/api/resources/unstable/resources/brands/client/requests/index.ts b/src/api/resources/preview/resources/brands/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/brands/client/requests/index.ts rename to src/api/resources/preview/resources/brands/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/contacts/index.ts b/src/api/resources/preview/resources/brands/index.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/index.ts rename to src/api/resources/preview/resources/brands/index.ts diff --git a/src/api/resources/preview/resources/brands/types/index.ts b/src/api/resources/preview/resources/brands/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/brands/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/brands/types/Brand.ts b/src/api/resources/preview/resources/brands/types/types.ts similarity index 78% rename from src/api/resources/unstable/resources/brands/types/Brand.ts rename to src/api/resources/preview/resources/brands/types/types.ts index 53a416af..b61503cf 100644 --- a/src/api/resources/unstable/resources/brands/types/Brand.ts +++ b/src/api/resources/preview/resources/brands/types/types.ts @@ -1,5 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Intercom from "../../../../../index.js"; + /** * Represents a branding configuration for the workspace */ @@ -21,3 +23,12 @@ export interface Brand { /** Default email settings ID for this brand */ default_address_settings_id?: string; } + +/** + * A list of brands + */ +export interface BrandList { + /** The type of object */ + type?: string; + data?: Intercom.preview.Brand[]; +} diff --git a/src/api/resources/unstable/resources/calls/client/Client.ts b/src/api/resources/preview/resources/calls/client/Client.ts similarity index 71% rename from src/api/resources/unstable/resources/calls/client/Client.ts rename to src/api/resources/preview/resources/calls/client/Client.ts index 24f1b6f6..b75cba65 100644 --- a/src/api/resources/unstable/resources/calls/client/Client.ts +++ b/src/api/resources/preview/resources/calls/client/Client.ts @@ -28,28 +28,28 @@ export class CallsClient { /** * Retrieve a paginated list of calls. * - * @param {Intercom.unstable.ListCallsRequest} request + * @param {Intercom.preview.ListCallsRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.calls.listCalls({ + * await client.preview.calls.listCalls({ * page: 1, * per_page: 1 * }) */ public listCalls( - request: Intercom.unstable.ListCallsRequest = {}, + request: Intercom.preview.ListCallsRequest = {}, requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listCalls(request, requestOptions)); } private async __listCalls( - request: Intercom.unstable.ListCallsRequest = {}, + request: Intercom.preview.ListCallsRequest = {}, requestOptions?: CallsClient.RequestOptions, - ): Promise> { + ): Promise> { const { page, per_page: perPage } = request; const _queryParams: Record = {}; if (page != null) { @@ -84,14 +84,14 @@ export class CallsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.CallList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.CallList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -109,28 +109,28 @@ export class CallsClient { /** * Retrieve a single call by id. * - * @param {Intercom.unstable.ShowCallRequest} request + * @param {Intercom.preview.ShowCallRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.calls.showCall({ + * await client.preview.calls.showCall({ * id: "id" * }) */ public showCall( - request: Intercom.unstable.ShowCallRequest, + request: Intercom.preview.ShowCallRequest, requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__showCall(request, requestOptions)); } private async __showCall( - request: Intercom.unstable.ShowCallRequest, + request: Intercom.preview.ShowCallRequest, requestOptions?: CallsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -156,18 +156,18 @@ export class CallsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Call, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Call, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -183,26 +183,26 @@ export class CallsClient { /** * Redirects to a signed URL for the call's recording if it exists. * - * @param {Intercom.unstable.ShowCallRecordingRequest} request + * @param {Intercom.preview.ShowCallRecordingRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.calls.showCallRecording({ + * await client.preview.calls.showCallRecording({ * id: "id" * }) */ public showCallRecording( - request: Intercom.unstable.ShowCallRecordingRequest, + request: Intercom.preview.ShowCallRecordingRequest, requestOptions?: CallsClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__showCallRecording(request, requestOptions)); } private async __showCallRecording( - request: Intercom.unstable.ShowCallRecordingRequest, + request: Intercom.preview.ShowCallRecordingRequest, requestOptions?: CallsClient.RequestOptions, ): Promise> { const { id } = request; @@ -236,12 +236,12 @@ export class CallsClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -257,25 +257,25 @@ export class CallsClient { /** * Returns the transcript for the specified call as a downloadable text file. * - * @param {Intercom.unstable.ShowCallTranscriptRequest} request + * @param {Intercom.preview.ShowCallTranscriptRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.calls.showCallTranscript({ + * await client.preview.calls.showCallTranscript({ * id: "id" * }) */ public showCallTranscript( - request: Intercom.unstable.ShowCallTranscriptRequest, + request: Intercom.preview.ShowCallTranscriptRequest, requestOptions?: CallsClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__showCallTranscript(request, requestOptions)); } private async __showCallTranscript( - request: Intercom.unstable.ShowCallTranscriptRequest, + request: Intercom.preview.ShowCallTranscriptRequest, requestOptions?: CallsClient.RequestOptions, ): Promise> { const { id } = request; @@ -310,7 +310,7 @@ export class CallsClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -327,28 +327,28 @@ export class CallsClient { * Retrieve calls by a list of conversation ids and include transcripts when available. * A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. * - * @param {Intercom.unstable.ListCallsWithTranscriptsRequest} request + * @param {Intercom.preview.ListCallsWithTranscriptsRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.calls.listCallsWithTranscripts({ + * await client.preview.calls.listCallsWithTranscripts({ * conversation_ids: ["64619700005694", "64619700005695"] * }) */ public listCallsWithTranscripts( - request: Intercom.unstable.ListCallsWithTranscriptsRequest, + request: Intercom.preview.ListCallsWithTranscriptsRequest, requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listCallsWithTranscripts(request, requestOptions)); } private async __listCallsWithTranscripts( - request: Intercom.unstable.ListCallsWithTranscriptsRequest, + request: Intercom.preview.ListCallsWithTranscriptsRequest, requestOptions?: CallsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -377,7 +377,7 @@ export class CallsClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.ListCallsWithTranscriptsResponse, + data: _response.body as Intercom.preview.ListCallsWithTranscriptsResponse, rawResponse: _response.rawResponse, }; } @@ -385,10 +385,10 @@ export class CallsClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -412,29 +412,29 @@ export class CallsClient { * - Five9 * - Zoom Phone * - * @param {Intercom.unstable.RegisterFinVoiceCallRequest} request + * @param {Intercom.preview.RegisterFinVoiceCallRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.ConflictError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.ConflictError} * * @example - * await client.unstable.calls.registerFinVoiceCall({ + * await client.preview.calls.registerFinVoiceCall({ * phone_number: "+1234567890", * call_id: "call-123-abc" * }) */ public registerFinVoiceCall( - request?: Intercom.unstable.RegisterFinVoiceCallRequest, + request?: Intercom.preview.RegisterFinVoiceCallRequest, requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__registerFinVoiceCall(request, requestOptions)); } private async __registerFinVoiceCall( - request?: Intercom.unstable.RegisterFinVoiceCallRequest, + request?: Intercom.preview.RegisterFinVoiceCallRequest, requestOptions?: CallsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -462,16 +462,16 @@ export class CallsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.AiCallResponse, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.AiCallResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 409: - throw new Intercom.unstable.ConflictError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ConflictError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -489,27 +489,27 @@ export class CallsClient { /** * Retrieve information about a Fin Voice call using the external reference ID. * - * @param {Intercom.unstable.CollectFinVoiceCallByIdRequest} request + * @param {Intercom.preview.CollectFinVoiceCallByIdRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.calls.collectFinVoiceCallById({ + * await client.preview.calls.collectFinVoiceCallById({ * id: 1 * }) */ public collectFinVoiceCallById( - request: Intercom.unstable.CollectFinVoiceCallByIdRequest, + request: Intercom.preview.CollectFinVoiceCallByIdRequest, requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__collectFinVoiceCallById(request, requestOptions)); } private async __collectFinVoiceCallById( - request: Intercom.unstable.CollectFinVoiceCallByIdRequest, + request: Intercom.preview.CollectFinVoiceCallByIdRequest, requestOptions?: CallsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -535,13 +535,13 @@ export class CallsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.AiCallResponse, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.AiCallResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -557,27 +557,27 @@ export class CallsClient { /** * Retrieve information about a Fin Voice call using the external call identifier. * - * @param {Intercom.unstable.CollectFinVoiceCallByExternalIdRequest} request + * @param {Intercom.preview.CollectFinVoiceCallByExternalIdRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.calls.collectFinVoiceCallByExternalId({ + * await client.preview.calls.collectFinVoiceCallByExternalId({ * external_id: "external_id" * }) */ public collectFinVoiceCallByExternalId( - request: Intercom.unstable.CollectFinVoiceCallByExternalIdRequest, + request: Intercom.preview.CollectFinVoiceCallByExternalIdRequest, requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__collectFinVoiceCallByExternalId(request, requestOptions)); } private async __collectFinVoiceCallByExternalId( - request: Intercom.unstable.CollectFinVoiceCallByExternalIdRequest, + request: Intercom.preview.CollectFinVoiceCallByExternalIdRequest, requestOptions?: CallsClient.RequestOptions, - ): Promise> { + ): Promise> { const { external_id: externalId } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -603,13 +603,13 @@ export class CallsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.AiCallResponse, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.AiCallResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -632,28 +632,28 @@ export class CallsClient { * * Returns the most recent matched call for the given phone number, ordered by creation date. * - * @param {Intercom.unstable.CollectFinVoiceCallByPhoneNumberRequest} request + * @param {Intercom.preview.CollectFinVoiceCallByPhoneNumberRequest} request * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ + * await client.preview.calls.collectFinVoiceCallByPhoneNumber({ * phone_number: "phone_number" * }) */ public collectFinVoiceCallByPhoneNumber( - request: Intercom.unstable.CollectFinVoiceCallByPhoneNumberRequest, + request: Intercom.preview.CollectFinVoiceCallByPhoneNumberRequest, requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__collectFinVoiceCallByPhoneNumber(request, requestOptions)); } private async __collectFinVoiceCallByPhoneNumber( - request: Intercom.unstable.CollectFinVoiceCallByPhoneNumberRequest, + request: Intercom.preview.CollectFinVoiceCallByPhoneNumberRequest, requestOptions?: CallsClient.RequestOptions, - ): Promise> { + ): Promise> { const { phone_number: phoneNumber } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -679,18 +679,18 @@ export class CallsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Error_, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Error_, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -707,4 +707,84 @@ export class CallsClient { "/fin_voice/phone_number/{phone_number}", ); } + + /** + * Retrieve information about Fin Voice calls associated with a conversation. + * + * Returns all matched calls for the given conversation ID. A conversation may have multiple associated calls. + * + * @param {Intercom.preview.CollectFinVoiceCallsByConversationIdRequest} request + * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.calls.collectFinVoiceCallsByConversationId({ + * conversation_id: "conversation_id" + * }) + */ + public collectFinVoiceCallsByConversationId( + request: Intercom.preview.CollectFinVoiceCallsByConversationIdRequest, + requestOptions?: CallsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise( + this.__collectFinVoiceCallsByConversationId(request, requestOptions), + ); + } + + private async __collectFinVoiceCallsByConversationId( + request: Intercom.preview.CollectFinVoiceCallsByConversationIdRequest, + requestOptions?: CallsClient.RequestOptions, + ): Promise> { + const { conversation_id: conversationId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `fin_voice/conversation/${core.url.encodePathParam(conversationId)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.AiCallResponse[], rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/fin_voice/conversation/{conversation_id}", + ); + } } diff --git a/src/api/resources/unstable/resources/contacts/client/index.ts b/src/api/resources/preview/resources/calls/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/index.ts rename to src/api/resources/preview/resources/calls/client/index.ts diff --git a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByExternalIdRequest.ts b/src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallByExternalIdRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByExternalIdRequest.ts rename to src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallByExternalIdRequest.ts diff --git a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByIdRequest.ts b/src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallByIdRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByIdRequest.ts rename to src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallByIdRequest.ts diff --git a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByPhoneNumberRequest.ts b/src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallByPhoneNumberRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByPhoneNumberRequest.ts rename to src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallByPhoneNumberRequest.ts diff --git a/src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallsByConversationIdRequest.ts b/src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallsByConversationIdRequest.ts new file mode 100644 index 00000000..f2805a18 --- /dev/null +++ b/src/api/resources/preview/resources/calls/client/requests/CollectFinVoiceCallsByConversationIdRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * conversation_id: "conversation_id" + * } + */ +export interface CollectFinVoiceCallsByConversationIdRequest { + /** The Intercom conversation identifier */ + conversation_id: string; +} diff --git a/src/api/resources/unstable/resources/calls/client/requests/ListCallsRequest.ts b/src/api/resources/preview/resources/calls/client/requests/ListCallsRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/requests/ListCallsRequest.ts rename to src/api/resources/preview/resources/calls/client/requests/ListCallsRequest.ts diff --git a/src/api/resources/unstable/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts b/src/api/resources/preview/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts rename to src/api/resources/preview/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts diff --git a/src/api/resources/unstable/resources/calls/client/requests/ShowCallRecordingRequest.ts b/src/api/resources/preview/resources/calls/client/requests/ShowCallRecordingRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/requests/ShowCallRecordingRequest.ts rename to src/api/resources/preview/resources/calls/client/requests/ShowCallRecordingRequest.ts diff --git a/src/api/resources/unstable/resources/calls/client/requests/ShowCallRequest.ts b/src/api/resources/preview/resources/calls/client/requests/ShowCallRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/requests/ShowCallRequest.ts rename to src/api/resources/preview/resources/calls/client/requests/ShowCallRequest.ts diff --git a/src/api/resources/unstable/resources/calls/client/requests/ShowCallTranscriptRequest.ts b/src/api/resources/preview/resources/calls/client/requests/ShowCallTranscriptRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/calls/client/requests/ShowCallTranscriptRequest.ts rename to src/api/resources/preview/resources/calls/client/requests/ShowCallTranscriptRequest.ts diff --git a/src/api/resources/unstable/resources/calls/client/requests/index.ts b/src/api/resources/preview/resources/calls/client/requests/index.ts similarity index 85% rename from src/api/resources/unstable/resources/calls/client/requests/index.ts rename to src/api/resources/preview/resources/calls/client/requests/index.ts index d1c18782..8ed9089f 100644 --- a/src/api/resources/unstable/resources/calls/client/requests/index.ts +++ b/src/api/resources/preview/resources/calls/client/requests/index.ts @@ -1,6 +1,7 @@ export type { CollectFinVoiceCallByExternalIdRequest } from "./CollectFinVoiceCallByExternalIdRequest.js"; export type { CollectFinVoiceCallByIdRequest } from "./CollectFinVoiceCallByIdRequest.js"; export type { CollectFinVoiceCallByPhoneNumberRequest } from "./CollectFinVoiceCallByPhoneNumberRequest.js"; +export type { CollectFinVoiceCallsByConversationIdRequest } from "./CollectFinVoiceCallsByConversationIdRequest.js"; export type { ListCallsRequest } from "./ListCallsRequest.js"; export type { ListCallsWithTranscriptsRequest } from "./ListCallsWithTranscriptsRequest.js"; export type { ShowCallRecordingRequest } from "./ShowCallRecordingRequest.js"; diff --git a/src/api/resources/unstable/resources/conversations/index.ts b/src/api/resources/preview/resources/calls/index.ts similarity index 100% rename from src/api/resources/unstable/resources/conversations/index.ts rename to src/api/resources/preview/resources/calls/index.ts diff --git a/src/api/resources/preview/resources/calls/types/index.ts b/src/api/resources/preview/resources/calls/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/calls/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/calls/types/Call.ts b/src/api/resources/preview/resources/calls/types/types.ts similarity index 51% rename from src/api/resources/unstable/resources/calls/types/Call.ts rename to src/api/resources/preview/resources/calls/types/types.ts index 18bb1be3..340b6d58 100644 --- a/src/api/resources/unstable/resources/calls/types/Call.ts +++ b/src/api/resources/preview/resources/calls/types/types.ts @@ -2,6 +2,24 @@ import type * as Intercom from "../../../../../index.js"; +export interface ListCallsWithTranscriptsResponse { + type?: string; + data?: ListCallsWithTranscriptsResponse.Data.Item[]; +} + +export namespace ListCallsWithTranscriptsResponse { + export type Data = Data.Item[]; + + export namespace Data { + export interface Item extends Intercom.preview.Call { + /** The call transcript if available, otherwise an empty array. */ + transcript?: Record[]; + /** The status of the transcript if available. */ + transcript_status?: string; + } + } +} + /** * Represents a phone call in Intercom */ @@ -18,11 +36,11 @@ export interface Call { contact_id?: string; /** The current state of the call. */ state?: string; - initiated_at?: Intercom.unstable.Datetime; - answered_at?: Intercom.unstable.Datetime; - ended_at?: Intercom.unstable.Datetime; - created_at?: Intercom.unstable.Datetime; - updated_at?: Intercom.unstable.Datetime; + initiated_at?: Intercom.preview.Datetime; + answered_at?: Intercom.preview.Datetime; + ended_at?: Intercom.preview.Datetime; + created_at?: Intercom.preview.Datetime; + updated_at?: Intercom.preview.Datetime; /** API URL to download or redirect to the call recording if available. */ recording_url?: string; /** API URL to the call transcript if available. */ @@ -39,4 +57,12 @@ export interface Call { fin_recording_url?: string; /** API URL to the AI Agent (Fin) call transcript if available. */ fin_transcription_url?: string; + /** Total call duration in seconds from the caller's perspective. For inbound calls, measured from initiated to ended. For outbound calls, measured from answered to ended. */ + duration?: number; + /** Total time in seconds the agent and customer were connected. */ + talk_time?: number; + /** Total time in seconds the caller waited in queue before connecting, when assigned to a team. */ + queue_time?: number; + /** Total time in seconds the caller was placed on hold during the call. */ + hold_time?: number; } diff --git a/src/api/resources/preview/resources/companies/client/Client.ts b/src/api/resources/preview/resources/companies/client/Client.ts new file mode 100644 index 00000000..8d72ff33 --- /dev/null +++ b/src/api/resources/preview/resources/companies/client/Client.ts @@ -0,0 +1,1558 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace CompaniesClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Everything about your Companies + */ +export class CompaniesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: CompaniesClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * You can fetch a single company by passing in `company_id` or `name`. + * + * `https://api.intercom.io/companies?name={name}` + * + * `https://api.intercom.io/companies?company_id={company_id}` + * + * You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. + * + * `https://api.intercom.io/companies?tag_id={tag_id}` + * + * `https://api.intercom.io/companies?segment_id={segment_id}` + * + * @param {Intercom.preview.RetrieveCompanyRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.companies.retrieveCompany({ + * name: "my company", + * company_id: "12345", + * tag_id: "678910", + * segment_id: "98765", + * page: 1, + * per_page: 1 + * }) + */ + public retrieveCompany( + request: Intercom.preview.RetrieveCompanyRequest = {}, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveCompany(request, requestOptions)); + } + + private async __retrieveCompany( + request: Intercom.preview.RetrieveCompanyRequest = {}, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { name, company_id: companyId, tag_id: tagId, segment_id: segmentId, page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (name != null) { + _queryParams.name = name; + } + + if (companyId != null) { + _queryParams.company_id = companyId; + } + + if (tagId != null) { + _queryParams.tag_id = tagId; + } + + if (segmentId != null) { + _queryParams.segment_id = segmentId; + } + + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.CompanyList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies"); + } + + /** + * You can create or update a company. + * + * Companies will be only visible in Intercom when there is at least one associated user. + * + * Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. + * + * {% admonition type="warning" name="Using `company_id`" %} + * You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. + * {% /admonition %} + * + * @param {unknown} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.companies.createOrUpdateCompany({ + * "key": "value" + * }) + */ + public createOrUpdateCompany( + request?: unknown, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createOrUpdateCompany(request, requestOptions)); + } + + private async __createOrUpdateCompany( + request?: unknown, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies"); + } + + /** + * You can fetch a single company. + * + * @param {Intercom.preview.RetrieveACompanyByIdRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.companies.retrieveACompanyById({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public retrieveACompanyById( + request: Intercom.preview.RetrieveACompanyByIdRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveACompanyById(request, requestOptions)); + } + + private async __retrieveACompanyById( + request: Intercom.preview.RetrieveACompanyByIdRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}"); + } + + /** + * You can update a single company using the Intercom provisioned `id`. + * + * {% admonition type="warning" name="Using `company_id`" %} + * When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. + * {% /admonition %} + * + * @param {Intercom.preview.UpdateCompanyRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.companies.updateCompany({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public updateCompany( + request: Intercom.preview.UpdateCompanyRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateCompany(request, requestOptions)); + } + + private async __updateCompany( + request: Intercom.preview.UpdateCompanyRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${core.url.encodePathParam(id)}`, + ), + method: "PUT", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/companies/{id}"); + } + + /** + * Delete a single company. + * + * This endpoint does not permanently remove the company. It archives the company record and detaches any contacts attached to it; the contacts themselves are not deleted. A `company.deleted` webhook is sent once archival completes. + * + * The endpoint returns `200` with `"deleted": true` as soon as the request is accepted — archival is processed asynchronously. + * + * {% admonition type="warning" %} + * Third-party integrations that sync companies into Intercom (for example, Salesforce or Chargebee) will recreate any company deleted through this endpoint on their next sync. To prevent recreation, remove or filter the company at the source integration before deleting it via the API. + * {% /admonition %} + * + * @param {Intercom.preview.DeleteCompanyRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.companies.deleteCompany({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public deleteCompany( + request: Intercom.preview.DeleteCompanyRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteCompany(request, requestOptions)); + } + + private async __deleteCompany( + request: Intercom.preview.DeleteCompanyRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.DeletedCompanyObject, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/companies/{id}"); + } + + /** + * You can fetch a list of all contacts that belong to a company. + * + * @param {Intercom.preview.ListAttachedContactsRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.companies.listAttachedContacts({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public listAttachedContacts( + request: Intercom.preview.ListAttachedContactsRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedContacts(request, requestOptions)); + } + + private async __listAttachedContacts( + request: Intercom.preview.ListAttachedContactsRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${core.url.encodePathParam(id)}/contacts`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.CompanyAttachedContacts, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}/contacts"); + } + + /** + * You can fetch a list of all segments that belong to a company. + * + * @param {Intercom.preview.ListAttachedSegmentsForCompaniesRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.companies.listAttachedSegmentsForCompanies({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public listAttachedSegmentsForCompanies( + request: Intercom.preview.ListAttachedSegmentsForCompaniesRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedSegmentsForCompanies(request, requestOptions)); + } + + private async __listAttachedSegmentsForCompanies( + request: Intercom.preview.ListAttachedSegmentsForCompaniesRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${core.url.encodePathParam(id)}/segments`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.CompanyAttachedSegments, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}/segments"); + } + + /** + * You can search for companies by the value of their attributes in order to fetch exactly the companies you want. + * + * To search for companies, send a `POST` request to `https://api.intercom.io/companies/search`, with a query object in the body defining your filters. + * + * Note that the API does not include companies who have no associated users in search results. + * + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is `15` results per page. + * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. + * {% /admonition %} + * + * ### Nesting & Limitations + * + * You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be: + * * There's a limit of max 2 nested filters + * * There's a limit of max 15 filters for each AND or OR group + * + * ### Accepted Fields + * + * Most keys listed as part of the Companies Model are searchable. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). + * + * | Field | Type | + * | ---------------------------------- | ------------------------------ | + * | company_id | String | + * | name | String | + * | created_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | remote_created_at | Date (UNIX Timestamp) | + * | last_request_at | Date (UNIX Timestamp) | + * | monthly_spend | Integer | + * | session_count | Integer | + * | user_count | Integer | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String | + * + * The `plan.id` and `plan.name` fields are not searchable and return a `400` error with code `invalid_field`. + * + * ### Accepted Operators + * + * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). Searching by `tag_id` supports only the `=` and `!=` operators. The `IN` and `NIN` operators are not supported for Date fields. + * + * | Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All except Date and tag_id | In
Shortcut for `OR` queries
Values must be in Array | + * | NIN | All except Date and tag_id | Not In
Shortcut for `OR !` queries
Values must be in Array | + * | > | Integer
Date (UNIX Timestamp) | Greater than | + * | < | Integer
Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With | + * + * ### Sorting + * + * Pass an optional `sort` object with a `field` and an `order` (`ascending` or `descending`; defaults to `descending`) to order the results. An invalid `order` returns a `400` error with code `invalid_sort_order`. `tag_id` can be used as a filter but not as a sort field. + * + * @param {Intercom.preview.CompanySearchRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.companies.searchCompanies({ + * query: { + * operator: "AND", + * value: [{ + * field: "name", + * operator: "=", + * value: "my-company" + * }] + * }, + * pagination: { + * per_page: 5 + * }, + * sort: { + * field: "name", + * order: "ascending" + * } + * }) + */ + public searchCompanies( + request: Intercom.preview.CompanySearchRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchCompanies(request, requestOptions)); + } + + private async __searchCompanies( + request: Intercom.preview.CompanySearchRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/search", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.CompanyList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies/search"); + } + + /** + * You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. + * + * Note that the API does not include companies who have no associated users in list responses. + * + * When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is `20` results per page. + * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. + * {% /admonition %} + * + * @param {Intercom.preview.ListAllCompaniesRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.companies.listAllCompanies({ + * page: 1, + * per_page: 1, + * order: "desc" + * }) + */ + public listAllCompanies( + request: Intercom.preview.ListAllCompaniesRequest = {}, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAllCompanies(request, requestOptions)); + } + + private async __listAllCompanies( + request: Intercom.preview.ListAllCompaniesRequest = {}, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { page, per_page: perPage, order } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (order != null) { + _queryParams.order = order; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/list", + ), + method: "POST", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.CompanyList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies/list"); + } + + /** + * The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + * + * - Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. + * - If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail + * - If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire + * + * {% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %} + * + * @param {Intercom.preview.ScrollOverAllCompaniesRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.companies.scrollOverAllCompanies({ + * scroll_param: "scroll_param" + * }) + */ + public scrollOverAllCompanies( + request: Intercom.preview.ScrollOverAllCompaniesRequest = {}, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__scrollOverAllCompanies(request, requestOptions)); + } + + private async __scrollOverAllCompanies( + request: Intercom.preview.ScrollOverAllCompaniesRequest = {}, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { scroll_param: scrollParam } = request; + const _queryParams: Record = {}; + if (scrollParam != null) { + _queryParams.scroll_param = scrollParam; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/scroll", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.CompanyScroll | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/scroll"); + } + + /** + * You can attach a company to a single contact. + * + * @param {Intercom.preview.AttachContactToACompanyRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.companies.attachContactToACompany({ + * id: "id", + * company_id: "6762f09a1bb69f9f2193bb34" + * }) + * + * @example + * await client.preview.companies.attachContactToACompany({ + * id: "id", + * company_id: "58a430d35458202d41b1e65b" + * }) + * + * @example + * await client.preview.companies.attachContactToACompany({ + * id: "id", + * company_id: "123" + * }) + */ + public attachContactToACompany( + request: Intercom.preview.AttachContactToACompanyRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachContactToACompany(request, requestOptions)); + } + + private async __attachContactToACompany( + request: Intercom.preview.AttachContactToACompanyRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/companies`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/companies"); + } + + /** + * You can detach a company from a single contact. + * + * @param {Intercom.preview.DetachContactFromACompanyRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.companies.detachContactFromACompany({ + * contact_id: "58a430d35458202d41b1e65b", + * id: "58a430d35458202d41b1e65b" + * }) + */ + public detachContactFromACompany( + request: Intercom.preview.DetachContactFromACompanyRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachContactFromACompany(request, requestOptions)); + } + + private async __detachContactFromACompany( + request: Intercom.preview.DetachContactFromACompanyRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { contact_id: contactId, id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(contactId)}/companies/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/contacts/{contact_id}/companies/{id}", + ); + } + + /** + * You can bulk create or update companies by submitting an array of company objects. Each company is matched on the `company_id` you have defined for it: a new company is created if none exists with that `company_id`, otherwise the matching company is updated. This mirrors the single [Create or update a company](/docs/references/preview/rest-api/api.intercom.io/companies/createorupdatecompany) endpoint. + * + * The endpoint creates an async job that processes the items in the background. Use the returned job ID with `GET /companies/bulk/{id}` to check the job status. + * + * {% admonition type="info" name="Handling failures" %} + * If an item fails validation, that item is rejected and the job's `state` ends as `completed_with_errors`. The other companies in the same request are still processed. The job `state` from `GET /companies/bulk/{id}` is the signal that one or more items were rejected. + * {% /admonition %} + * + * {% admonition type="info" name="Limits" %} + * - Maximum of 100 companies per request. + * - You can append tasks to an existing job by including `job.id` in the request body. + * {% /admonition %} + * + * @param {Intercom.preview.BulkCreateCompaniesRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.companies.bulkCreateCompanies({ + * companies: [{ + * company_id: "abc123", + * name: "Acme Corp", + * plan: "Enterprise", + * size: 100, + * website: "https://www.example.com", + * industry: "Manufacturing", + * custom_attributes: { + * "paid_subscriber": true, + * "team_mates": 9 + * }, + * remote_created_at: 1394531169, + * monthly_spend: 1000, + * update_last_request_at: true + * }, { + * company_id: "def456", + * name: "Example Inc", + * industry: "Manufacturing" + * }] + * }) + * + * @example + * await client.preview.companies.bulkCreateCompanies({ + * companies: [{ + * company_id: "abc123", + * monthly_spend: 1000 + * }], + * job: { + * id: "job_v2_1" + * } + * }) + */ + public bulkCreateCompanies( + request: Intercom.preview.BulkCreateCompaniesRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__bulkCreateCompanies(request, requestOptions)); + } + + private async __bulkCreateCompanies( + request: Intercom.preview.BulkCreateCompaniesRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/bulk", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.CompaniesBulkJob, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies/bulk"); + } + + /** + * You can bulk update companies by submitting an array of company objects with the fields to update. Each company must include an `id` field identifying the company to update by its Intercom company `id`. An unknown `id` fails that item and never creates a company. + * + * Only the fields listed in the request schema below can be set. Any other fields in a company object are ignored. + * + * The endpoint creates an async job that processes the updates in the background. Use the returned job ID with `GET /companies/bulk/{id}` to check the job status. + * + * {% admonition type="info" name="Limits" %} + * - Maximum of 100 companies per request. + * - You can append tasks to an existing job by including `job.id` in the request body. + * {% /admonition %} + * + * @param {Intercom.preview.BulkUpdateCompaniesRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.companies.bulkUpdateCompanies({ + * companies: [{ + * id: "531ee472cce572a6ec000006", + * name: "Acme Corp", + * plan: "Enterprise", + * size: 100, + * website: "https://www.example.com", + * industry: "Manufacturing", + * custom_attributes: { + * "paid_subscriber": true, + * "team_mates": 9 + * }, + * remote_created_at: 1394531169, + * monthly_spend: 1000, + * update_last_request_at: true + * }, { + * id: "531ee472cce572a6ec000007", + * name: "Example Inc" + * }] + * }) + * + * @example + * await client.preview.companies.bulkUpdateCompanies({ + * companies: [{ + * id: "531ee472cce572a6ec000006", + * monthly_spend: 1000 + * }], + * job: { + * id: "job_v2_1" + * } + * }) + */ + public bulkUpdateCompanies( + request: Intercom.preview.BulkUpdateCompaniesRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__bulkUpdateCompanies(request, requestOptions)); + } + + private async __bulkUpdateCompanies( + request: Intercom.preview.BulkUpdateCompaniesRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/bulk", + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.CompaniesBulkJob, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/companies/bulk"); + } + + /** + * You can bulk delete companies by submitting an array of companies, each identified by its Intercom company `id`. Deleting a company detaches all of its associated contacts but keeps the company record itself — the same archival behaviour as the single [Delete a company](/docs/references/preview/rest-api/api.intercom.io/companies/deletecompany) endpoint. + * + * The endpoint creates an async job that processes the deletes in the background. Use the returned job ID with `GET /companies/bulk/{id}` to check the job status. + * + * {% admonition type="info" name="Limits" %} + * - Maximum of 100 companies per request. + * - You can append tasks to an existing job by including `job.id` in the request body. + * {% /admonition %} + * + * @param {Intercom.preview.BulkDeleteCompaniesRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.companies.bulkDeleteCompanies({ + * companies: [{ + * id: "531ee472cce572a6ec000006" + * }, { + * id: "531ee472cce572a6ec000007" + * }] + * }) + * + * @example + * await client.preview.companies.bulkDeleteCompanies({ + * companies: [{ + * id: "531ee472cce572a6ec000006" + * }], + * job: { + * id: "job_v2_1" + * } + * }) + */ + public bulkDeleteCompanies( + request: Intercom.preview.BulkDeleteCompaniesRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__bulkDeleteCompanies(request, requestOptions)); + } + + private async __bulkDeleteCompanies( + request: Intercom.preview.BulkDeleteCompaniesRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/bulk/delete", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.CompaniesBulkJob, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies/bulk/delete"); + } + + /** + * You can check the status of a bulk companies job. The `state` field indicates the overall job progress: `pending`, `running`, `completed`, or `completed_with_errors`. + * + * @param {Intercom.preview.ShowBulkCompaniesJobRequest} request + * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.companies.showBulkCompaniesJob({ + * id: "job_v2_1" + * }) + */ + public showBulkCompaniesJob( + request: Intercom.preview.ShowBulkCompaniesJobRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__showBulkCompaniesJob(request, requestOptions)); + } + + private async __showBulkCompaniesJob( + request: Intercom.preview.ShowBulkCompaniesJobRequest, + requestOptions?: CompaniesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/bulk/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.CompaniesBulkJob, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/bulk/{id}"); + } +} diff --git a/src/api/resources/unstable/resources/conversations/client/index.ts b/src/api/resources/preview/resources/companies/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/conversations/client/index.ts rename to src/api/resources/preview/resources/companies/client/index.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/AttachContactToACompanyRequest.ts b/src/api/resources/preview/resources/companies/client/requests/AttachContactToACompanyRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/AttachContactToACompanyRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/AttachContactToACompanyRequest.ts diff --git a/src/api/resources/preview/resources/companies/client/requests/BulkCreateCompaniesRequest.ts b/src/api/resources/preview/resources/companies/client/requests/BulkCreateCompaniesRequest.ts new file mode 100644 index 00000000..9cb10321 --- /dev/null +++ b/src/api/resources/preview/resources/companies/client/requests/BulkCreateCompaniesRequest.ts @@ -0,0 +1,80 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * companies: [{ + * company_id: "abc123", + * name: "Acme Corp", + * plan: "Enterprise", + * size: 100, + * website: "https://www.example.com", + * industry: "Manufacturing", + * custom_attributes: { + * "paid_subscriber": true, + * "team_mates": 9 + * }, + * remote_created_at: 1394531169, + * monthly_spend: 1000, + * update_last_request_at: true + * }, { + * company_id: "def456", + * name: "Example Inc", + * industry: "Manufacturing" + * }] + * } + * + * @example + * { + * companies: [{ + * company_id: "abc123", + * monthly_spend: 1000 + * }], + * job: { + * id: "job_v2_1" + * } + * } + */ +export interface BulkCreateCompaniesRequest { + /** An array of company objects to create or update. Maximum 100 companies per request. */ + companies: BulkCreateCompaniesRequest.Companies.Item[]; + /** Optional. Include to append tasks to an existing job. */ + job?: BulkCreateCompaniesRequest.Job; +} + +export namespace BulkCreateCompaniesRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The company id you have defined for the company. Used to match an existing company; a new one is created if none matches. */ + company_id?: string; + /** The name of the company. */ + name?: string; + /** The name of the plan you have associated with the company. */ + plan?: string; + /** The number of employees in this company. */ + size?: number; + /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ + website?: string; + /** The industry that this company operates in. */ + industry?: string; + /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ + custom_attributes?: Record; + /** The time the company was created by you, in Unix timestamp format. */ + remote_created_at?: number; + /** How much revenue the company generates for your business. Note that this will truncate floats — only whole integers are stored, so 155.98 is truncated to 155, with an upper limit of 2147483647. */ + monthly_spend?: number; + /** Set to true to update the company's last seen time to now. */ + update_last_request_at?: boolean; + } + } + + /** + * Optional. Include to append tasks to an existing job. + */ + export interface Job { + /** The ID of an existing bulk job to append to. */ + id?: string; + } +} diff --git a/src/api/resources/preview/resources/companies/client/requests/BulkDeleteCompaniesRequest.ts b/src/api/resources/preview/resources/companies/client/requests/BulkDeleteCompaniesRequest.ts new file mode 100644 index 00000000..994e2792 --- /dev/null +++ b/src/api/resources/preview/resources/companies/client/requests/BulkDeleteCompaniesRequest.ts @@ -0,0 +1,47 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * companies: [{ + * id: "531ee472cce572a6ec000006" + * }, { + * id: "531ee472cce572a6ec000007" + * }] + * } + * + * @example + * { + * companies: [{ + * id: "531ee472cce572a6ec000006" + * }], + * job: { + * id: "job_v2_1" + * } + * } + */ +export interface BulkDeleteCompaniesRequest { + /** An array of companies to delete, each identified by its Intercom company `id`. Maximum 100 companies per request. */ + companies: BulkDeleteCompaniesRequest.Companies.Item[]; + /** Optional. Include to append tasks to an existing job. */ + job?: BulkDeleteCompaniesRequest.Job; +} + +export namespace BulkDeleteCompaniesRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom defined id representing the company. */ + id: string; + } + } + + /** + * Optional. Include to append tasks to an existing job. + */ + export interface Job { + /** The ID of an existing bulk job to append to. */ + id?: string; + } +} diff --git a/src/api/resources/preview/resources/companies/client/requests/BulkUpdateCompaniesRequest.ts b/src/api/resources/preview/resources/companies/client/requests/BulkUpdateCompaniesRequest.ts new file mode 100644 index 00000000..b4da59fb --- /dev/null +++ b/src/api/resources/preview/resources/companies/client/requests/BulkUpdateCompaniesRequest.ts @@ -0,0 +1,79 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * companies: [{ + * id: "531ee472cce572a6ec000006", + * name: "Acme Corp", + * plan: "Enterprise", + * size: 100, + * website: "https://www.example.com", + * industry: "Manufacturing", + * custom_attributes: { + * "paid_subscriber": true, + * "team_mates": 9 + * }, + * remote_created_at: 1394531169, + * monthly_spend: 1000, + * update_last_request_at: true + * }, { + * id: "531ee472cce572a6ec000007", + * name: "Example Inc" + * }] + * } + * + * @example + * { + * companies: [{ + * id: "531ee472cce572a6ec000006", + * monthly_spend: 1000 + * }], + * job: { + * id: "job_v2_1" + * } + * } + */ +export interface BulkUpdateCompaniesRequest { + /** An array of company objects to update. Each must include an `id` and the fields to update. Maximum 100 companies per request. */ + companies: BulkUpdateCompaniesRequest.Companies.Item[]; + /** Optional. Include to append tasks to an existing job. */ + job?: BulkUpdateCompaniesRequest.Job; +} + +export namespace BulkUpdateCompaniesRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom defined id representing the company to update. */ + id: string; + /** The name of the company. */ + name?: string; + /** The name of the plan you have associated with the company. */ + plan?: string; + /** The number of employees in this company. */ + size?: number; + /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ + website?: string; + /** The industry that this company operates in. */ + industry?: string; + /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ + custom_attributes?: Record; + /** The time the company was created by you, in Unix timestamp format. */ + remote_created_at?: number; + /** How much revenue the company generates for your business. Note that this will truncate floats — only whole integers are stored, so 155.98 is truncated to 155, with an upper limit of 2147483647. */ + monthly_spend?: number; + /** Set to true to update the company's last seen time to now. */ + update_last_request_at?: boolean; + } + } + + /** + * Optional. Include to append tasks to an existing job. + */ + export interface Job { + /** The ID of an existing bulk job to append to. */ + id?: string; + } +} diff --git a/src/api/resources/preview/resources/companies/client/requests/CompanySearchRequest.ts b/src/api/resources/preview/resources/companies/client/requests/CompanySearchRequest.ts new file mode 100644 index 00000000..b165f588 --- /dev/null +++ b/src/api/resources/preview/resources/companies/client/requests/CompanySearchRequest.ts @@ -0,0 +1,53 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * query: { + * operator: "AND", + * value: [{ + * field: "name", + * operator: "=", + * value: "my-company" + * }] + * }, + * pagination: { + * per_page: 5 + * }, + * sort: { + * field: "name", + * order: "ascending" + * } + * } + */ +export interface CompanySearchRequest { + query: CompanySearchRequest.Query; + pagination?: Intercom.preview.StartingAfterPaging; + /** An optional object to sort the results by. */ + sort?: CompanySearchRequest.Sort; +} + +export namespace CompanySearchRequest { + export type Query = Intercom.preview.SingleFilterSearchRequest | Intercom.preview.MultipleFilterSearchRequest; + + /** + * An optional object to sort the results by. + */ + export interface Sort { + /** The field to sort the results on. */ + field?: string; + /** The order to sort the results in. Defaults to `descending` when omitted. Values other than `ascending` or `descending` return a `400` error with code `invalid_sort_order`. */ + order?: Sort.Order; + } + + export namespace Sort { + /** The order to sort the results in. Defaults to `descending` when omitted. Values other than `ascending` or `descending` return a `400` error with code `invalid_sort_order`. */ + export const Order = { + Ascending: "ascending", + Descending: "descending", + } as const; + export type Order = (typeof Order)[keyof typeof Order]; + } +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/DeleteCompanyRequest.ts b/src/api/resources/preview/resources/companies/client/requests/DeleteCompanyRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/DeleteCompanyRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/DeleteCompanyRequest.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/DetachContactFromACompanyRequest.ts b/src/api/resources/preview/resources/companies/client/requests/DetachContactFromACompanyRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/DetachContactFromACompanyRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/DetachContactFromACompanyRequest.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/ListAllCompaniesRequest.ts b/src/api/resources/preview/resources/companies/client/requests/ListAllCompaniesRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/ListAllCompaniesRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/ListAllCompaniesRequest.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/ListAttachedContactsRequest.ts b/src/api/resources/preview/resources/companies/client/requests/ListAttachedContactsRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/ListAttachedContactsRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/ListAttachedContactsRequest.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts b/src/api/resources/preview/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts b/src/api/resources/preview/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/RetrieveCompanyRequest.ts b/src/api/resources/preview/resources/companies/client/requests/RetrieveCompanyRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/RetrieveCompanyRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/RetrieveCompanyRequest.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts b/src/api/resources/preview/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts diff --git a/src/api/resources/preview/resources/companies/client/requests/ShowBulkCompaniesJobRequest.ts b/src/api/resources/preview/resources/companies/client/requests/ShowBulkCompaniesJobRequest.ts new file mode 100644 index 00000000..e969d56f --- /dev/null +++ b/src/api/resources/preview/resources/companies/client/requests/ShowBulkCompaniesJobRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "job_v2_1" + * } + */ +export interface ShowBulkCompaniesJobRequest { + /** The unique identifier for the bulk job. */ + id: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/UpdateCompanyRequest.ts b/src/api/resources/preview/resources/companies/client/requests/UpdateCompanyRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/companies/client/requests/UpdateCompanyRequest.ts rename to src/api/resources/preview/resources/companies/client/requests/UpdateCompanyRequest.ts diff --git a/src/api/resources/unstable/resources/companies/client/requests/index.ts b/src/api/resources/preview/resources/companies/client/requests/index.ts similarity index 67% rename from src/api/resources/unstable/resources/companies/client/requests/index.ts rename to src/api/resources/preview/resources/companies/client/requests/index.ts index 7bdff9f7..49b616f3 100644 --- a/src/api/resources/unstable/resources/companies/client/requests/index.ts +++ b/src/api/resources/preview/resources/companies/client/requests/index.ts @@ -1,4 +1,8 @@ export type { AttachContactToACompanyRequest } from "./AttachContactToACompanyRequest.js"; +export type { BulkCreateCompaniesRequest } from "./BulkCreateCompaniesRequest.js"; +export type { BulkDeleteCompaniesRequest } from "./BulkDeleteCompaniesRequest.js"; +export type { BulkUpdateCompaniesRequest } from "./BulkUpdateCompaniesRequest.js"; +export type { CompanySearchRequest } from "./CompanySearchRequest.js"; export type { DeleteCompanyRequest } from "./DeleteCompanyRequest.js"; export type { DetachContactFromACompanyRequest } from "./DetachContactFromACompanyRequest.js"; export type { ListAllCompaniesRequest } from "./ListAllCompaniesRequest.js"; @@ -7,4 +11,5 @@ export type { ListAttachedSegmentsForCompaniesRequest } from "./ListAttachedSegm export type { RetrieveACompanyByIdRequest } from "./RetrieveACompanyByIdRequest.js"; export type { RetrieveCompanyRequest } from "./RetrieveCompanyRequest.js"; export type { ScrollOverAllCompaniesRequest } from "./ScrollOverAllCompaniesRequest.js"; +export type { ShowBulkCompaniesJobRequest } from "./ShowBulkCompaniesJobRequest.js"; export type { UpdateCompanyRequest } from "./UpdateCompanyRequest.js"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/index.ts b/src/api/resources/preview/resources/companies/index.ts similarity index 100% rename from src/api/resources/unstable/resources/customObjectInstances/index.ts rename to src/api/resources/preview/resources/companies/index.ts diff --git a/src/api/resources/preview/resources/companies/types/index.ts b/src/api/resources/preview/resources/companies/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/companies/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/companies/types/Company.ts b/src/api/resources/preview/resources/companies/types/types.ts similarity index 52% rename from src/api/resources/unstable/resources/companies/types/Company.ts rename to src/api/resources/preview/resources/companies/types/types.ts index d2569495..f6651599 100644 --- a/src/api/resources/unstable/resources/companies/types/Company.ts +++ b/src/api/resources/preview/resources/companies/types/types.ts @@ -63,7 +63,7 @@ export namespace Company { export interface Tags { /** The type of the object */ type?: "tag.list"; - tags?: unknown[]; + tags?: Intercom.preview.TagBasic[]; } /** @@ -72,7 +72,7 @@ export namespace Company { export interface Segments { /** The type of the object */ type?: "segment.list"; - segments?: Intercom.unstable.Segment[]; + segments?: Intercom.preview.Segment[]; } /** @@ -81,6 +81,68 @@ export namespace Company { export interface Notes { /** The type of the object */ type?: "note.list"; - notes?: Intercom.unstable.CompanyNote[]; + notes?: Intercom.preview.CompanyNote[]; + } +} + +/** + * A bulk job for creating, updating, or deleting companies asynchronously. Track the job status using the `state` field. + */ +export interface CompaniesBulkJob { + /** The unique identifier for the bulk job. */ + id?: string; + /** The type of the object. */ + type?: "companies.bulk.job"; + /** The current state of the job. */ + state?: CompaniesBulkJob.State; + /** The time the job was created as a UNIX timestamp. */ + created_at?: number; + /** The time the job was last updated as a UNIX timestamp. */ + updated_at?: number; + /** The time the job completed as a UNIX timestamp. Null if not yet completed. */ + completed_at?: number; + /** The tasks that make up this bulk job. */ + tasks?: CompaniesBulkJob.Tasks.Item[]; + /** The URL to check the job status. */ + url?: string; +} + +export namespace CompaniesBulkJob { + /** The current state of the job. */ + export const State = { + Pending: "pending", + Running: "running", + Completed: "completed", + CompletedWithErrors: "completed_with_errors", + } as const; + export type State = (typeof State)[keyof typeof State]; + export type Tasks = Tasks.Item[]; + + export namespace Tasks { + export interface Item { + /** The unique identifier for the task. */ + id?: string; + /** The number of items in this task. */ + item_count?: number; + /** The current state of the task. */ + state?: Item.State; + /** The time the task was created as a UNIX timestamp. */ + created_at?: number; + /** The time the task started as a UNIX timestamp. Null if not yet started. */ + started_at?: number; + /** The time the task completed as a UNIX timestamp. Null if not yet completed. */ + completed_at?: number; + } + + export namespace Item { + /** The current state of the task. */ + export const State = { + Pending: "pending", + Running: "running", + Completed: "completed", + CompletedWithErrors: "completed_with_errors", + } as const; + export type State = (typeof State)[keyof typeof State]; + } } } diff --git a/src/api/resources/preview/resources/contacts/client/Client.ts b/src/api/resources/preview/resources/contacts/client/Client.ts new file mode 100644 index 00000000..096eeaf2 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/Client.ts @@ -0,0 +1,2570 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace ContactsClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Everything about your contacts + */ +export class ContactsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ContactsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * You can fetch a list of companies that are associated to a contact. + * + * @param {Intercom.preview.ListCompaniesForAContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.contacts.listCompaniesForAContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public listCompaniesForAContact( + request: Intercom.preview.ListCompaniesForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listCompaniesForAContact(request, requestOptions)); + } + + private async __listCompaniesForAContact( + request: Intercom.preview.ListCompaniesForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/companies`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ContactAttachedCompanies, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}/companies"); + } + + /** + * List the companies a contact has been granted access to. + * + * A granted company lets the contact read that company's tickets in the customer portal. It is separate from company membership — granting a company does not attach the contact to it, and [`GET /contacts/{id}/companies`](/docs/references/preview/rest-api/api.intercom.io/contacts/listcompaniesforacontact) does not include grants. + * + * `company_ids` holds the `company_id` values you set on your companies, so the list round-trips with the `company_ids` you send to `PUT /contacts/{contact_id}/granted_companies`. The list is sorted by company id and paginated. + * + * Returns an empty list when granted companies are not enabled for the workspace. + * + * Requires the `read_users_companies` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.ListGrantedCompaniesForAContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.contacts.listGrantedCompaniesForAContact({ + * contact_id: "63a07ddf05a32042dffac965", + * page: 1, + * per_page: 1, + * order: "asc" + * }) + */ + public listGrantedCompaniesForAContact( + request: Intercom.preview.ListGrantedCompaniesForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listGrantedCompaniesForAContact(request, requestOptions)); + } + + private async __listGrantedCompaniesForAContact( + request: Intercom.preview.ListGrantedCompaniesForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { contact_id: contactId, page, per_page: perPage, order } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (order != null) { + _queryParams.order = order; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(contactId)}/granted_companies`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.GrantedCompanyList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/contacts/{contact_id}/granted_companies", + ); + } + + /** + * Replace the full set of companies a contact has been granted access to. + * + * This is a replacement, not an append. The `company_ids` you send become the contact's entire granted set — any company id you leave out is dropped. To add a company, send the existing ids plus the new one; to remove one, send the existing ids minus that one; to drop every grant, send an empty array. + * + * Identify companies by the `company_id` you set on them, the same values [`GET /contacts/{contact_id}/granted_companies`](/docs/references/preview/rest-api/api.intercom.io/contacts/listgrantedcompaniesforacontact) returns. Duplicates in the request are collapsed. A contact can be granted at most 100 companies. + * + * The response echoes the stored set, so a `200` is confirmation of exactly what the contact can now read. + * + * {% admonition type="info" name="Requires granted companies to be enabled" %} + * This endpoint returns `404` with the code `granted_companies_not_enabled` unless granted companies are enabled for the workspace. Contact Intercom Support to enable it. + * {% /admonition %} + * + * Requires the `write_users_companies` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.ReplaceGrantedCompaniesRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.ServiceUnavailableError} + * + * @example + * await client.preview.contacts.replaceGrantedCompaniesForAContact({ + * contact_id: "63a07ddf05a32042dffac965", + * company_ids: ["acme-corp", "1234", "globex"] + * }) + * + * @example + * await client.preview.contacts.replaceGrantedCompaniesForAContact({ + * contact_id: "63a07ddf05a32042dffac965", + * company_ids: ["globex"] + * }) + * + * @example + * await client.preview.contacts.replaceGrantedCompaniesForAContact({ + * contact_id: "63a07ddf05a32042dffac965", + * company_ids: ["acme-corp", "1234"] + * }) + */ + public replaceGrantedCompaniesForAContact( + request: Intercom.preview.ReplaceGrantedCompaniesRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__replaceGrantedCompaniesForAContact(request, requestOptions)); + } + + private async __replaceGrantedCompaniesForAContact( + request: Intercom.preview.ReplaceGrantedCompaniesRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { contact_id: contactId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(contactId)}/granted_companies`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.GrantedCompanyList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 503: + throw new Intercom.preview.ServiceUnavailableError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PUT", + "/contacts/{contact_id}/granted_companies", + ); + } + + /** + * Remove a single company from a contact's granted set, leaving the contact's other grants in place. + * + * Identify the company by the `company_id` you set on it, the same value [`GET /contacts/{contact_id}/granted_companies`](/docs/references/preview/rest-api/api.intercom.io/contacts/listgrantedcompaniesforacontact) returns. A `company_id` containing a dot or a slash is supported — URL-encode a slash as `%2F`. + * + * This endpoint is not idempotent. Removing a company the contact is not currently granted returns `404` with the code `company_not_found`, so repeating a successful call returns `404` rather than `204`. Treat the first `204` as the confirmation. + * + * {% admonition type="info" name="Requires granted companies to be enabled" %} + * This endpoint returns `404` with the code `granted_companies_not_enabled` unless granted companies are enabled for the workspace. Contact Intercom Support to enable it. + * {% /admonition %} + * + * Requires the `write_users_companies` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.RemoveGrantedCompanyFromAContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.contacts.removeGrantedCompanyFromAContact({ + * contact_id: "63a07ddf05a32042dffac965", + * company_id: "acme-corp" + * }) + */ + public removeGrantedCompanyFromAContact( + request: Intercom.preview.RemoveGrantedCompanyFromAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__removeGrantedCompanyFromAContact(request, requestOptions)); + } + + private async __removeGrantedCompanyFromAContact( + request: Intercom.preview.RemoveGrantedCompanyFromAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { contact_id: contactId, company_id: companyId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(contactId)}/granted_companies/${core.url.encodePathParam(companyId)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/contacts/{contact_id}/granted_companies/{company_id}", + ); + } + + /** + * You can fetch a list of segments that are associated to a contact. + * + * @param {Intercom.preview.ListSegmentsForAContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.contacts.listSegmentsForAContact({ + * contact_id: "63a07ddf05a32042dffac965" + * }) + */ + public listSegmentsForAContact( + request: Intercom.preview.ListSegmentsForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listSegmentsForAContact(request, requestOptions)); + } + + private async __listSegmentsForAContact( + request: Intercom.preview.ListSegmentsForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { contact_id: contactId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(contactId)}/segments`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactSegments, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/contacts/{contact_id}/segments", + ); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + * + * The data property will show a combined list of: + * + * 1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving. + * + * **Note:** This endpoint only returns subscriptions where the contact has explicitly configured their preference. Subscriptions that are in the default state — where the contact has not made an explicit opt-in or opt-out choice — are not included in the response. + * + * @param {Intercom.preview.ListSubscriptionsForAContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.contacts.listSubscriptionsForAContact({ + * contact_id: "63a07ddf05a32042dffac965" + * }) + */ + public listSubscriptionsForAContact( + request: Intercom.preview.ListSubscriptionsForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listSubscriptionsForAContact(request, requestOptions)); + } + + private async __listSubscriptionsForAContact( + request: Intercom.preview.ListSubscriptionsForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { contact_id: contactId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(contactId)}/subscriptions`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.SubscriptionTypeList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/contacts/{contact_id}/subscriptions", + ); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + * + * @param {Intercom.preview.ListTagsForAContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.contacts.listTagsForAContact({ + * contact_id: "63a07ddf05a32042dffac965" + * }) + */ + public listTagsForAContact( + request: Intercom.preview.ListTagsForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listTagsForAContact(request, requestOptions)); + } + + private async __listTagsForAContact( + request: Intercom.preview.ListTagsForAContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { contact_id: contactId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(contactId)}/tags`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.TagList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{contact_id}/tags"); + } + + /** + * Fetch a paginated list of the contacts in your workspace that are no longer active, + * so you can recover ones whose `id`, `email`, or `external_id` you no longer have and + * then permanently delete them. Each entry carries a `status` describing why the contact + * is inactive: `archived`, `blocked`, `merged`, `pending_deletion`, or `permanently_deleted`. + * `merged_into_id` is present only when `status` is `merged`, and `external_id` and `email` + * are `null` for `permanently_deleted` contacts. + * + * @param {Intercom.preview.ListDeletedContactsRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.listDeletedContacts({ + * per_page: 1, + * page: 1 + * }) + */ + public listDeletedContacts( + request: Intercom.preview.ListDeletedContactsRequest = {}, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listDeletedContacts(request, requestOptions)); + } + + private async __listDeletedContacts( + request: Intercom.preview.ListDeletedContactsRequest = {}, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { per_page: perPage, page } = request; + const _queryParams: Record = {}; + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (page != null) { + _queryParams.page = page.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/deleted", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.DeletedContactList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/deleted"); + } + + /** + * You can fetch the details of a single contact. + * + * {% admonition type="info" name="Merged contacts return 410 Gone" %} + * If a contact has been merged into another contact via the Merge endpoint (`POST /contacts/merge`), requesting it by its original ID will return **HTTP 410 Gone** with a `Link` header pointing to the canonical (merged-into) contact. + * + * **Response headers:** + * ``` + * Link: ; rel="canonical" + * ``` + * + * **Response body:** + * ```json + * { + * "type": "error.list", + * "errors": [{ "code": "contact_merged", "message": "This contact has been merged. See the 'Link' header for the canonical contact." }] + * } + * ``` + * + * The `Link` header contains the path to the final merge target, resolving multi-hop merge chains (up to 3 hops). + * {% /admonition %} + * + * @param {Intercom.preview.ShowContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.GoneError} + * + * @example + * await client.preview.contacts.showContact({ + * id: "63a07ddf05a32042dffac965", + * include_merge_history: true + * }) + */ + public showContact( + request: Intercom.preview.ShowContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__showContact(request, requestOptions)); + } + + private async __showContact( + request: Intercom.preview.ShowContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id, include_merge_history: includeMergeHistory } = request; + const _queryParams: Record = {}; + if (includeMergeHistory != null) { + _queryParams.include_merge_history = includeMergeHistory.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ShowContactResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 410: + throw new Intercom.preview.GoneError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}"); + } + + /** + * You can update an existing contact (ie. user or lead). + * + * {% admonition type="info" %} + * This endpoint handles both **contact updates** and **custom object associations**. + * + * See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. + * {% /admonition %} + * + * @param {Intercom.preview.UpdateContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.updateContact({ + * id: "63a07ddf05a32042dffac965", + * include_merge_history: true, + * email: "joebloggs@intercom.io", + * name: "joe bloggs" + * }) + * + * @example + * await client.preview.contacts.updateContact({ + * id: "63a07ddf05a32042dffac965", + * include_merge_history: true, + * custom_attributes: { + * "order": [ + * "21" + * ] + * } + * }) + */ + public updateContact( + request: Intercom.preview.UpdateContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateContact(request, requestOptions)); + } + + private async __updateContact( + request: Intercom.preview.UpdateContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id, include_merge_history: includeMergeHistory, ..._body } = request; + const _queryParams: Record = {}; + if (includeMergeHistory != null) { + _queryParams.include_merge_history = includeMergeHistory.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.UpdateContactResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/contacts/{id}"); + } + + /** + * You can delete a single contact. + * + * @param {Intercom.preview.DeleteContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.deleteContact({ + * id: "id" + * }) + */ + public deleteContact( + request: Intercom.preview.DeleteContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteContact(request, requestOptions)); + } + + private async __deleteContact( + request: Intercom.preview.DeleteContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactDeleted, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/contacts/{id}"); + } + + /** + * You can merge one contact into another. Both lead-into-user and user-into-user merges are supported: the source contact (`from`) may have a `role` of `lead` or `user`, and the destination contact (`into`) must have a `role` of `user`. + * + * {% admonition type="warning" name="User-to-user merges" %} + * When you merge a user into another user, the source user's attribute values (standard and custom) are discarded and are not moved onto the target user. The target user keeps its own attribute values. Records associated with the source, such as conversations, notes, and tags, are still reassigned to the target. + * + * Merging a user into another user requires the `merge_users` OAuth scope on your access token, in addition to the scope required for lead-into-user merges. Tokens without this scope receive a `401 Unauthorized` when the source contact is a user. + * {% /admonition %} + * + * {% admonition type="warning" name="Merged contacts are not retrievable via the API" %} + * Once a merge is completed, the source contact (`from`) is permanently removed from the active contact list. This means: + * - **GET /contacts/{id}** — Requesting the source contact by its original ID will return `410 Gone` with a `Link` header pointing to the canonical (merged-into) contact. + * - **POST /contacts/search** — The source contact will not appear in search results, including queries filtered by `updated_at`. + * - **GET /contacts** — The source contact will not appear in list results. + * + * Only the target contact (`into`) remains accessible. If your application stores contact IDs, update them to use the target contact's ID after a merge. + * {% /admonition %} + * + * @param {Intercom.preview.MergeContactsRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.mergeContact({ + * include_merge_history: true, + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80" + * }) + * + * @example + * await client.preview.contacts.mergeContact({ + * include_merge_history: true, + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80", + * skip_duplicate_validation: true + * }) + */ + public mergeContact( + request: Intercom.preview.MergeContactsRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__mergeContact(request, requestOptions)); + } + + private async __mergeContact( + request: Intercom.preview.MergeContactsRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { include_merge_history: includeMergeHistory, ..._body } = request; + const _queryParams: Record = {}; + if (includeMergeHistory != null) { + _queryParams.include_merge_history = includeMergeHistory.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/merge", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.MergeContactResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/merge"); + } + + /** + * Preview the result of merging one contact into another without applying the merge. This is a read-only dry run: it reports whether the merge is allowed and, if so, exactly what would change, **without modifying any data**. + * + * Send the same `from` and `into` contact IDs you would pass to [Merge two contacts](/docs/references/preview/rest-api/api.intercom.io/contacts/mergecontact). As with the merge endpoint, `from` may have a `role` of `lead` or `user`, and `into` must have a `role` of `user`. You can optionally pass `custom_attribute_names` to include specific custom attributes in the previewed attribute changes. + * + * - When `allowed` is `true`, the response contains a `summary`: every attribute change (with the resulting value on the surviving contact) and, for each object type, two counts — `from`, how many are on the source contact and would move to the destination, and `into`, how many the destination already has. Counts are reported for conversations, tickets, phone calls, notes, and tags. `conversations` counts non-ticket conversations only; tickets are reported separately under `tickets`, and `phone_calls` is present only for phone-channel merges. + * - When `allowed` is `false`, the response contains `reasons`. Each reason has a stable `code` you can branch on and a human-readable `message` you can display. + * + * {% admonition type="warning" name="Previewing non-duplicate contacts" %} + * By default a merge requires the two contacts to share an identifier (email or phone). Set `skip_duplicate_validation` to `true` to preview a merge of contacts that don't, the same rule the merge endpoint enforces. + * {% /admonition %} + * + * When `allowed` is `false`, `reasons[].code` is one of: + * + * | code | meaning | + * | --- | --- | + * | `source_same_as_target` | The source contact (`from`) and the destination contact (`into`) are the same contact. A contact can't be merged into itself. | + * | `invalid_merge_role_pair` | The `from`/`into` roles aren't mergeable. `into` must be a user. | + * | `no_shared_identifier` | The contacts share no email or phone. Set `skip_duplicate_validation` to preview anyway. | + * | `facebook_user` | Facebook contacts can't be merged. | + * | `external_lead_channel_not_allowed` | The source is an external-channel lead that isn't eligible for merging. | + * | `mailing_list` | Contacts created from a mailing list can't be merged. | + * | `user_to_lead` | `into` is a lead or visitor. A user can only be merged into another user. | + * | `whatsapp_data_cannot_be_merged` | The WhatsApp number on the source contact can't be reassigned to the destination. | + * | `telegram_data_cannot_be_merged` | The Telegram sender on the source contact can't be reassigned to the destination. | + * | `source_has_telegram_data` | The source contact has Telegram data, which user-into-user merges don't yet support moving. | + * | `phone_data_cannot_be_merged` | The phone data on the source contact can't be reassigned to the destination. | + * + * @param {Intercom.preview.MergePreviewRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.previewMergeContact({ + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80" + * }) + */ + public previewMergeContact( + request: Intercom.preview.MergePreviewRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__previewMergeContact(request, requestOptions)); + } + + private async __previewMergeContact( + request: Intercom.preview.MergePreviewRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/merge/preview", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.MergePreviewResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/merge/preview"); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + * + * To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`. + * + * This will accept a query object in the body which will define your filters in order to search for contacts. + * + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is `50` results per page. + * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. + * {% /admonition %} + * ### Merged Contacts + * + * Contacts that have been merged (via POST /contacts/merge) are excluded from search results. If a contact was recently merged into another, it will no longer appear in queries filtered by `updated_at` or any other field. Only the target contact from the merge remains searchable. + * + * ### Contact Creation Delay + * + * If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. + * + * ### Nesting & Limitations + * + * You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be: + * * There's a limit of max 2 nested filters + * * There's a limit of max 15 filters for each AND or OR group + * + * ### Searching for Timestamp Fields + * + * Standard timestamp fields and Date custom attributes behave differently. + * + * **Standard timestamp fields** (`created_at`, `updated_at`, `last_seen_at` etc.) are filtered on the exact second, in UTC. `=` matches only Contacts whose value is that exact second, and `>`, `<`, `>=` and `<=` compare against the exact instant you pass - the value is not rounded or truncated. These fields report a type of `datetime` on the Data Attributes endpoint. Note that `!=` also matches Contacts with no value set for the field. + * + * **Date custom attributes** are matched by calendar day, and the day boundary is always UTC regardless of your workspace's timezone. `=` matches the whole UTC day, `>` matches from the start of the *next* UTC day, and `<` matches everything before the start of that day. The `!=`, `>=`, `<=`, `IN` and `NIN` operators are not supported on these fields and return an error. + * + * **Example.** Searching for `created_at` greater than `1577869200` (January 1st, 2020 9:00 AM UTC) returns Contacts created after that exact instant. Passing the same value for a Date custom attribute truncates it to `1577836800` (January 1st, 2020 12:00 AM UTC), so those results begin from January 2nd, 2020 12:00 AM UTC. + * + * Only search queries behave this way. Responses always carry the full UNIX timestamp, and sorting uses the full value. + * + * ### Accepted Fields + * + * Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + * + * | Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String
Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Datetime (Unix timestamp in seconds) | + * | signed_up_at | Datetime (Unix timestamp in seconds) | + * | updated_at | Datetime (Unix timestamp in seconds) | + * | last_seen_at | Datetime (Unix timestamp in seconds) | + * | last_contacted_at | Datetime (Unix timestamp in seconds) | + * | last_replied_at | Datetime (Unix timestamp in seconds) | + * | last_email_opened_at | Datetime (Unix timestamp in seconds) | + * | last_email_clicked_at | Datetime (Unix timestamp in seconds) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Datetime (Unix timestamp in seconds) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Datetime (Unix timestamp in seconds) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | Matches the attribute's own type
(String, Integer, Float, Boolean or Date) | + * + * ### Accepted Operators + * + * {% admonition type="warning" name="Operators not supported on Date custom attributes" %} + * Date custom attributes do not support the `!=`, `>=`, or `<=` operators. Using them returns an error. Standard timestamp fields (`created_at`, `updated_at` etc.) do support these operators, and are filtered on the exact second. + * {% /admonition %} + * + * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). Which operators are valid depends on the field's type - see the "Valid Types" column below. Searching by `tag_id` supports only the `=` and `!=` operators. + * + * | Operator | Valid Types | Description | + * | :------- | :---------------------------------- | :----------------------------------------------------------------------| + * | = | All | Equals | + * | != | All except Date | Doesn't Equal
Also matches Contacts with no value set | + * | IN | All except Date, Datetime and tag_id | In
Shortcut for `OR` queries
Values must be in Array | + * | NIN | All except Date, Datetime and tag_id | Not In
Shortcut for `OR !` queries
Values must be in Array | + * | > | Integer
Datetime
Date | Greater than
On Date custom attributes, matches from the start of the next day | + * | < | Integer
Datetime
Date | Lower than
On Date custom attributes, matches before the start of the day | + * | >= | Integer
Datetime | Greater than or equal to
Not supported on Date custom attributes | + * | <= | Integer
Datetime | Lower than or equal to
Not supported on Date custom attributes | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With | + * + * @param {Intercom.preview.ContactSearchRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.searchContacts({ + * include_merge_history: true, + * query: { + * operator: "AND", + * value: [{ + * field: "created_at", + * operator: ">", + * value: "1306054154" + * }] + * }, + * pagination: { + * per_page: 5 + * }, + * sort: { + * field: "created_at", + * order: "ascending" + * } + * }) + */ + public searchContacts( + request: Intercom.preview.ContactSearchRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchContacts(request, requestOptions)); + } + + private async __searchContacts( + request: Intercom.preview.ContactSearchRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { include_merge_history: includeMergeHistory, ..._body } = request; + const _queryParams: Record = {}; + if (includeMergeHistory != null) { + _queryParams.include_merge_history = includeMergeHistory.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/search", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/search"); + } + + /** + * You can fetch a list of contact activity events for your workspace, such as when contacts are created, role updated, merged, or deleted. Events are returned oldest first. + * + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is `50` results per page, with a maximum of `150`. + * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. + * {% /admonition %} + * + * @param {Intercom.preview.ListContactActivitiesRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.listContactActivities({ + * per_page: 1, + * starting_after: "starting_after" + * }) + */ + public listContactActivities( + request: Intercom.preview.ListContactActivitiesRequest = {}, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listContactActivities(request, requestOptions)); + } + + private async __listContactActivities( + request: Intercom.preview.ListContactActivitiesRequest = {}, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { per_page: perPage, starting_after: startingAfter } = request; + const _queryParams: Record = {}; + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (startingAfter != null) { + _queryParams.starting_after = startingAfter; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/activities", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactActivityList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/activities"); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="info" name="Merged contacts" %} + * Contacts that have been merged (via POST /contacts/merge) will not appear in list results. Only the target contact from the merge remains accessible. + * {% /admonition %} + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is `10` results per page, with a maximum of `150`. + * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. + * {% /admonition %} + * + * @param {Intercom.preview.ListContactsRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.listContacts({ + * include_merge_history: true + * }) + */ + public listContacts( + request: Intercom.preview.ListContactsRequest = {}, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listContacts(request, requestOptions)); + } + + private async __listContacts( + request: Intercom.preview.ListContactsRequest = {}, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { include_merge_history: includeMergeHistory } = request; + const _queryParams: Record = {}; + if (includeMergeHistory != null) { + _queryParams.include_merge_history = includeMergeHistory.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts"); + } + + /** + * You can create a new contact (ie. user or lead). + * + * @param {Intercom.CreateContactRequestTwo} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.createContact({ + * "email": "joebloggs@intercom.io" + * }) + */ + public createContact( + request?: Intercom.CreateContactRequestTwo, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createContact(request, requestOptions)); + } + + private async __createContact( + request?: Intercom.CreateContactRequestTwo, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.CreateContactResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts"); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + * + * {% admonition type="info" name="Merged contacts return 410 Gone" %} + * If the contact with this external ID has been merged into another contact, the API returns **HTTP 410 Gone** with a `Link` header pointing to the canonical (merged-into) contact. See `GET /contacts/{id}` for details on the response format. + * {% /admonition %} + * + * @param {Intercom.preview.ShowContactByExternalIdRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.GoneError} + * + * @example + * await client.preview.contacts.showContactByExternalId({ + * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27", + * include_merge_history: true + * }) + */ + public showContactByExternalId( + request: Intercom.preview.ShowContactByExternalIdRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__showContactByExternalId(request, requestOptions)); + } + + private async __showContactByExternalId( + request: Intercom.preview.ShowContactByExternalIdRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { external_id: externalId, include_merge_history: includeMergeHistory } = request; + const _queryParams: Record = {}; + if (includeMergeHistory != null) { + _queryParams.include_merge_history = includeMergeHistory.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/find_by_external_id/${core.url.encodePathParam(externalId)}`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ShowContactByExternalIdResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 410: + throw new Intercom.preview.GoneError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/contacts/find_by_external_id/{external_id}", + ); + } + + /** + * You can archive a single contact. + * + * @param {Intercom.preview.ArchiveContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.preview.contacts.archiveContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public archiveContact( + request: Intercom.preview.ArchiveContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__archiveContact(request, requestOptions)); + } + + private async __archiveContact( + request: Intercom.preview.ArchiveContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/archive`, + ), + method: "POST", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactArchived, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/archive"); + } + + /** + * You can unarchive a single contact. + * + * @param {Intercom.preview.UnarchiveContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.preview.contacts.unarchiveContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public unarchiveContact( + request: Intercom.preview.UnarchiveContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__unarchiveContact(request, requestOptions)); + } + + private async __unarchiveContact( + request: Intercom.preview.UnarchiveContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/unarchive`, + ), + method: "POST", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactUnarchived, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/unarchive"); + } + + /** + * Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) + * + * @param {Intercom.preview.BlockContactRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.preview.contacts.blockContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public blockContact( + request: Intercom.preview.BlockContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__blockContact(request, requestOptions)); + } + + private async __blockContact( + request: Intercom.preview.BlockContactRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/block`, + ), + method: "POST", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactBlocked, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/block"); + } + + /** + * Retrieve the paginated list of contacts that have been merged into a given contact. + * + * Only available for contacts with a `user` role. Returns a `404` if the contact is not found or has a `lead` role. + * + * @param {Intercom.preview.ListContactMergeHistoryRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.contacts.listContactMergeHistory({ + * id: "63a07ddf05a32042dffac965", + * cursor: "cursor", + * per_page: 1, + * order: "asc" + * }) + */ + public listContactMergeHistory( + request: Intercom.preview.ListContactMergeHistoryRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listContactMergeHistory(request, requestOptions)); + } + + private async __listContactMergeHistory( + request: Intercom.preview.ListContactMergeHistoryRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id, cursor, per_page: perPage, order } = request; + const _queryParams: Record = {}; + if (cursor != null) { + _queryParams.cursor = cursor; + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (order != null) { + _queryParams.order = order; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/merge_history`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.MergeHistoryList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}/merge_history"); + } + + /** + * You can bulk create contacts by submitting an array of contact objects. This is a **strict create** and never updates an existing contact. + * + * The endpoint creates an async job that processes the items in the background. Use the returned job ID with `GET /contacts/bulk/{id}` to check the job status. + * + * Only the fields listed in the request schema below can be set. Any other fields in a contact object are ignored. + * + * {% admonition type="info" name="Handling existing contacts" %} + * If a contact already exists with the given `external_id` or `email` (including an archived contact), that item is rejected and the job's `state` ends as `completed_with_errors`. New contacts in the same request are still created. The job `state` from `GET /contacts/bulk/{id}` is the signal that one or more items were rejected. + * + * Created contacts aren't returned with IDs in the response. Look them up afterwards with [Get a contact by External ID](/docs/references/preview/rest-api/api.intercom.io/contacts/showcontactbyexternalid) or [Search contacts](/docs/references/preview/rest-api/api.intercom.io/contacts/searchcontacts). + * {% /admonition %} + * + * {% admonition type="info" name="Limits" %} + * - Maximum of 100 contacts per request. + * - You can append tasks to an existing job by including `job.id` in the request body. + * - Tag application is best-effort and processed asynchronously: unknown tag IDs are skipped, and per-tag results are not returned in the job status. + * {% /admonition %} + * + * @param {Intercom.preview.BulkCreateContactsRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.contacts.bulkCreateContacts({ + * contacts: [{ + * external_id: "abc123", + * email: "joe@bloggs.com", + * name: "Joe Bloggs", + * role: "user", + * phone: "+353871234567", + * avatar: "https://www.example.com/avatar_image.jpg", + * language_override: "fr", + * custom_attributes: { + * "plan": "pro" + * }, + * signed_up_at: 1571672154, + * last_seen_at: 1571672154, + * owner_id: "321", + * unsubscribed_from_emails: false, + * companies: [{ + * company_id: "6", + * name: "Blue Sun" + * }], + * tags: { + * add: [{ + * id: "123" + * }] + * } + * }] + * }) + * + * @example + * await client.preview.contacts.bulkCreateContacts({ + * contacts: [{ + * external_id: "abc123", + * email: "joe@bloggs.com", + * companies: [{ + * company_id: "6", + * name: "Blue Sun" + * }, { + * company_id: "7", + * name: "Weyland-Yutani" + * }] + * }] + * }) + * + * @example + * await client.preview.contacts.bulkCreateContacts({ + * contacts: [{ + * external_id: "abc123", + * name: "Contact Name", + * tags: { + * add: [{ + * id: "123" + * }] + * } + * }] + * }) + * + * @example + * await client.preview.contacts.bulkCreateContacts({ + * contacts: [{ + * external_id: "abc123", + * email: "joe@bloggs.com", + * language_override: "de" + * }], + * job: { + * id: "job_v2_1" + * } + * }) + */ + public bulkCreateContacts( + request: Intercom.preview.BulkCreateContactsRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__bulkCreateContacts(request, requestOptions)); + } + + private async __bulkCreateContacts( + request: Intercom.preview.BulkCreateContactsRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/bulk", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactsBulkJob, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/bulk"); + } + + /** + * You can bulk update contacts by submitting an array of contact objects with the fields to update. Each contact must include an `id` field identifying the contact to update. You can also add or remove tags on each contact by including a `tags` object. + * + * Only the fields listed in the request schema below can be set. Any other fields in a contact object are ignored. + * + * The endpoint creates an async job that processes the updates in the background. Use the returned job ID with `GET /contacts/bulk/{id}` to check the job status. + * + * {% admonition type="info" name="Limits" %} + * - Maximum of 100 contacts per request. + * - You can append tasks to an existing job by including `job.id` in the request body. + * - Tag application is best-effort and processed asynchronously: unknown tag IDs are skipped, and per-tag results are not returned in the job status. + * {% /admonition %} + * + * @param {Intercom.preview.BulkUpdateContactsRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.contacts.bulkUpdateContacts({ + * contacts: [{ + * id: "abc123", + * external_id: "ext123", + * email: "joe@bloggs.com", + * name: "Joe Bloggs", + * phone: "+353871234567", + * avatar: "https://www.example.com/avatar_image.jpg", + * owner_id: "321", + * unsubscribed_from_emails: false, + * language_override: "fr", + * custom_attributes: { + * "plan": "pro" + * }, + * companies: [{ + * company_id: "6", + * name: "Blue Sun" + * }], + * tags: { + * add: [{ + * id: "123" + * }], + * remove: [{ + * id: "987" + * }] + * } + * }] + * }) + * + * @example + * await client.preview.contacts.bulkUpdateContacts({ + * contacts: [{ + * id: "abc123", + * companies: [{ + * company_id: "6", + * name: "Blue Sun" + * }, { + * company_id: "7", + * remove: true + * }] + * }] + * }) + * + * @example + * await client.preview.contacts.bulkUpdateContacts({ + * contacts: [{ + * id: "abc123", + * name: "Updated Name", + * tags: { + * add: [{ + * id: "123" + * }], + * remove: [{ + * id: "456" + * }] + * } + * }] + * }) + * + * @example + * await client.preview.contacts.bulkUpdateContacts({ + * contacts: [{ + * id: "abc123", + * language_override: "de" + * }], + * job: { + * id: "job_v2_1" + * } + * }) + */ + public bulkUpdateContacts( + request: Intercom.preview.BulkUpdateContactsRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__bulkUpdateContacts(request, requestOptions)); + } + + private async __bulkUpdateContacts( + request: Intercom.preview.BulkUpdateContactsRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/bulk", + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactsBulkJob, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/contacts/bulk"); + } + + /** + * You can delete contacts in bulk by submitting an array of contact `id`s. + * + * The endpoint creates an async job that processes the deletes in the background. Use the returned job ID with `GET /contacts/bulk/{id}` to check the job status. + * + * {% admonition type="warning" name="Permanent deletion" %} + * A contact that doesn't exist, or can't be deleted, fails that item and the job's `state` ends as `completed_with_errors` (visible via `GET /contacts/bulk/{id}`) without failing the rest of the batch. + * {% /admonition %} + * + * {% admonition type="info" name="Limits" %} + * - Maximum of 100 contacts per request. + * - You can append tasks to an existing job by including `job.id` in the request body. + * {% /admonition %} + * + * @param {Intercom.preview.BulkDeleteContactsRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.contacts.bulkDeleteContacts({ + * contacts: [{ + * id: "abc123" + * }, { + * id: "def456" + * }] + * }) + * + * @example + * await client.preview.contacts.bulkDeleteContacts({ + * contacts: [{ + * id: "abc123" + * }], + * job: { + * id: "job_v2_1" + * } + * }) + */ + public bulkDeleteContacts( + request: Intercom.preview.BulkDeleteContactsRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__bulkDeleteContacts(request, requestOptions)); + } + + private async __bulkDeleteContacts( + request: Intercom.preview.BulkDeleteContactsRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/bulk/delete", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactsBulkJob, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/bulk/delete"); + } + + /** + * You can check the status of a bulk contact update job. The `state` field indicates the overall job progress: `pending`, `running`, `completed`, or `completed_with_errors`. + * + * @param {Intercom.preview.ShowBulkUpdateContactsJobRequest} request + * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.contacts.showBulkUpdateContactsJob({ + * id: "job_v2_1" + * }) + */ + public showBulkUpdateContactsJob( + request: Intercom.preview.ShowBulkUpdateContactsJobRequest, + requestOptions?: ContactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__showBulkUpdateContactsJob(request, requestOptions)); + } + + private async __showBulkUpdateContactsJob( + request: Intercom.preview.ShowBulkUpdateContactsJobRequest, + requestOptions?: ContactsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/bulk/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ContactsBulkJob, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/bulk/{id}"); + } +} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/index.ts b/src/api/resources/preview/resources/contacts/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/customChannelEvents/client/index.ts rename to src/api/resources/preview/resources/contacts/client/index.ts diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ArchiveContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ArchiveContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/requests/ArchiveContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/ArchiveContactRequest.ts diff --git a/src/api/resources/unstable/resources/contacts/client/requests/BlockContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/BlockContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/requests/BlockContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/BlockContactRequest.ts diff --git a/src/api/resources/preview/resources/contacts/client/requests/BulkCreateContactsRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/BulkCreateContactsRequest.ts new file mode 100644 index 00000000..2ab5f51f --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/BulkCreateContactsRequest.ts @@ -0,0 +1,155 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * contacts: [{ + * external_id: "abc123", + * email: "joe@bloggs.com", + * name: "Joe Bloggs", + * role: "user", + * phone: "+353871234567", + * avatar: "https://www.example.com/avatar_image.jpg", + * language_override: "fr", + * custom_attributes: { + * "plan": "pro" + * }, + * signed_up_at: 1571672154, + * last_seen_at: 1571672154, + * owner_id: "321", + * unsubscribed_from_emails: false, + * companies: [{ + * company_id: "6", + * name: "Blue Sun" + * }], + * tags: { + * add: [{ + * id: "123" + * }] + * } + * }] + * } + * + * @example + * { + * contacts: [{ + * external_id: "abc123", + * email: "joe@bloggs.com", + * companies: [{ + * company_id: "6", + * name: "Blue Sun" + * }, { + * company_id: "7", + * name: "Weyland-Yutani" + * }] + * }] + * } + * + * @example + * { + * contacts: [{ + * external_id: "abc123", + * name: "Contact Name", + * tags: { + * add: [{ + * id: "123" + * }] + * } + * }] + * } + * + * @example + * { + * contacts: [{ + * external_id: "abc123", + * email: "joe@bloggs.com", + * language_override: "de" + * }], + * job: { + * id: "job_v2_1" + * } + * } + */ +export interface BulkCreateContactsRequest { + /** An array of contact objects to create. Maximum 100 contacts per request. */ + contacts: BulkCreateContactsRequest.Contacts.Item[]; + /** Optional. Include to append tasks to an existing job. */ + job?: BulkCreateContactsRequest.Job; +} + +export namespace BulkCreateContactsRequest { + export type Contacts = Contacts.Item[]; + + export namespace Contacts { + export interface Item { + /** A unique identifier for the contact which you have defined. */ + external_id?: string; + /** The contact's email address. */ + email?: string; + /** The contact's name. */ + name?: string; + /** The contact's role. One of `user` or `lead`. Leads are exempt from the uniqueness check described above. */ + role?: string; + /** The contact's phone number. */ + phone?: string; + /** An image URL containing the avatar of the contact. */ + avatar?: string; + /** A preferred language setting for the contact, used by the Intercom Messenger. */ + language_override?: string; + /** Custom attributes to set on the contact. */ + custom_attributes?: Record; + /** The time the contact signed up, in Unix timestamp format. */ + signed_up_at?: number; + /** The time the contact was last seen, in Unix timestamp format. */ + last_seen_at?: number; + /** The ID of an admin that has been assigned account ownership of the contact. */ + owner_id?: string; + /** Whether the contact is unsubscribed from emails. */ + unsubscribed_from_emails?: boolean; + /** A list of companies to associate with the contact. Each company is identified by the `company_id` you have defined. A company that does not exist is created, and one that already exists has the supplied attributes applied to it. */ + companies?: Item.Companies.Item[]; + /** Tags to add to the contact. Each tag is identified by its `id`, which must be a positive integer for a tag that already exists in your workspace. Tag application is best-effort: unknown tag IDs are skipped while the rest of the contact create still applies. Per-tag results are not yet returned in the job status. */ + tags?: Item.Tags; + } + + export namespace Item { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The company ID you have defined for the company. */ + company_id: string; + /** The name of the company. */ + name?: string; + } + } + + /** + * Tags to add to the contact. Each tag is identified by its `id`, which must be a positive integer for a tag that already exists in your workspace. Tag application is best-effort: unknown tag IDs are skipped while the rest of the contact create still applies. Per-tag results are not yet returned in the job status. + */ + export interface Tags { + /** Tags to add to the contact. */ + add?: Tags.Add.Item[]; + } + + export namespace Tags { + export type Add = Add.Item[]; + + export namespace Add { + export interface Item { + /** The ID of an existing tag to add to the contact. */ + id: string; + } + } + } + } + } + + /** + * Optional. Include to append tasks to an existing job. + */ + export interface Job { + /** The ID of an existing bulk job to append to. */ + id?: string; + } +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/BulkDeleteContactsRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/BulkDeleteContactsRequest.ts new file mode 100644 index 00000000..080bcdbf --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/BulkDeleteContactsRequest.ts @@ -0,0 +1,47 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * contacts: [{ + * id: "abc123" + * }, { + * id: "def456" + * }] + * } + * + * @example + * { + * contacts: [{ + * id: "abc123" + * }], + * job: { + * id: "job_v2_1" + * } + * } + */ +export interface BulkDeleteContactsRequest { + /** An array of contacts to delete, each identified by `id`. Maximum 100 contacts per request. */ + contacts: BulkDeleteContactsRequest.Contacts.Item[]; + /** Optional. Include to append tasks to an existing job. */ + job?: BulkDeleteContactsRequest.Job; +} + +export namespace BulkDeleteContactsRequest { + export type Contacts = Contacts.Item[]; + + export namespace Contacts { + export interface Item { + /** The unique identifier for the contact. */ + id: string; + } + } + + /** + * Optional. Include to append tasks to an existing job. + */ + export interface Job { + /** The ID of an existing bulk job to append to. */ + id?: string; + } +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/BulkUpdateContactsRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/BulkUpdateContactsRequest.ts new file mode 100644 index 00000000..a39e99c2 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/BulkUpdateContactsRequest.ts @@ -0,0 +1,166 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * contacts: [{ + * id: "abc123", + * external_id: "ext123", + * email: "joe@bloggs.com", + * name: "Joe Bloggs", + * phone: "+353871234567", + * avatar: "https://www.example.com/avatar_image.jpg", + * owner_id: "321", + * unsubscribed_from_emails: false, + * language_override: "fr", + * custom_attributes: { + * "plan": "pro" + * }, + * companies: [{ + * company_id: "6", + * name: "Blue Sun" + * }], + * tags: { + * add: [{ + * id: "123" + * }], + * remove: [{ + * id: "987" + * }] + * } + * }] + * } + * + * @example + * { + * contacts: [{ + * id: "abc123", + * companies: [{ + * company_id: "6", + * name: "Blue Sun" + * }, { + * company_id: "7", + * remove: true + * }] + * }] + * } + * + * @example + * { + * contacts: [{ + * id: "abc123", + * name: "Updated Name", + * tags: { + * add: [{ + * id: "123" + * }], + * remove: [{ + * id: "456" + * }] + * } + * }] + * } + * + * @example + * { + * contacts: [{ + * id: "abc123", + * language_override: "de" + * }], + * job: { + * id: "job_v2_1" + * } + * } + */ +export interface BulkUpdateContactsRequest { + /** An array of contact objects to update. Each must include an `id` and the fields to update. Maximum 100 contacts per request. */ + contacts: BulkUpdateContactsRequest.Contacts.Item[]; + /** Optional. Include to append tasks to an existing job. */ + job?: BulkUpdateContactsRequest.Job; +} + +export namespace BulkUpdateContactsRequest { + export type Contacts = Contacts.Item[]; + + export namespace Contacts { + export interface Item { + /** The unique identifier for the contact. */ + id: string; + /** A unique identifier for the contact which you have defined. */ + external_id?: string; + /** The contact's email address. */ + email?: string; + /** The contact's name. */ + name?: string; + /** The contact's phone number. */ + phone?: string; + /** An image URL containing the avatar of the contact. */ + avatar?: string; + /** The ID of an admin that has been assigned account ownership of the contact. */ + owner_id?: string; + /** Whether the contact is unsubscribed from emails. */ + unsubscribed_from_emails?: boolean; + /** A preferred language setting for the contact, used by the Intercom Messenger. */ + language_override?: string; + /** Custom attributes to update on the contact. */ + custom_attributes?: Record; + /** A list of companies to associate with the contact. Each company is identified by the `company_id` you have defined. A company that does not exist is created, and one that already exists has the supplied attributes applied to it. */ + companies?: Item.Companies.Item[]; + /** Tags to add to or remove from the contact. Each tag is identified by its `id`, which must be a positive integer for a tag that already exists in your workspace. Tag application is best-effort: unknown tag IDs are skipped while the rest of the contact update still applies. Per-tag results are not yet returned in the job status. */ + tags?: Item.Tags; + } + + export namespace Item { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The company ID you have defined for the company. */ + company_id: string; + /** The name of the company. */ + name?: string; + /** Set to true to detach this company from the contact instead of attaching it. */ + remove?: boolean; + } + } + + /** + * Tags to add to or remove from the contact. Each tag is identified by its `id`, which must be a positive integer for a tag that already exists in your workspace. Tag application is best-effort: unknown tag IDs are skipped while the rest of the contact update still applies. Per-tag results are not yet returned in the job status. + */ + export interface Tags { + /** Tags to add to the contact. */ + add?: Tags.Add.Item[]; + /** Tags to remove from the contact. */ + remove?: Tags.Remove.Item[]; + } + + export namespace Tags { + export type Add = Add.Item[]; + + export namespace Add { + export interface Item { + /** The ID of an existing tag to add to the contact. */ + id: string; + } + } + + export type Remove = Remove.Item[]; + + export namespace Remove { + export interface Item { + /** The ID of an existing tag to remove from the contact. */ + id: string; + } + } + } + } + } + + /** + * Optional. Include to append tasks to an existing job. + */ + export interface Job { + /** The ID of an existing bulk job to append to. */ + id?: string; + } +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ContactSearchRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ContactSearchRequest.ts new file mode 100644 index 00000000..f7ed6cab --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ContactSearchRequest.ts @@ -0,0 +1,56 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * include_merge_history: true, + * query: { + * operator: "AND", + * value: [{ + * field: "created_at", + * operator: ">", + * value: "1306054154" + * }] + * }, + * pagination: { + * per_page: 5 + * }, + * sort: { + * field: "created_at", + * order: "ascending" + * } + * } + */ +export interface ContactSearchRequest { + /** Pass `true` to include a `merge_history` array on each contact in the response. Only returned for contacts with a `user` role. */ + include_merge_history?: boolean; + query: ContactSearchRequest.Query; + pagination?: Intercom.preview.StartingAfterPaging; + /** An optional object to sort the results by. */ + sort?: ContactSearchRequest.Sort; +} + +export namespace ContactSearchRequest { + export type Query = Intercom.preview.SingleFilterSearchRequest | Intercom.preview.MultipleFilterSearchRequest; + + /** + * An optional object to sort the results by. + */ + export interface Sort { + /** The field to sort the results on. */ + field?: string; + /** The order to sort the results in. Defaults to `descending` when omitted. Values other than `ascending` or `descending` return a `400` error with code `invalid_sort_order`. */ + order?: Sort.Order; + } + + export namespace Sort { + /** The order to sort the results in. Defaults to `descending` when omitted. Values other than `ascending` or `descending` return a `400` error with code `invalid_sort_order`. */ + export const Order = { + Ascending: "ascending", + Descending: "descending", + } as const; + export type Order = (typeof Order)[keyof typeof Order]; + } +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/DeleteContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/DeleteContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/requests/DeleteContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/DeleteContactRequest.ts diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts diff --git a/src/api/resources/preview/resources/contacts/client/requests/ListContactActivitiesRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListContactActivitiesRequest.ts new file mode 100644 index 00000000..44e52a14 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ListContactActivitiesRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * per_page: 1, + * starting_after: "starting_after" + * } + */ +export interface ListContactActivitiesRequest { + /** The number of results to return per page. Defaults to 50, minimum 1, maximum 150. */ + per_page?: number; + /** The cursor value from `pages.next.starting_after` in a previous response. Used to paginate through results. */ + starting_after?: string; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ListContactMergeHistoryRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListContactMergeHistoryRequest.ts new file mode 100644 index 00000000..4014762c --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ListContactMergeHistoryRequest.ts @@ -0,0 +1,23 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * id: "63a07ddf05a32042dffac965", + * cursor: "cursor", + * per_page: 1, + * order: "asc" + * } + */ +export interface ListContactMergeHistoryRequest { + /** The id of the contact to fetch merge history for. */ + id: string; + /** A cursor for pagination. Pass the `next_cursor` value from a previous response to fetch the next page. */ + cursor?: string; + /** The number of results to return per page (default 50, max 150). */ + per_page?: number; + /** The order to return results in. Defaults to descending. */ + order?: Intercom.preview.ListContactMergeHistoryRequestOrder; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ListContactsRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListContactsRequest.ts new file mode 100644 index 00000000..a98b73d2 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ListContactsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * include_merge_history: true + * } + */ +export interface ListContactsRequest { + /** Pass `true` to include a `merge_history` array on each contact in the response. Only returned for contacts with a `user` role. */ + include_merge_history?: boolean; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ListDeletedContactsRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListDeletedContactsRequest.ts new file mode 100644 index 00000000..ea26b3e3 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ListDeletedContactsRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * per_page: 1, + * page: 1 + * } + */ +export interface ListDeletedContactsRequest { + /** The number of results per page. Defaults to `10`, with a maximum of `150`. */ + per_page?: number; + /** The page of results to fetch. Defaults to `1`. */ + page?: number; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ListGrantedCompaniesForAContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListGrantedCompaniesForAContactRequest.ts new file mode 100644 index 00000000..145be71a --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ListGrantedCompaniesForAContactRequest.ts @@ -0,0 +1,31 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * page: 1, + * per_page: 1, + * order: "asc" + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * page: 1, + * per_page: 1, + * order: "asc" + * } + */ +export interface ListGrantedCompaniesForAContactRequest { + /** The unique identifier for the contact which is given by Intercom */ + contact_id: string; + /** The page number to retrieve, starting at 1. */ + page?: number; + /** The number of company ids to return per page. Values above 150 are reduced to 150. */ + per_page?: number; + /** The direction to sort the company ids in. Any other value is treated as `desc`. */ + order?: Intercom.preview.ListGrantedCompaniesForAContactRequestOrder; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ListTagsForAContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ListTagsForAContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/requests/ListTagsForAContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/ListTagsForAContactRequest.ts diff --git a/src/api/resources/preview/resources/contacts/client/requests/MergeContactsRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/MergeContactsRequest.ts new file mode 100644 index 00000000..4a328506 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/MergeContactsRequest.ts @@ -0,0 +1,28 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * include_merge_history: true, + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80" + * } + * + * @example + * { + * include_merge_history: true, + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80", + * skip_duplicate_validation: true + * } + */ +export interface MergeContactsRequest { + /** Pass `true` to include the merge history of the resulting contact in the response. Only returned for contacts with a `user` role. */ + include_merge_history?: boolean; + /** The unique identifier for the contact to merge away from (the source contact). Can have a `role` of `lead` or `user`. */ + from: string; + /** The unique identifier for the contact to merge into (the destination contact). Must have a `role` of `user`. */ + into: string; + /** When `true`, bypasses the check that the two contacts must be duplicates (matching email or phone), allowing non-duplicate contacts to be merged. Must be a JSON boolean; the string `"true"` does not bypass the check. */ + skip_duplicate_validation?: boolean; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/MergePreviewRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/MergePreviewRequest.ts new file mode 100644 index 00000000..ad9bef69 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/MergePreviewRequest.ts @@ -0,0 +1,25 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80" + * } + * + * @example + * { + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80" + * } + */ +export interface MergePreviewRequest { + /** The unique identifier for the contact to merge away from (the source contact). Can have a `role` of `lead` or `user`. */ + from: string; + /** The unique identifier for the contact to merge into (the destination contact). Must have a `role` of `user`. */ + into: string; + /** When `true`, previews the merge even if the contacts don't share a common identifier. Must be a JSON boolean; the string `"true"` does not bypass the check. Defaults to false. */ + skip_duplicate_validation?: boolean; + /** Custom attribute names to include in the previewed attribute changes. */ + custom_attribute_names?: string[]; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/RemoveGrantedCompanyFromAContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/RemoveGrantedCompanyFromAContactRequest.ts new file mode 100644 index 00000000..d057551d --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/RemoveGrantedCompanyFromAContactRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * company_id: "acme-corp" + * } + */ +export interface RemoveGrantedCompanyFromAContactRequest { + /** The unique identifier for the contact which is given by Intercom */ + contact_id: string; + /** The `company_id` you set on the company, as returned in `company_ids`. */ + company_id: string; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ReplaceGrantedCompaniesRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ReplaceGrantedCompaniesRequest.ts new file mode 100644 index 00000000..47fd2a2b --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ReplaceGrantedCompaniesRequest.ts @@ -0,0 +1,39 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * company_ids: ["acme-corp", "1234", "globex"] + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * company_ids: ["globex"] + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * company_ids: ["acme-corp", "1234"] + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * company_ids: ["acme-corp", "1234", "globex"] + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * company_ids: ["acme-corp", "1234", "globex"] + * } + */ +export interface ReplaceGrantedCompaniesRequest { + /** The unique identifier for the contact which is given by Intercom */ + contact_id: string; + /** The `company_id` values of the companies to grant the contact access to. Send an empty array to drop every grant. Maximum of 100 ids. */ + company_ids: string[]; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ShowBulkUpdateContactsJobRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ShowBulkUpdateContactsJobRequest.ts new file mode 100644 index 00000000..e3437fbc --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ShowBulkUpdateContactsJobRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "job_v2_1" + * } + */ +export interface ShowBulkUpdateContactsJobRequest { + /** The unique identifier for the bulk job. */ + id: string; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts new file mode 100644 index 00000000..f3b9d165 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27", + * include_merge_history: true + * } + */ +export interface ShowContactByExternalIdRequest { + /** The external ID of the user that you want to retrieve */ + external_id: string; + /** Pass `true` to include the contact's merge history in the response. Only returned for contacts with a `user` role. */ + include_merge_history?: boolean; +} diff --git a/src/api/resources/preview/resources/contacts/client/requests/ShowContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/ShowContactRequest.ts new file mode 100644 index 00000000..6f179d63 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/ShowContactRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "63a07ddf05a32042dffac965", + * include_merge_history: true + * } + */ +export interface ShowContactRequest { + /** id */ + id: string; + /** Pass `true` to include the contact's merge history in the response. Only returned for contacts with a `user` role. */ + include_merge_history?: boolean; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/UnarchiveContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/UnarchiveContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/contacts/client/requests/UnarchiveContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/UnarchiveContactRequest.ts diff --git a/src/api/resources/unstable/resources/contacts/client/requests/UpdateContactRequest.ts b/src/api/resources/preview/resources/contacts/client/requests/UpdateContactRequest.ts similarity index 55% rename from src/api/resources/unstable/resources/contacts/client/requests/UpdateContactRequest.ts rename to src/api/resources/preview/resources/contacts/client/requests/UpdateContactRequest.ts index 3d671681..1ca58d2a 100644 --- a/src/api/resources/unstable/resources/contacts/client/requests/UpdateContactRequest.ts +++ b/src/api/resources/preview/resources/contacts/client/requests/UpdateContactRequest.ts @@ -4,6 +4,7 @@ * @example * { * id: "63a07ddf05a32042dffac965", + * include_merge_history: true, * email: "joebloggs@intercom.io", * name: "joe bloggs" * } @@ -11,6 +12,7 @@ * @example * { * id: "63a07ddf05a32042dffac965", + * include_merge_history: true, * custom_attributes: { * "order": [ * "21" @@ -21,24 +23,28 @@ export interface UpdateContactRequest { /** id */ id: string; + /** Pass `true` to include the contact's merge history in the response. Only returned for contacts with a `user` role. */ + include_merge_history?: boolean; /** The role of the contact. */ role?: string; /** A unique identifier for the contact which is given to Intercom */ external_id?: string; /** The contacts email */ email?: string; + /** Whether the contact's email address has been verified. Set to true to indicate you have verified the contact owns this email address, or false to mark it as unverified. Must be supplied together with an email in the same request; sending it without an email returns a 400. Verifying a lead's email also makes that lead reusable whenever Intercom matches an email address to a contact. When inbound email arrives from an address no user has, or an outbound conversation or ticket is created for one, Intercom reuses a lead with that address whose email is verified, instead of creating a new lead. Leads with an unverified email are not matched this way. */ + email_verified?: boolean; /** The contacts phone */ phone?: string; /** The contacts name */ name?: string; /** An image URL containing the avatar of a contact */ avatar?: string; - /** The time specified for when a contact signed up */ + /** (Unix timestamp in seconds) The time specified for when a contact signed up. */ signed_up_at?: number; - /** The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) */ + /** (Unix timestamp in seconds) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). */ last_seen_at?: number; /** The id of an admin that has been assigned account ownership of the contact */ - owner_id?: number; + owner_id?: string; /** Whether the contact is unsubscribed from emails */ unsubscribed_from_emails?: boolean; /** A preferred language setting for the contact, used by Intercom as the language of Fin and the Messenger even if their browser has a different setting. Supports ISO 639-1 two-letter language codes. If an unsupported code is supplied, the field will be set to null. */ diff --git a/src/api/resources/preview/resources/contacts/client/requests/index.ts b/src/api/resources/preview/resources/contacts/client/requests/index.ts new file mode 100644 index 00000000..266132e1 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/client/requests/index.ts @@ -0,0 +1,25 @@ +export type { ArchiveContactRequest } from "./ArchiveContactRequest.js"; +export type { BlockContactRequest } from "./BlockContactRequest.js"; +export type { BulkCreateContactsRequest } from "./BulkCreateContactsRequest.js"; +export type { BulkDeleteContactsRequest } from "./BulkDeleteContactsRequest.js"; +export type { BulkUpdateContactsRequest } from "./BulkUpdateContactsRequest.js"; +export type { ContactSearchRequest } from "./ContactSearchRequest.js"; +export type { DeleteContactRequest } from "./DeleteContactRequest.js"; +export type { ListCompaniesForAContactRequest } from "./ListCompaniesForAContactRequest.js"; +export type { ListContactActivitiesRequest } from "./ListContactActivitiesRequest.js"; +export type { ListContactMergeHistoryRequest } from "./ListContactMergeHistoryRequest.js"; +export type { ListContactsRequest } from "./ListContactsRequest.js"; +export type { ListDeletedContactsRequest } from "./ListDeletedContactsRequest.js"; +export type { ListGrantedCompaniesForAContactRequest } from "./ListGrantedCompaniesForAContactRequest.js"; +export type { ListSegmentsForAContactRequest } from "./ListSegmentsForAContactRequest.js"; +export type { ListSubscriptionsForAContactRequest } from "./ListSubscriptionsForAContactRequest.js"; +export type { ListTagsForAContactRequest } from "./ListTagsForAContactRequest.js"; +export type { MergeContactsRequest } from "./MergeContactsRequest.js"; +export type { MergePreviewRequest } from "./MergePreviewRequest.js"; +export type { RemoveGrantedCompanyFromAContactRequest } from "./RemoveGrantedCompanyFromAContactRequest.js"; +export type { ReplaceGrantedCompaniesRequest } from "./ReplaceGrantedCompaniesRequest.js"; +export type { ShowBulkUpdateContactsJobRequest } from "./ShowBulkUpdateContactsJobRequest.js"; +export type { ShowContactByExternalIdRequest } from "./ShowContactByExternalIdRequest.js"; +export type { ShowContactRequest } from "./ShowContactRequest.js"; +export type { UnarchiveContactRequest } from "./UnarchiveContactRequest.js"; +export type { UpdateContactRequest } from "./UpdateContactRequest.js"; diff --git a/src/api/resources/unstable/resources/dataAttributes/index.ts b/src/api/resources/preview/resources/contacts/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataAttributes/index.ts rename to src/api/resources/preview/resources/contacts/index.ts diff --git a/src/api/resources/preview/resources/contacts/types/index.ts b/src/api/resources/preview/resources/contacts/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/contacts/types/types.ts b/src/api/resources/preview/resources/contacts/types/types.ts new file mode 100644 index 00000000..32387670 --- /dev/null +++ b/src/api/resources/preview/resources/contacts/types/types.ts @@ -0,0 +1,207 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +export const ListGrantedCompaniesForAContactRequestOrder = { + Asc: "asc", + Desc: "desc", +} as const; +export type ListGrantedCompaniesForAContactRequestOrder = + (typeof ListGrantedCompaniesForAContactRequestOrder)[keyof typeof ListGrantedCompaniesForAContactRequestOrder]; + +export interface ShowContactResponse extends Intercom.preview.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export interface UpdateContactResponse extends Intercom.preview.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export interface MergeContactResponse extends Intercom.preview.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export interface CreateContactResponse extends Intercom.preview.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export interface ShowContactByExternalIdResponse extends Intercom.preview.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} + +export const ListContactMergeHistoryRequestOrder = { + Asc: "asc", + Desc: "desc", +} as const; +export type ListContactMergeHistoryRequestOrder = + (typeof ListContactMergeHistoryRequestOrder)[keyof typeof ListContactMergeHistoryRequestOrder]; + +/** + * Contacts represent your leads and users in Intercom. + */ +export interface Contact { + /** The type of object. */ + type?: string; + /** The unique identifier for the contact which is given by Intercom. */ + id?: string; + /** The unique identifier for the contact which is provided by the Client. */ + external_id?: string; + /** The id of the workspace which the contact belongs to. */ + workspace_id?: string; + /** The role of the contact. */ + role?: string; + /** The contact's email. */ + email?: string; + /** The contact's email domain. */ + email_domain?: string; + /** The contacts phone. */ + phone?: string; + /** The contacts phone number normalized to the E164 format */ + formatted_phone?: string; + /** The contacts name. */ + name?: string; + /** The id of an admin that has been assigned account ownership of the contact. */ + owner_id?: string; + /** Whether the contact has had an email sent to them hard bounce. */ + has_hard_bounced?: boolean; + /** Whether the contact has marked an email sent to them as spam. */ + marked_email_as_spam?: boolean; + /** Whether the contact is unsubscribed from emails. */ + unsubscribed_from_emails?: boolean; + /** (Unix timestamp in seconds) The time when the contact was created. */ + created_at?: number; + /** (Unix timestamp in seconds) The time when the contact was last updated. */ + updated_at?: number; + /** (Unix timestamp in seconds) The time specified for when a contact signed up. */ + signed_up_at?: number; + /** (Unix timestamp in seconds) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). */ + last_seen_at?: number; + /** (Unix timestamp in seconds) The time when the contact last messaged in. */ + last_replied_at?: number; + /** (Unix timestamp in seconds) The time when the contact was last messaged. */ + last_contacted_at?: number; + /** (Unix timestamp in seconds) The time when the contact last opened an email. */ + last_email_opened_at?: number; + /** (Unix timestamp in seconds) The time when the contact last clicked a link in an email. */ + last_email_clicked_at?: number; + /** A preferred language setting for the contact, used by Intercom as the language of Fin and the Messenger even if their browser has a different setting. Supports ISO 639-1 two-letter language codes. If an unsupported code is supplied, the field will be set to null. */ + language_override?: string; + /** The name of the browser which the contact is using. */ + browser?: string; + /** The version of the browser which the contact is using. */ + browser_version?: string; + /** The language set by the browser which the contact is using. */ + browser_language?: string; + /** The operating system which the contact is using. */ + os?: string; + /** The name of the Android app which the contact is using. */ + android_app_name?: string; + /** The version of the Android app which the contact is using. */ + android_app_version?: string; + /** The Android device which the contact is using. */ + android_device?: string; + /** The version of the Android OS which the contact is using. */ + android_os_version?: string; + /** The version of the Android SDK which the contact is using. */ + android_sdk_version?: string; + /** (Unix timestamp in seconds) The time when the contact was last seen on an Android device. */ + android_last_seen_at?: number; + /** The name of the iOS app which the contact is using. */ + ios_app_name?: string; + /** The version of the iOS app which the contact is using. */ + ios_app_version?: string; + /** The iOS device which the contact is using. */ + ios_device?: string; + /** The version of iOS which the contact is using. */ + ios_os_version?: string; + /** The version of the iOS SDK which the contact is using. */ + ios_sdk_version?: string; + /** (Unix timestamp in seconds) The last time the contact used the iOS app. */ + ios_last_seen_at?: number; + /** The custom attributes which are set for the contact. */ + custom_attributes?: Record; + avatar?: Contact.Avatar; + tags?: Intercom.preview.ContactTags; + notes?: Intercom.preview.ContactNotes; + companies?: Intercom.preview.ContactCompanies; + location?: Intercom.preview.ContactLocation; + social_profiles?: Intercom.preview.ContactSocialProfiles; + /** A list of contacts that were merged into this contact. Only included in the response when `include_merge_history=true` is passed as a query parameter. Only available for contacts with a `user` role. */ + merge_history?: Intercom.preview.MergeHistoryItem[]; +} + +export namespace Contact { + export interface Avatar { + /** The type of object */ + type?: string; + /** An image URL containing the avatar of a contact. */ + image_url?: string; + } +} + +/** + * A bulk job for updating contacts asynchronously. Track the job status using the `state` field. + */ +export interface ContactsBulkJob { + /** The unique identifier for the bulk job. */ + id?: string; + /** The type of the object. */ + type?: "contacts.bulk.job"; + /** The current state of the job. */ + state?: ContactsBulkJob.State; + /** The time the job was created as a UNIX timestamp. */ + created_at?: number; + /** The time the job was last updated as a UNIX timestamp. */ + updated_at?: number; + /** The time the job completed as a UNIX timestamp. Null if not yet completed. */ + completed_at?: number; + /** The tasks that make up this bulk job. */ + tasks?: ContactsBulkJob.Tasks.Item[]; + /** The URL to check the job status. */ + url?: string; +} + +export namespace ContactsBulkJob { + /** The current state of the job. */ + export const State = { + Pending: "pending", + Running: "running", + Completed: "completed", + CompletedWithErrors: "completed_with_errors", + } as const; + export type State = (typeof State)[keyof typeof State]; + export type Tasks = Tasks.Item[]; + + export namespace Tasks { + export interface Item { + /** The unique identifier for the task. */ + id?: string; + /** The number of items in this task. */ + item_count?: number; + /** The current state of the task. */ + state?: Item.State; + /** The time the task was created as a UNIX timestamp. */ + created_at?: number; + /** The time the task started as a UNIX timestamp. Null if not yet started. */ + started_at?: number; + /** The time the task completed as a UNIX timestamp. Null if not yet completed. */ + completed_at?: number; + } + + export namespace Item { + /** The current state of the task. */ + export const State = { + Pending: "pending", + Running: "running", + Completed: "completed", + CompletedWithErrors: "completed_with_errors", + } as const; + export type State = (typeof State)[keyof typeof State]; + } + } +} diff --git a/src/api/resources/preview/resources/content/client/Client.ts b/src/api/resources/preview/resources/content/client/Client.ts new file mode 100644 index 00000000..91898854 --- /dev/null +++ b/src/api/resources/preview/resources/content/client/Client.ts @@ -0,0 +1,432 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace ContentClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Search and operations over Knowledge Hub content (Preview) — articles, snippets, external pages, uploaded files, and internal articles. + */ +export class ContentClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ContentClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Asynchronously run a bulk action over up to 1,000 Knowledge Hub content items. + * + * Six actions are supported: + * * `publish` and `unpublish` — apply to `article_content` only. + * * `delete` — permanently delete content (excludes synced sources and `external_content`). + * * `set_availability` — toggle Fin AI Agent, Copilot, and Sales Agent availability flags. + * * `set_audience` — manage segment membership on content. + * * `update_tags` — apply and/or remove existing tags on content. Unlike the other + * actions, `update_tags` addresses articles by the parent `article` id, not + * `article_content`. Tags must already exist and not be archived; supply at least one of + * `add_tag_ids` / `remove_tag_ids`. + * + * The endpoint validates the request, enqueues background work, and returns 202 with a + * placeholder envelope. Items whose `type` is not in the action's allowlist are silently + * dropped before processing. Articles imported from synced sources (Confluence, Notion, + * Zendesk, Salesforce Knowledge, etc.) are silently skipped on `delete` — they can only be + * removed by disconnecting the underlying import source. + * + * Requires the `write_content` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.ContentBulkActionRequest} request + * @param {ContentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.content.bulkContentActions({ + * action: "publish", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }, { + * type: "article_content", + * id: "12345679" + * }] + * }) + * + * @example + * await client.preview.content.bulkContentActions({ + * action: "unpublish", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }] + * }) + * + * @example + * await client.preview.content.bulkContentActions({ + * action: "delete", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }, { + * type: "internal_article", + * id: "12345679" + * }, { + * type: "content_snippet", + * id: "12345680" + * }] + * }) + * + * @example + * await client.preview.content.bulkContentActions({ + * action: "set_availability", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }], + * availability: { + * ai_agent: true, + * copilot: false + * } + * }) + * + * @example + * await client.preview.content.bulkContentActions({ + * action: "set_audience", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }], + * audience: { + * add_segment_ids: [100], + * remove_segment_ids: [200] + * } + * }) + * + * @example + * await client.preview.content.bulkContentActions({ + * action: "update_tags", + * content_ids: [{ + * type: "article", + * id: "12345678" + * }], + * tags: { + * add_tag_ids: [100], + * remove_tag_ids: [200] + * } + * }) + */ + public bulkContentActions( + request: Intercom.preview.ContentBulkActionRequest, + requestOptions?: ContentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__bulkContentActions(request, requestOptions)); + } + + private async __bulkContentActions( + request: Intercom.preview.ContentBulkActionRequest, + requestOptions?: ContentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "content/bulk_actions", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ContentBulkActionResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/content/bulk_actions"); + } + + /** + * Search the knowledge base contents — articles, snippets, external pages, uploaded files, and internal articles — using a keyword query. + * + * Each result row has a `type` discriminator. Most types (`content_snippet`, `external_content`, `file_source_content`, `internal_article`) return a flat `{ type, id, title }` shape. Help center articles return a nested shape with a `contents[]` array, one entry per locale. + * + * Requires the `read_content` OAuth scope. + * + * @param {Intercom.preview.SearchContentRequest} request + * @param {ContentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.content.searchContent({ + * query: "billing", + * page: 1, + * per_page: 1, + * tag_operator: "IN", + * folder_entity_type: "folder", + * copilot_state: "on", + * fin_service_state: "on", + * fin_sales_state: "on", + * created_at_after: 1, + * created_at_before: 1, + * updated_at_after: 1, + * updated_at_before: 1 + * }) + */ + public searchContent( + request: Intercom.preview.SearchContentRequest = {}, + requestOptions?: ContentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchContent(request, requestOptions)); + } + + private async __searchContent( + request: Intercom.preview.SearchContentRequest = {}, + requestOptions?: ContentClient.RequestOptions, + ): Promise> { + const { + query, + page, + per_page: perPage, + states, + locales, + tag_ids: tagIds, + tag_operator: tagOperator, + any_tag_ids: anyTagIds, + folder_ids: folderIds, + folder_entity_type: folderEntityType, + content_types: contentTypes, + copilot_state: copilotState, + fin_service_state: finServiceState, + fin_sales_state: finSalesState, + created_by_ids: createdByIds, + last_updated_by_ids: lastUpdatedByIds, + created_at_after: createdAtAfter, + created_at_before: createdAtBefore, + updated_at_after: updatedAtAfter, + updated_at_before: updatedAtBefore, + } = request; + const _queryParams: Record = {}; + if (query != null) { + _queryParams.query = query; + } + + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (states != null) { + if (Array.isArray(states)) { + _queryParams.states = states.map((item) => item); + } else { + _queryParams.states = states; + } + } + + if (locales != null) { + if (Array.isArray(locales)) { + _queryParams.locales = locales.map((item) => item); + } else { + _queryParams.locales = locales; + } + } + + if (tagIds != null) { + if (Array.isArray(tagIds)) { + _queryParams.tag_ids = tagIds.map((item) => item.toString()); + } else { + _queryParams.tag_ids = tagIds.toString(); + } + } + + if (tagOperator != null) { + _queryParams.tag_operator = tagOperator; + } + + if (anyTagIds != null) { + if (Array.isArray(anyTagIds)) { + _queryParams.any_tag_ids = anyTagIds.map((item) => item.toString()); + } else { + _queryParams.any_tag_ids = anyTagIds.toString(); + } + } + + if (folderIds != null) { + if (Array.isArray(folderIds)) { + _queryParams.folder_ids = folderIds.map((item) => item.toString()); + } else { + _queryParams.folder_ids = folderIds.toString(); + } + } + + if (folderEntityType != null) { + _queryParams.folder_entity_type = folderEntityType; + } + + if (contentTypes != null) { + if (Array.isArray(contentTypes)) { + _queryParams.content_types = contentTypes.map((item) => item); + } else { + _queryParams.content_types = contentTypes; + } + } + + if (copilotState != null) { + _queryParams.copilot_state = copilotState; + } + + if (finServiceState != null) { + _queryParams.fin_service_state = finServiceState; + } + + if (finSalesState != null) { + _queryParams.fin_sales_state = finSalesState; + } + + if (createdByIds != null) { + if (Array.isArray(createdByIds)) { + _queryParams.created_by_ids = createdByIds.map((item) => item.toString()); + } else { + _queryParams.created_by_ids = createdByIds.toString(); + } + } + + if (lastUpdatedByIds != null) { + if (Array.isArray(lastUpdatedByIds)) { + _queryParams.last_updated_by_ids = lastUpdatedByIds.map((item) => item.toString()); + } else { + _queryParams.last_updated_by_ids = lastUpdatedByIds.toString(); + } + } + + if (createdAtAfter != null) { + _queryParams.created_at_after = createdAtAfter.toString(); + } + + if (createdAtBefore != null) { + _queryParams.created_at_before = createdAtBefore.toString(); + } + + if (updatedAtAfter != null) { + _queryParams.updated_at_after = updatedAtAfter.toString(); + } + + if (updatedAtBefore != null) { + _queryParams.updated_at_before = updatedAtBefore.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "content/search", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ContentSearchResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/content/search"); + } +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/index.ts b/src/api/resources/preview/resources/content/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/customObjectInstances/client/index.ts rename to src/api/resources/preview/resources/content/client/index.ts diff --git a/src/api/resources/preview/resources/content/client/requests/ContentBulkActionRequest.ts b/src/api/resources/preview/resources/content/client/requests/ContentBulkActionRequest.ts new file mode 100644 index 00000000..3f335851 --- /dev/null +++ b/src/api/resources/preview/resources/content/client/requests/ContentBulkActionRequest.ts @@ -0,0 +1,183 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * action: "publish", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }, { + * type: "article_content", + * id: "12345679" + * }] + * } + * + * @example + * { + * action: "unpublish", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }] + * } + * + * @example + * { + * action: "delete", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }, { + * type: "internal_article", + * id: "12345679" + * }, { + * type: "content_snippet", + * id: "12345680" + * }] + * } + * + * @example + * { + * action: "set_availability", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }], + * availability: { + * ai_agent: true, + * copilot: false + * } + * } + * + * @example + * { + * action: "set_audience", + * content_ids: [{ + * type: "article_content", + * id: "12345678" + * }], + * audience: { + * add_segment_ids: [100], + * remove_segment_ids: [200] + * } + * } + * + * @example + * { + * action: "update_tags", + * content_ids: [{ + * type: "article", + * id: "12345678" + * }], + * tags: { + * add_tag_ids: [100], + * remove_tag_ids: [200] + * } + * } + */ +export interface ContentBulkActionRequest { + /** + * The bulk action to perform. Allowed `content_ids[].type` values vary per action: + * * `publish`, `unpublish`: `article_content` + * * `delete`: `article_content`, `content_snippet`, `file_source_content`, `internal_article` + * * `set_availability`, `set_audience`: `article_content`, `content_snippet`, `external_content`, `file_source_content`, `internal_article` + * * `update_tags`: `article` (the parent Article id, not `article_content`), `content_snippet`, `external_content`, `file_source_content`, `internal_article` + */ + action: ContentBulkActionRequest.Action; + /** Up to 1,000 content items to apply the action to. */ + content_ids: ContentBulkActionRequest.ContentIds.Item[]; + /** + * Required when `action` is `set_availability`. Each field is optional — only the + * properties present in the request are toggled. + */ + availability?: ContentBulkActionRequest.Availability; + /** Required when `action` is `set_audience`. Manages segment membership. */ + audience?: ContentBulkActionRequest.Audience; + /** + * Required when `action` is `update_tags`. Applies and/or removes existing tags. + * Supply at least one of `add_tag_ids` / `remove_tag_ids`. At most 100 distinct tag IDs + * may be supplied across `add_tag_ids` and `remove_tag_ids` combined. Tag IDs must + * reference existing, non-archived tags; exceeding the limit or referencing unknown or + * archived IDs is rejected with `parameter_invalid` (HTTP 422). + */ + tags?: ContentBulkActionRequest.Tags; +} + +export namespace ContentBulkActionRequest { + /** + * The bulk action to perform. Allowed `content_ids[].type` values vary per action: + * * `publish`, `unpublish`: `article_content` + * * `delete`: `article_content`, `content_snippet`, `file_source_content`, `internal_article` + * * `set_availability`, `set_audience`: `article_content`, `content_snippet`, `external_content`, `file_source_content`, `internal_article` + * * `update_tags`: `article` (the parent Article id, not `article_content`), `content_snippet`, `external_content`, `file_source_content`, `internal_article` + */ + export const Action = { + Publish: "publish", + Unpublish: "unpublish", + Delete: "delete", + SetAvailability: "set_availability", + SetAudience: "set_audience", + UpdateTags: "update_tags", + } as const; + export type Action = (typeof Action)[keyof typeof Action]; + export type ContentIds = ContentIds.Item[]; + + export namespace ContentIds { + export interface Item { + type: Item.Type; + id: string; + } + + export namespace Item { + export const Type = { + Article: "article", + ArticleContent: "article_content", + ContentSnippet: "content_snippet", + ExternalContent: "external_content", + FileSourceContent: "file_source_content", + InternalArticle: "internal_article", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } + + /** + * Required when `action` is `set_availability`. Each field is optional — only the + * properties present in the request are toggled. + */ + export interface Availability { + /** Toggle Fin AI Agent availability. */ + ai_agent?: boolean; + /** Toggle Copilot availability. */ + copilot?: boolean; + /** Toggle Sales Agent availability. */ + sales_agent?: boolean; + } + + /** + * Required when `action` is `set_audience`. Manages segment membership. + */ + export interface Audience { + /** Segment IDs to assign to the selected content. */ + add_segment_ids?: number[]; + /** Segment IDs to remove from the selected content. */ + remove_segment_ids?: number[]; + /** When `true`, removes all segments from the selected content. */ + remove_all?: boolean; + } + + /** + * Required when `action` is `update_tags`. Applies and/or removes existing tags. + * Supply at least one of `add_tag_ids` / `remove_tag_ids`. At most 100 distinct tag IDs + * may be supplied across `add_tag_ids` and `remove_tag_ids` combined. Tag IDs must + * reference existing, non-archived tags; exceeding the limit or referencing unknown or + * archived IDs is rejected with `parameter_invalid` (HTTP 422). + */ + export interface Tags { + /** Tag IDs to apply to the selected content. */ + add_tag_ids?: number[]; + /** Tag IDs to remove from the selected content. */ + remove_tag_ids?: number[]; + } +} diff --git a/src/api/resources/preview/resources/content/client/requests/SearchContentRequest.ts b/src/api/resources/preview/resources/content/client/requests/SearchContentRequest.ts new file mode 100644 index 00000000..0cd62baf --- /dev/null +++ b/src/api/resources/preview/resources/content/client/requests/SearchContentRequest.ts @@ -0,0 +1,65 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * query: "billing", + * page: 1, + * per_page: 1, + * tag_operator: "IN", + * folder_entity_type: "folder", + * copilot_state: "on", + * fin_service_state: "on", + * fin_sales_state: "on", + * created_at_after: 1, + * created_at_before: 1, + * updated_at_after: 1, + * updated_at_before: 1 + * } + */ +export interface SearchContentRequest { + /** A free-text search term matched against the title and body of each content item. When omitted, returns the most recent content items. */ + query?: string; + /** The page number to fetch. Defaults to 1. Values below 1 are clamped to 1. */ + page?: number; + /** Number of results per page. Defaults to 10. Maximum 50. */ + per_page?: number; + /** Filter by publication state. Accepts a comma-separated list or repeated params. */ + states?: Intercom.preview.SearchContentRequestStatesItem | Intercom.preview.SearchContentRequestStatesItem[]; + /** Filter by locale codes (e.g. `en`, `fr`, `de`). Accepts a comma-separated list or repeated params. */ + locales?: string | string[]; + /** Filter by tag IDs. Pairs with `tag_operator` to control match semantics. Accepts a comma-separated list or repeated params. */ + tag_ids?: number | number[]; + /** Match operator paired with `tag_ids`. `IN` returns content matching any of the given tags; `NIN` excludes content matching any of them. */ + tag_operator?: Intercom.preview.SearchContentRequestTagOperator; + /** Filter by tag IDs using OR semantics — returns content matching any of the given tags. Alternative to `tag_ids` + `tag_operator`. Accepts a comma-separated list or repeated params. */ + any_tag_ids?: number | number[]; + /** Filter by folder IDs. Must be sent together with `folder_entity_type`. Accepts a comma-separated list or repeated params. */ + folder_ids?: number | number[]; + /** Required when `folder_ids` is provided. Identifies the entity type the folder IDs refer to. */ + folder_entity_type?: "folder"; + /** Restrict the search to specific content types. When provided, this REPLACES the default content type set rather than filtering on top of it. Accepts a comma-separated list or repeated params. */ + content_types?: + | Intercom.preview.SearchContentRequestContentTypesItem + | Intercom.preview.SearchContentRequestContentTypesItem[]; + /** Filter by whether the content is enabled for Copilot. */ + copilot_state?: Intercom.preview.SearchContentRequestCopilotState; + /** Filter by whether the content is enabled for Fin AI Agent (customer-facing service). */ + fin_service_state?: Intercom.preview.SearchContentRequestFinServiceState; + /** Filter by whether the content is enabled for Fin Sales Agent. */ + fin_sales_state?: Intercom.preview.SearchContentRequestFinSalesState; + /** Filter by the admin IDs that created the content. Accepts a comma-separated list or repeated params. */ + created_by_ids?: number | number[]; + /** Filter by the admin IDs that last updated the content. Accepts a comma-separated list or repeated params. */ + last_updated_by_ids?: number | number[]; + /** Return content created at or after this time. Unix epoch seconds. */ + created_at_after?: number; + /** Return content created at or before this time. Unix epoch seconds. */ + created_at_before?: number; + /** Return content last updated at or after this time. Unix epoch seconds. */ + updated_at_after?: number; + /** Return content last updated at or before this time. Unix epoch seconds. */ + updated_at_before?: number; +} diff --git a/src/api/resources/preview/resources/content/client/requests/index.ts b/src/api/resources/preview/resources/content/client/requests/index.ts new file mode 100644 index 00000000..fb39bff3 --- /dev/null +++ b/src/api/resources/preview/resources/content/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { ContentBulkActionRequest } from "./ContentBulkActionRequest.js"; +export type { SearchContentRequest } from "./SearchContentRequest.js"; diff --git a/src/api/resources/unstable/resources/dataEvents/index.ts b/src/api/resources/preview/resources/content/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataEvents/index.ts rename to src/api/resources/preview/resources/content/index.ts diff --git a/src/api/resources/preview/resources/content/types/index.ts b/src/api/resources/preview/resources/content/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/content/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/content/types/types.ts b/src/api/resources/preview/resources/content/types/types.ts new file mode 100644 index 00000000..14f5b22a --- /dev/null +++ b/src/api/resources/preview/resources/content/types/types.ts @@ -0,0 +1,46 @@ +// This file was auto-generated by Fern from our API Definition. + +export const SearchContentRequestStatesItem = { + Published: "published", + Draft: "draft", +} as const; +export type SearchContentRequestStatesItem = + (typeof SearchContentRequestStatesItem)[keyof typeof SearchContentRequestStatesItem]; + +export const SearchContentRequestTagOperator = { + In: "IN", + Nin: "NIN", +} as const; +export type SearchContentRequestTagOperator = + (typeof SearchContentRequestTagOperator)[keyof typeof SearchContentRequestTagOperator]; + +export const SearchContentRequestContentTypesItem = { + Snippet: "snippet", + ExternalContent: "external_content", + FileSourceContent: "file_source_content", + InternalArticle: "internal_article", + Article: "article", +} as const; +export type SearchContentRequestContentTypesItem = + (typeof SearchContentRequestContentTypesItem)[keyof typeof SearchContentRequestContentTypesItem]; + +export const SearchContentRequestCopilotState = { + On: "on", + Off: "off", +} as const; +export type SearchContentRequestCopilotState = + (typeof SearchContentRequestCopilotState)[keyof typeof SearchContentRequestCopilotState]; + +export const SearchContentRequestFinServiceState = { + On: "on", + Off: "off", +} as const; +export type SearchContentRequestFinServiceState = + (typeof SearchContentRequestFinServiceState)[keyof typeof SearchContentRequestFinServiceState]; + +export const SearchContentRequestFinSalesState = { + On: "on", + Off: "off", +} as const; +export type SearchContentRequestFinSalesState = + (typeof SearchContentRequestFinSalesState)[keyof typeof SearchContentRequestFinSalesState]; diff --git a/src/api/resources/unstable/resources/helpCenter/client/Client.ts b/src/api/resources/preview/resources/contentSnippets/client/Client.ts similarity index 52% rename from src/api/resources/unstable/resources/helpCenter/client/Client.ts rename to src/api/resources/preview/resources/contentSnippets/client/Client.ts index 73d06f5d..4ed23327 100644 --- a/src/api/resources/unstable/resources/helpCenter/client/Client.ts +++ b/src/api/resources/preview/resources/contentSnippets/client/Client.ts @@ -9,43 +9,55 @@ import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStat import * as errors from "../../../../../../errors/index.js"; import * as Intercom from "../../../../../index.js"; -export declare namespace HelpCenterClient { +export declare namespace ContentSnippetsClient { export interface Options extends BaseClientOptions {} export interface RequestOptions extends BaseRequestOptions {} } /** - * Everything about your Help Center + * Everything about your Content Snippets */ -export class HelpCenterClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class ContentSnippetsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; - constructor(options: HelpCenterClient.Options = {}) { + constructor(options: ContentSnippetsClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } /** - * You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. + * You can fetch a list of all content snippets for a workspace. * - * Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first. - * - * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @param {Intercom.preview.ListContentSnippetsRequest} request + * @param {ContentSnippetsClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.unstable.helpCenter.listAllCollections() + * await client.preview.contentSnippets.listContentSnippets({ + * page: 1, + * per_page: 20 + * }) */ - public listAllCollections( - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAllCollections(requestOptions)); + public listContentSnippets( + request: Intercom.preview.ListContentSnippetsRequest = {}, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listContentSnippets(request, requestOptions)); } - private async __listAllCollections( - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { + private async __listContentSnippets( + request: Intercom.preview.ListContentSnippetsRequest = {}, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): Promise> { + const { page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -58,11 +70,11 @@ export class HelpCenterClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "help_center/collections", + "content_snippets", ), method: "GET", headers: _headers, - queryParameters: requestOptions?.queryParams, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -70,59 +82,51 @@ export class HelpCenterClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.CollectionList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ContentSnippetList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/collections"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/content_snippets"); } /** - * You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` + * You can create a new content snippet. * - * @param {Intercom.unstable.CreateCollectionRequest} request - * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.ContentSnippetCreateRequest} request + * @param {ContentSnippetsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.helpCenter.createCollection({ - * name: "Thanks for everything" - * }) - * - * @example - * await client.unstable.helpCenter.createCollection({ - * name: "collection 51", - * description: "Missing required parameter" + * await client.preview.contentSnippets.createContentSnippet({ + * title: "How to reset your password", + * json_blocks: [{ + * "type": "paragraph", + * "text": "Navigate to Settings > Security > Reset password." + * }], + * locale: "en", + * audience_ids: [1, 2] * }) */ - public createCollection( - request: Intercom.unstable.CreateCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createCollection(request, requestOptions)); + public createContentSnippet( + request: Intercom.preview.ContentSnippetCreateRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createContentSnippet(request, requestOptions)); } - private async __createCollection( - request: Intercom.unstable.CreateCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { + private async __createContentSnippet( + request: Intercom.preview.ContentSnippetCreateRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -135,7 +139,7 @@ export class HelpCenterClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "help_center/collections", + "content_snippets", ), method: "POST", headers: _headers, @@ -150,16 +154,16 @@ export class HelpCenterClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Collection, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ContentSnippet, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { - case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); default: @@ -171,34 +175,33 @@ export class HelpCenterClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/help_center/collections"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/content_snippets"); } /** - * You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. + * You can fetch a single content snippet by its id. * - * @param {Intercom.unstable.RetrieveCollectionRequest} request - * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.GetContentSnippetRequest} request + * @param {ContentSnippetsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.helpCenter.retrieveCollection({ - * id: 1 + * await client.preview.contentSnippets.getContentSnippet({ + * id: "123" * }) */ - public retrieveCollection( - request: Intercom.unstable.RetrieveCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveCollection(request, requestOptions)); + public getContentSnippet( + request: Intercom.preview.GetContentSnippetRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getContentSnippet(request, requestOptions)); } - private async __retrieveCollection( - request: Intercom.unstable.RetrieveCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { + private async __getContentSnippet( + request: Intercom.preview.GetContentSnippetRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -212,7 +215,7 @@ export class HelpCenterClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(id)}`, + `content_snippets/${core.url.encodePathParam(id)}`, ), method: "GET", headers: _headers, @@ -224,18 +227,13 @@ export class HelpCenterClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Collection, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ContentSnippet, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -245,35 +243,40 @@ export class HelpCenterClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/collections/{id}"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/content_snippets/{id}"); } /** - * You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. + * You can update an existing content snippet. * - * @param {Intercom.unstable.UpdateCollectionRequest} request - * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.ContentSnippetUpdateRequest} request + * @param {ContentSnippetsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.helpCenter.updateCollection({ - * id: 1, - * name: "Update collection name" + * await client.preview.contentSnippets.updateContentSnippet({ + * id: "123", + * title: "How to reset your password (updated)", + * json_blocks: [{ + * "type": "paragraph", + * "text": "Go to Settings > Security > Reset password and follow the steps." + * }], + * audience_ids: [1, 2] * }) */ - public updateCollection( - request: Intercom.unstable.UpdateCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateCollection(request, requestOptions)); + public updateContentSnippet( + request: Intercom.preview.ContentSnippetUpdateRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateContentSnippet(request, requestOptions)); } - private async __updateCollection( - request: Intercom.unstable.UpdateCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { + private async __updateContentSnippet( + request: Intercom.preview.ContentSnippetUpdateRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): Promise> { const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -287,7 +290,7 @@ export class HelpCenterClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(id)}`, + `content_snippets/${core.url.encodePathParam(id)}`, ), method: "PUT", headers: _headers, @@ -302,18 +305,18 @@ export class HelpCenterClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Collection, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ContentSnippet, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -323,34 +326,34 @@ export class HelpCenterClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/help_center/collections/{id}"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/content_snippets/{id}"); } /** - * You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. + * You can delete a single content snippet by its id. * - * @param {Intercom.unstable.DeleteCollectionRequest} request - * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.DeleteContentSnippetRequest} request + * @param {ContentSnippetsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.helpCenter.deleteCollection({ - * id: 1 + * await client.preview.contentSnippets.deleteContentSnippet({ + * id: "123" * }) */ - public deleteCollection( - request: Intercom.unstable.DeleteCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteCollection(request, requestOptions)); + public deleteContentSnippet( + request: Intercom.preview.DeleteContentSnippetRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteContentSnippet(request, requestOptions)); } - private async __deleteCollection( - request: Intercom.unstable.DeleteCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { + private async __deleteContentSnippet( + request: Intercom.preview.DeleteContentSnippetRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -364,7 +367,7 @@ export class HelpCenterClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(id)}`, + `content_snippets/${core.url.encodePathParam(id)}`, ), method: "DELETE", headers: _headers, @@ -376,21 +379,18 @@ export class HelpCenterClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.DeletedCollectionObject, - rawResponse: _response.rawResponse, - }; + return { data: undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -400,40 +400,43 @@ export class HelpCenterClient { } } - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/help_center/collections/{id}", - ); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/content_snippets/{id}"); } /** - * You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. + * Apply an existing tag to a content snippet. Returns the tag that was applied. * - * @param {Intercom.unstable.RetrieveHelpCenterRequest} request - * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. + * The tag must already exist in the workspace (create tags with the Tags API), + * and the authenticating teammate must have the `manage_knowledge_base_content` + * permission. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * Requires the `read_write_content_snippets` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.AttachTagToContentSnippetRequest} request + * @param {ContentSnippetsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.helpCenter.retrieveHelpCenter({ - * id: 1 + * await client.preview.contentSnippets.attachTagToContentSnippet({ + * content_snippet_id: "123", + * id: "7522907" * }) */ - public retrieveHelpCenter( - request: Intercom.unstable.RetrieveHelpCenterRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveHelpCenter(request, requestOptions)); + public attachTagToContentSnippet( + request: Intercom.preview.AttachTagToContentSnippetRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachTagToContentSnippet(request, requestOptions)); } - private async __retrieveHelpCenter( - request: Intercom.unstable.RetrieveHelpCenterRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __attachTagToContentSnippet( + request: Intercom.preview.AttachTagToContentSnippetRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): Promise> { + const { content_snippet_id: contentSnippetId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -446,11 +449,14 @@ export class HelpCenterClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `help_center/help_centers/${core.url.encodePathParam(id)}`, + `content_snippets/${core.url.encodePathParam(contentSnippetId)}/tags`, ), - method: "GET", + method: "POST", headers: _headers, + contentType: "application/json", queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -458,18 +464,23 @@ export class HelpCenterClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.HelpCenter, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -482,30 +493,45 @@ export class HelpCenterClient { return handleNonStatusCodeError( _response.error, _response.rawResponse, - "GET", - "/help_center/help_centers/{id}", + "POST", + "/content_snippets/{content_snippet_id}/tags", ); } /** - * You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. + * Remove a tag from a content snippet. Returns the tag that was removed, with + * null `applied_at` and `applied_by`. + * + * The authenticating teammate must have the `manage_knowledge_base_content` + * permission. + * + * Requires the `read_write_content_snippets` OAuth scope. Set `Intercom-Version: Preview`. * - * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.DetachTagFromContentSnippetRequest} request + * @param {ContentSnippetsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.helpCenter.listHelpCenters() + * await client.preview.contentSnippets.detachTagFromContentSnippet({ + * content_snippet_id: "123", + * id: "7522907" + * }) */ - public listHelpCenters( - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listHelpCenters(requestOptions)); + public detachTagFromContentSnippet( + request: Intercom.preview.DetachTagFromContentSnippetRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachTagFromContentSnippet(request, requestOptions)); } - private async __listHelpCenters( - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { + private async __detachTagFromContentSnippet( + request: Intercom.preview.DetachTagFromContentSnippetRequest, + requestOptions?: ContentSnippetsClient.RequestOptions, + ): Promise> { + const { content_snippet_id: contentSnippetId, id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -518,9 +544,9 @@ export class HelpCenterClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "help_center/help_centers", + `content_snippets/${core.url.encodePathParam(contentSnippetId)}/tags/${core.url.encodePathParam(id)}`, ), - method: "GET", + method: "DELETE", headers: _headers, queryParameters: requestOptions?.queryParams, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, @@ -530,16 +556,23 @@ export class HelpCenterClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.HelpCenterList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -549,6 +582,11 @@ export class HelpCenterClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/help_centers"); + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/content_snippets/{content_snippet_id}/tags/{id}", + ); } } diff --git a/src/api/resources/unstable/resources/dataAttributes/client/index.ts b/src/api/resources/preview/resources/contentSnippets/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataAttributes/client/index.ts rename to src/api/resources/preview/resources/contentSnippets/client/index.ts diff --git a/src/api/resources/preview/resources/contentSnippets/client/requests/AttachTagToContentSnippetRequest.ts b/src/api/resources/preview/resources/contentSnippets/client/requests/AttachTagToContentSnippetRequest.ts new file mode 100644 index 00000000..541d5d1c --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/client/requests/AttachTagToContentSnippetRequest.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * content_snippet_id: "123", + * id: "7522907" + * } + */ +export interface AttachTagToContentSnippetRequest { + /** The unique identifier for the content snippet. */ + content_snippet_id: string; + /** The unique identifier of the tag to apply, as given by Intercom. */ + id: string; + /** Optional id of the teammate to attribute the tagging to. Defaults to the authenticating teammate. Does not affect authorization. */ + admin_id?: string; +} diff --git a/src/api/resources/preview/resources/contentSnippets/client/requests/ContentSnippetCreateRequest.ts b/src/api/resources/preview/resources/contentSnippets/client/requests/ContentSnippetCreateRequest.ts new file mode 100644 index 00000000..3baff40e --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/client/requests/ContentSnippetCreateRequest.ts @@ -0,0 +1,32 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * title: "How to reset your password", + * json_blocks: [{ + * "type": "paragraph", + * "text": "Navigate to Settings > Security > Reset password." + * }], + * locale: "en", + * audience_ids: [1, 2] + * } + */ +export interface ContentSnippetCreateRequest { + /** The title of the content snippet. */ + title: string; + /** The content blocks that make up the body of the snippet. Mutually exclusive with `body_markdown`. */ + json_blocks?: Record[]; + /** The content of the snippet in markdown. An alternative to `json_blocks` — you can provide content as markdown instead of structured blocks. Mutually exclusive with `json_blocks`. */ + body_markdown?: string; + /** The locale of the content snippet. Defaults to `en`. */ + locale?: string; + /** The list of audience IDs to target this content snippet to for Fin AI Agent. Pass an empty array or omit the field for no audience targeting. Unknown audience IDs return a `404` error with no partial commit. */ + audience_ids?: number[]; + /** Whether the content snippet should be available for AI Chatbot (Fin). Defaults to false. */ + ai_chatbot_availability?: boolean; + /** Whether the content snippet should be available for AI Copilot. Defaults to false. */ + ai_copilot_availability?: boolean; + /** Whether the content snippet should be available for AI Sales Agent. Defaults to false. */ + ai_sales_agent_availability?: boolean; +} diff --git a/src/api/resources/preview/resources/contentSnippets/client/requests/ContentSnippetUpdateRequest.ts b/src/api/resources/preview/resources/contentSnippets/client/requests/ContentSnippetUpdateRequest.ts new file mode 100644 index 00000000..511c1ab7 --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/client/requests/ContentSnippetUpdateRequest.ts @@ -0,0 +1,34 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123", + * title: "How to reset your password (updated)", + * json_blocks: [{ + * "type": "paragraph", + * "text": "Go to Settings > Security > Reset password and follow the steps." + * }], + * audience_ids: [1, 2] + * } + */ +export interface ContentSnippetUpdateRequest { + /** The unique identifier for the content snippet. */ + id: string; + /** The title of the content snippet. */ + title?: string; + /** The content blocks that make up the body of the snippet. Mutually exclusive with `body_markdown`. */ + json_blocks?: Record[]; + /** The content of the snippet in markdown. An alternative to `json_blocks` — you can provide content as markdown instead of structured blocks. Mutually exclusive with `json_blocks`. */ + body_markdown?: string; + /** The locale of the content snippet. */ + locale?: string; + /** The list of audience IDs to target this content snippet to for Fin AI Agent. Omitting the field leaves existing audience memberships unchanged (PATCH semantics). Pass `[]` to clear all audience memberships. Unknown audience IDs return a `404` error with no partial commit. */ + audience_ids?: number[]; + /** Whether the content snippet should be available for AI Chatbot (Fin). */ + ai_chatbot_availability?: boolean; + /** Whether the content snippet should be available for AI Copilot. */ + ai_copilot_availability?: boolean; + /** Whether the content snippet should be available for AI Sales Agent. */ + ai_sales_agent_availability?: boolean; +} diff --git a/src/api/resources/preview/resources/contentSnippets/client/requests/DeleteContentSnippetRequest.ts b/src/api/resources/preview/resources/contentSnippets/client/requests/DeleteContentSnippetRequest.ts new file mode 100644 index 00000000..5308da1f --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/client/requests/DeleteContentSnippetRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123" + * } + */ +export interface DeleteContentSnippetRequest { + /** The unique identifier for the content snippet. */ + id: string; +} diff --git a/src/api/resources/preview/resources/contentSnippets/client/requests/DetachTagFromContentSnippetRequest.ts b/src/api/resources/preview/resources/contentSnippets/client/requests/DetachTagFromContentSnippetRequest.ts new file mode 100644 index 00000000..e605874d --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/client/requests/DetachTagFromContentSnippetRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * content_snippet_id: "123", + * id: "7522907" + * } + */ +export interface DetachTagFromContentSnippetRequest { + /** The unique identifier for the content snippet. */ + content_snippet_id: string; + /** The unique identifier of the tag to remove, as given by Intercom. */ + id: string; +} diff --git a/src/api/resources/preview/resources/contentSnippets/client/requests/GetContentSnippetRequest.ts b/src/api/resources/preview/resources/contentSnippets/client/requests/GetContentSnippetRequest.ts new file mode 100644 index 00000000..92690751 --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/client/requests/GetContentSnippetRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123" + * } + */ +export interface GetContentSnippetRequest { + /** The unique identifier for the content snippet. */ + id: string; +} diff --git a/src/api/resources/preview/resources/contentSnippets/client/requests/ListContentSnippetsRequest.ts b/src/api/resources/preview/resources/contentSnippets/client/requests/ListContentSnippetsRequest.ts new file mode 100644 index 00000000..56681c2b --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/client/requests/ListContentSnippetsRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * page: 1, + * per_page: 20 + * } + */ +export interface ListContentSnippetsRequest { + /** The page of results to fetch. */ + page?: number; + /** The number of results to return per page. Max value of 50. */ + per_page?: number; +} diff --git a/src/api/resources/preview/resources/contentSnippets/client/requests/index.ts b/src/api/resources/preview/resources/contentSnippets/client/requests/index.ts new file mode 100644 index 00000000..44c68e1b --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/client/requests/index.ts @@ -0,0 +1,7 @@ +export type { AttachTagToContentSnippetRequest } from "./AttachTagToContentSnippetRequest.js"; +export type { ContentSnippetCreateRequest } from "./ContentSnippetCreateRequest.js"; +export type { ContentSnippetUpdateRequest } from "./ContentSnippetUpdateRequest.js"; +export type { DeleteContentSnippetRequest } from "./DeleteContentSnippetRequest.js"; +export type { DetachTagFromContentSnippetRequest } from "./DetachTagFromContentSnippetRequest.js"; +export type { GetContentSnippetRequest } from "./GetContentSnippetRequest.js"; +export type { ListContentSnippetsRequest } from "./ListContentSnippetsRequest.js"; diff --git a/src/api/resources/unstable/resources/dataExport/index.ts b/src/api/resources/preview/resources/contentSnippets/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataExport/index.ts rename to src/api/resources/preview/resources/contentSnippets/index.ts diff --git a/src/api/resources/preview/resources/contentSnippets/types/index.ts b/src/api/resources/preview/resources/contentSnippets/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/contentSnippets/types/types.ts b/src/api/resources/preview/resources/contentSnippets/types/types.ts new file mode 100644 index 00000000..d4446955 --- /dev/null +++ b/src/api/resources/preview/resources/contentSnippets/types/types.ts @@ -0,0 +1,35 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A content snippet is a reusable piece of content for your AI agent and Copilot. + */ +export interface ContentSnippet { + /** String representing the object's type. Always has the value `content_snippet`. */ + type?: string; + /** The unique identifier for the content snippet. */ + id?: string; + /** The title of the content snippet. */ + title?: string; + /** The locale of the content snippet. */ + locale?: string; + /** The content blocks that make up the body of the snippet. */ + json_blocks?: Record[]; + /** The body of the content snippet in markdown. */ + body_markdown?: string; + /** Deprecated. Use ai_chatbot_availability instead. Whether this snippet is available for Fin (1 = on, 0 = off). */ + chatbot_availability?: number; + /** Deprecated. Use ai_copilot_availability instead. Whether this snippet is available for Copilot (1 = on, 0 = off). */ + copilot_availability?: number; + /** Whether the content snippet is available for AI Chatbot (Fin). */ + ai_chatbot_availability?: boolean; + /** Whether the content snippet is available for AI Copilot. */ + ai_copilot_availability?: boolean; + /** Whether the content snippet is available for AI Sales Agent. */ + ai_sales_agent_availability?: boolean; + /** The time the snippet was created as a UNIX timestamp. */ + created_at?: number; + /** The time the snippet was last updated as a UNIX timestamp. */ + updated_at?: number; + /** The list of audience IDs this content snippet is targeted to for Fin AI Agent. Empty array means no audience targeting is set. */ + audience_ids?: number[]; +} diff --git a/src/api/resources/preview/resources/conversation/index.ts b/src/api/resources/preview/resources/conversation/index.ts new file mode 100644 index 00000000..2f88e301 --- /dev/null +++ b/src/api/resources/preview/resources/conversation/index.ts @@ -0,0 +1 @@ +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/conversation/types/index.ts b/src/api/resources/preview/resources/conversation/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/conversation/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/conversation/types/types.ts b/src/api/resources/preview/resources/conversation/types/types.ts new file mode 100644 index 00000000..55c6a860 --- /dev/null +++ b/src/api/resources/preview/resources/conversation/types/types.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A deleted conversation record containing its ID, metrics retained status and deletion timestamp. + */ +export interface DeletedConversationItem { + /** String representing the object's type. Always has the value `conversation`. */ + type?: string; + /** The ID of the deleted conversation. */ + id?: string; + /** Whether reporting metrics are retained for this conversation ID */ + metrics_retained?: boolean; + /** The time when the conversation was deleted. */ + deleted_at?: number; +} diff --git a/src/api/resources/preview/resources/conversationParticipants/client/Client.ts b/src/api/resources/preview/resources/conversationParticipants/client/Client.ts new file mode 100644 index 00000000..b9b0fd70 --- /dev/null +++ b/src/api/resources/preview/resources/conversationParticipants/client/Client.ts @@ -0,0 +1,240 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace ConversationParticipantsClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Manage contacts participating in conversations + */ +export class ConversationParticipantsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ConversationParticipantsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * + * {% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. + * {% /admonition %} + * + * + * @param {Intercom.preview.AttachContactToConversationRequest} request + * @param {ConversationParticipantsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.conversationParticipants.attachContactToConversation({ + * id: "123", + * admin_id: "12345", + * customer: { + * intercom_user_id: "6762f19b1bb69f9f2193bbd4" + * } + * }) + * + * @example + * await client.preview.conversationParticipants.attachContactToConversation({ + * id: "123", + * admin_id: "12345", + * customer: { + * intercom_user_id: "6762f19e1bb69f9f2193bbd5" + * } + * }) + */ + public attachContactToConversation( + request: Intercom.preview.AttachContactToConversationRequest, + requestOptions?: ConversationParticipantsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachContactToConversation(request, requestOptions)); + } + + private async __attachContactToConversation( + request: Intercom.preview.AttachContactToConversationRequest, + requestOptions?: ConversationParticipantsClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${core.url.encodePathParam(id)}/customers`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationParticipantsResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/conversations/{id}/customers", + ); + } + + /** + * You can remove participants who are contacts from a group conversation, on behalf of an admin. + * + * {% admonition type="warning" name="Removing the last participant" %} + * You cannot remove the last remaining contact from a conversation. + * {% /admonition %} + * + * + * @param {Intercom.preview.DetachContactFromConversationRequest} request + * @param {ConversationParticipantsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.conversationParticipants.detachContactFromConversation({ + * conversation_id: "123", + * contact_id: "123", + * admin_id: "5017690" + * }) + */ + public detachContactFromConversation( + request: Intercom.preview.DetachContactFromConversationRequest, + requestOptions?: ConversationParticipantsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachContactFromConversation(request, requestOptions)); + } + + private async __detachContactFromConversation( + request: Intercom.preview.DetachContactFromConversationRequest, + requestOptions?: ConversationParticipantsClient.RequestOptions, + ): Promise> { + const { conversation_id: conversationId, contact_id: contactId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${core.url.encodePathParam(conversationId)}/customers/${core.url.encodePathParam(contactId)}`, + ), + method: "DELETE", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationParticipantsResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/conversations/{conversation_id}/customers/{contact_id}", + ); + } +} diff --git a/src/api/resources/unstable/resources/dataEvents/client/index.ts b/src/api/resources/preview/resources/conversationParticipants/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataEvents/client/index.ts rename to src/api/resources/preview/resources/conversationParticipants/client/index.ts diff --git a/src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts b/src/api/resources/preview/resources/conversationParticipants/client/requests/AttachContactToConversationRequest.ts similarity index 82% rename from src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts rename to src/api/resources/preview/resources/conversationParticipants/client/requests/AttachContactToConversationRequest.ts index e7d06d91..a3817832 100644 --- a/src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts +++ b/src/api/resources/preview/resources/conversationParticipants/client/requests/AttachContactToConversationRequest.ts @@ -33,14 +33,14 @@ export namespace AttachContactToConversationRequest { export type Customer = | { intercom_user_id: string; - customer?: Intercom.unstable.CustomerRequest | undefined; + customer?: Intercom.preview.CustomerRequest | undefined; } | { user_id: string; - customer?: Intercom.unstable.CustomerRequest | undefined; + customer?: Intercom.preview.CustomerRequest | undefined; } | { email: string; - customer?: Intercom.unstable.CustomerRequest | undefined; + customer?: Intercom.preview.CustomerRequest | undefined; }; } diff --git a/src/api/resources/unstable/resources/conversations/client/requests/DetachContactFromConversationRequest.ts b/src/api/resources/preview/resources/conversationParticipants/client/requests/DetachContactFromConversationRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/conversations/client/requests/DetachContactFromConversationRequest.ts rename to src/api/resources/preview/resources/conversationParticipants/client/requests/DetachContactFromConversationRequest.ts diff --git a/src/api/resources/preview/resources/conversationParticipants/client/requests/index.ts b/src/api/resources/preview/resources/conversationParticipants/client/requests/index.ts new file mode 100644 index 00000000..9bf60370 --- /dev/null +++ b/src/api/resources/preview/resources/conversationParticipants/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { AttachContactToConversationRequest } from "./AttachContactToConversationRequest.js"; +export type { DetachContactFromConversationRequest } from "./DetachContactFromConversationRequest.js"; diff --git a/src/api/resources/unstable/resources/awayStatusReasons/index.ts b/src/api/resources/preview/resources/conversationParticipants/index.ts similarity index 100% rename from src/api/resources/unstable/resources/awayStatusReasons/index.ts rename to src/api/resources/preview/resources/conversationParticipants/index.ts diff --git a/src/api/resources/preview/resources/conversationParts/client/Client.ts b/src/api/resources/preview/resources/conversationParts/client/Client.ts new file mode 100644 index 00000000..3720fc0a --- /dev/null +++ b/src/api/resources/preview/resources/conversationParts/client/Client.ts @@ -0,0 +1,224 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace ConversationPartsClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Update and redact individual conversation parts + */ +export class ConversationPartsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ConversationPartsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * You can update properties of a conversation part. Currently supports updating the send state of an external reply or marking a part as seen by an admin. + * + * {% admonition type="warning" name="Experimental" %} + * This is an experimental endpoint. It requires a valid HMAC secret for authentication in addition to the standard bearer token. + * {% /admonition %} + * + * @param {Intercom.preview.UpdateConversationPartRequest} request + * @param {ConversationPartsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.conversationParts.updateConversationPart({ + * conversation_id: "123", + * id: "456", + * send_state: "sent", + * info_message: "Message delivered successfully", + * experimental: true, + * secret: "hmac_secret_value" + * }) + * + * @example + * await client.preview.conversationParts.updateConversationPart({ + * conversation_id: "123", + * id: "456", + * seen: true, + * admin_id: "991267694", + * experimental: true, + * secret: "hmac_secret_value" + * }) + */ + public updateConversationPart( + request: Intercom.preview.UpdateConversationPartRequest, + requestOptions?: ConversationPartsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateConversationPart(request, requestOptions)); + } + + private async __updateConversationPart( + request: Intercom.preview.UpdateConversationPartRequest, + requestOptions?: ConversationPartsClient.RequestOptions, + ): Promise> { + const { conversation_id: conversationId, id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${core.url.encodePathParam(conversationId)}/conversation_parts/${core.url.encodePathParam(id)}`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ConversationPart, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PUT", + "/conversations/{conversation_id}/conversation_parts/{id}", + ); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + * + * {% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. + * {% /admonition %} + * + * + * @param {Intercom.preview.RedactConversationRequest} request + * @param {ConversationPartsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.conversationParts.redactConversation({ + * type: "conversation_part", + * conversation_id: "19894788788", + * conversation_part_id: "19381789428" + * }) + * + * @example + * await client.preview.conversationParts.redactConversation({ + * type: "conversation_part", + * conversation_id: "really_123_doesnt_exist", + * conversation_part_id: "really_123_doesnt_exist" + * }) + */ + public redactConversation( + request: Intercom.preview.RedactConversationRequest, + requestOptions?: ConversationPartsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__redactConversation(request, requestOptions)); + } + + private async __redactConversation( + request: Intercom.preview.RedactConversationRequest, + requestOptions?: ConversationPartsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations/redact", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/redact"); + } +} diff --git a/src/api/resources/unstable/resources/dataExport/client/index.ts b/src/api/resources/preview/resources/conversationParts/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataExport/client/index.ts rename to src/api/resources/preview/resources/conversationParts/client/index.ts diff --git a/src/api/resources/preview/resources/conversationParts/client/requests/UpdateConversationPartRequest.ts b/src/api/resources/preview/resources/conversationParts/client/requests/UpdateConversationPartRequest.ts new file mode 100644 index 00000000..2731a447 --- /dev/null +++ b/src/api/resources/preview/resources/conversationParts/client/requests/UpdateConversationPartRequest.ts @@ -0,0 +1,41 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * conversation_id: "123", + * id: "456", + * send_state: "sent", + * info_message: "Message delivered successfully", + * experimental: true, + * secret: "hmac_secret_value" + * } + * + * @example + * { + * conversation_id: "123", + * id: "456", + * seen: true, + * admin_id: "991267694", + * experimental: true, + * secret: "hmac_secret_value" + * } + */ +export interface UpdateConversationPartRequest { + /** The identifier for the conversation as given by Intercom. */ + conversation_id: string; + /** The identifier for the conversation part. */ + id: string; + /** The send state to set on the external reply. */ + send_state?: string; + /** An informational message about the send state update. */ + info_message?: string; + /** Set to true to mark the conversation part as seen. */ + seen?: boolean; + /** The id of the admin marking the part as seen. */ + admin_id?: string; + /** Must be true to use this experimental endpoint. */ + experimental: boolean; + /** HMAC secret for authenticating the experimental request. */ + secret: string; +} diff --git a/src/api/resources/preview/resources/conversationParts/client/requests/index.ts b/src/api/resources/preview/resources/conversationParts/client/requests/index.ts new file mode 100644 index 00000000..9e7ef30b --- /dev/null +++ b/src/api/resources/preview/resources/conversationParts/client/requests/index.ts @@ -0,0 +1 @@ +export type { UpdateConversationPartRequest } from "./UpdateConversationPartRequest.js"; diff --git a/src/api/resources/unstable/resources/customChannelEvents/index.ts b/src/api/resources/preview/resources/conversationParts/index.ts similarity index 100% rename from src/api/resources/unstable/resources/customChannelEvents/index.ts rename to src/api/resources/preview/resources/conversationParts/index.ts diff --git a/src/api/resources/unstable/resources/conversations/client/Client.ts b/src/api/resources/preview/resources/conversations/client/Client.ts similarity index 65% rename from src/api/resources/unstable/resources/conversations/client/Client.ts rename to src/api/resources/preview/resources/conversations/client/Client.ts index 1823bcca..105f666d 100644 --- a/src/api/resources/unstable/resources/conversations/client/Client.ts +++ b/src/api/resources/preview/resources/conversations/client/Client.ts @@ -34,30 +34,37 @@ export class ConversationsClient { * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * - * @param {Intercom.unstable.ListConversationsRequest} request + * @param {Intercom.preview.ListConversationsRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} * * @example - * await client.unstable.conversations.listConversations({ + * await client.preview.conversations.listConversations({ * per_page: 1, - * starting_after: "starting_after" + * starting_after: "starting_after", + * include_monitors: true, + * include_scorecards: true * }) */ public listConversations( - request: Intercom.unstable.ListConversationsRequest = {}, + request: Intercom.preview.ListConversationsRequest = {}, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listConversations(request, requestOptions)); } private async __listConversations( - request: Intercom.unstable.ListConversationsRequest = {}, + request: Intercom.preview.ListConversationsRequest = {}, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { per_page: perPage, starting_after: startingAfter } = request; + ): Promise> { + const { + per_page: perPage, + starting_after: startingAfter, + include_monitors: includeMonitors, + include_scorecards: includeScorecards, + } = request; const _queryParams: Record = {}; if (perPage != null) { _queryParams.per_page = perPage.toString(); @@ -67,6 +74,14 @@ export class ConversationsClient { _queryParams.starting_after = startingAfter; } + if (includeMonitors != null) { + _queryParams.include_monitors = includeMonitors.toString(); + } + + if (includeScorecards != null) { + _queryParams.include_scorecards = includeScorecards.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -91,19 +106,19 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ConversationList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ConversationList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -130,24 +145,25 @@ export class ConversationsClient { * This will return the Message model that has been created. * * - * @param {Intercom.unstable.CreateConversationRequest} request + * @param {Intercom.preview.CreateConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.conversations.createConversation({ + * await client.preview.conversations.createConversation({ * from: { * type: "user", * id: "6762f11b1bb69f9f2193bba3" * }, - * body: "Hello there" + * body: "Hello there", + * brand_id: "123" * }) * * @example - * await client.unstable.conversations.createConversation({ + * await client.preview.conversations.createConversation({ * from: { * type: "user", * id: "123_doesnt_exist" @@ -156,16 +172,16 @@ export class ConversationsClient { * }) */ public createConversation( - request: Intercom.unstable.CreateConversationRequest, + request: Intercom.preview.CreateConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createConversation(request, requestOptions)); } private async __createConversation( - request: Intercom.unstable.CreateConversationRequest, + request: Intercom.preview.CreateConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -193,23 +209,23 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Message, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Message, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -229,37 +245,50 @@ export class ConversationsClient { * This will return a single Conversation model with all its conversation parts. * * {% admonition type="warning" name="Hard limit of 500 parts" %} - * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. `include_part_types` and `exclude_part_types` are applied before this limit, so filtering returns the 500 most recent matching parts. `conversation_parts.total_count` counts the parts in this response, after filtering — it is not the conversation's total part count. * {% /admonition %} * * For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a [paid feature](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). * - * @param {Intercom.unstable.RetrieveConversationRequest} request + * @param {Intercom.preview.RetrieveConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.conversations.retrieveConversation({ + * await client.preview.conversations.retrieveConversation({ * id: 1, * display_as: "plaintext", - * include_translations: true + * include_translations: true, + * include_email_history: true, + * include_monitors: true, + * include_scorecards: true * }) */ public retrieveConversation( - request: Intercom.unstable.RetrieveConversationRequest, + request: Intercom.preview.RetrieveConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__retrieveConversation(request, requestOptions)); } private async __retrieveConversation( - request: Intercom.unstable.RetrieveConversationRequest, + request: Intercom.preview.RetrieveConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id, display_as: displayAs, include_translations: includeTranslations } = request; + ): Promise> { + const { + id, + display_as: displayAs, + include_translations: includeTranslations, + include_email_history: includeEmailHistory, + include_monitors: includeMonitors, + include_scorecards: includeScorecards, + include_part_types: includePartTypes, + exclude_part_types: excludePartTypes, + } = request; const _queryParams: Record = {}; if (displayAs != null) { _queryParams.display_as = displayAs; @@ -269,6 +298,34 @@ export class ConversationsClient { _queryParams.include_translations = includeTranslations.toString(); } + if (includeEmailHistory != null) { + _queryParams.include_email_history = includeEmailHistory.toString(); + } + + if (includeMonitors != null) { + _queryParams.include_monitors = includeMonitors.toString(); + } + + if (includeScorecards != null) { + _queryParams.include_scorecards = includeScorecards.toString(); + } + + if (includePartTypes != null) { + if (Array.isArray(includePartTypes)) { + _queryParams.include_part_types = includePartTypes.map((item) => item); + } else { + _queryParams.include_part_types = includePartTypes; + } + } + + if (excludePartTypes != null) { + if (Array.isArray(excludePartTypes)) { + _queryParams.exclude_part_types = excludePartTypes.map((item) => item); + } else { + _queryParams.exclude_part_types = excludePartTypes; + } + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -293,23 +350,28 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -336,28 +398,38 @@ export class ConversationsClient { * See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. * {% /admonition %} * + * {% admonition type="danger" name="Breaking change: duplicate custom attribute names" %} + * The `PUT /conversations/{id}` endpoint now returns a `400 INVALID_PARAMETER` error when the request includes `custom_attributes` and your workspace contains multiple non-archived conversation custom attributes with the same name. Previously, the update would silently apply to a non-deterministic attribute. * - * @param {Intercom.unstable.UpdateConversationRequest} request + * To resolve, rename or archive the duplicate attribute so each name is unique, then retry the request. You can do this through: + * + * - The Conversation Attributes API — list with `GET /conversations/attributes`, then rename with `PUT /conversations/attributes/{id}` or archive with `DELETE /conversations/attributes/{id}` + * - Your workspace settings (Settings → Data → Conversations) + * {% /admonition %} + * + * + * @param {Intercom.preview.UpdateConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.conversations.updateConversation({ + * await client.preview.conversations.updateConversation({ * id: 1, * display_as: "plaintext", * read: true, * title: "new conversation title", + * priority: "high", + * admin_id: "394051", * custom_attributes: { - * "issue_type": "Billing", - * "priority": "High" + * "issue_type": "Billing" * } * }) * * @example - * await client.unstable.conversations.updateConversation({ + * await client.preview.conversations.updateConversation({ * id: 1, * display_as: "plaintext", * custom_attributes: { @@ -366,16 +438,16 @@ export class ConversationsClient { * }) */ public updateConversation( - request: Intercom.unstable.UpdateConversationRequest, + request: Intercom.preview.UpdateConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateConversation(request, requestOptions)); } private async __updateConversation( - request: Intercom.unstable.UpdateConversationRequest, + request: Intercom.preview.UpdateConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, display_as: displayAs, ..._body } = request; const _queryParams: Record = {}; if (displayAs != null) { @@ -409,23 +481,23 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -439,31 +511,51 @@ export class ConversationsClient { } /** - * You can delete a single conversation. + * {% admonition type="warning" name="Irreversible operation" %} + * Deleting a conversation is permanent and cannot be reversed. + * {% /admonition %} + * + * You can delete a single conversation. The behavior depends on the `retain_metrics` parameter: * - * @param {Intercom.unstable.DeleteConversationRequest} request + * - **With `retain_metrics=true` (default)**: Deletes the conversation while retaining reporting data. The conversation will still appear in reporting, though some data may be incomplete due to the deletion. + * + * - **With `retain_metrics=false`**: Deletes the conversation and all associated reporting data. The conversation will be completely removed from both the inbox and all reporting. + * + * {% admonition type="info" name="Required scope for retain_metrics=false" %} + * Using `retain_metrics=false` requires the `delete_conversations_and_metrics` OAuth scope. + * {% /admonition %} + * + * For more info, see [this help center article](https://www.intercom.com/help/en/articles/13885146-deleting-a-conversation). + * + * @param {Intercom.preview.DeleteConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} * * @example - * await client.unstable.conversations.deleteConversation({ - * id: 1 + * await client.preview.conversations.deleteConversation({ + * id: 1, + * retain_metrics: true * }) */ public deleteConversation( - request: Intercom.unstable.DeleteConversationRequest, + request: Intercom.preview.DeleteConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteConversation(request, requestOptions)); } private async __deleteConversation( - request: Intercom.unstable.DeleteConversationRequest, + request: Intercom.preview.DeleteConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id } = request; + ): Promise> { + const { id, retain_metrics: retainMetrics } = request; + const _queryParams: Record = {}; + if (retainMetrics != null) { + _queryParams.retain_metrics = retainMetrics.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -480,7 +572,7 @@ export class ConversationsClient { ), method: "DELETE", headers: _headers, - queryParameters: requestOptions?.queryParams, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -488,22 +580,19 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ConversationDeleted, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.ConversationDeleted, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -560,8 +649,8 @@ export class ConversationsClient { * | source.url | String | * | contact_ids | String | * | teammate_ids | String | - * | admin_assignee_id | String | - * | team_assignee_id | String | + * | admin_assignee_id | Integer | + * | team_assignee_id | Integer | * | channel_initiated | String | * | open | Boolean | * | read | Boolean | @@ -619,35 +708,49 @@ export class ConversationsClient { * | ^ | String | Starts With | * | $ | String | Ends With | * - * @param {Intercom.unstable.SearchRequest} request + * @param {Intercom.preview.SearchConversationsRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.unstable.conversations.searchConversations({ - * query: { - * operator: "AND", - * value: [{ - * field: "created_at", - * operator: ">", - * value: "1306054154" - * }] - * }, - * pagination: { - * per_page: 5 + * await client.preview.conversations.searchConversations({ + * include_monitors: true, + * include_scorecards: true, + * body: { + * query: { + * operator: "AND", + * value: [{ + * field: "created_at", + * operator: ">", + * value: "1306054154" + * }] + * }, + * pagination: { + * per_page: 5 + * } * } * }) */ public searchConversations( - request: Intercom.unstable.SearchRequest, + request: Intercom.preview.SearchConversationsRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__searchConversations(request, requestOptions)); } private async __searchConversations( - request: Intercom.unstable.SearchRequest, + request: Intercom.preview.SearchConversationsRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { + const { include_monitors: includeMonitors, include_scorecards: includeScorecards, body: _body } = request; + const _queryParams: Record = {}; + if (includeMonitors != null) { + _queryParams.include_monitors = includeMonitors.toString(); + } + + if (includeScorecards != null) { + _queryParams.include_scorecards = includeScorecards.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -665,9 +768,9 @@ export class ConversationsClient { method: "POST", headers: _headers, contentType: "application/json", - queryParameters: requestOptions?.queryParams, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, requestType: "json", - body: request, + body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -675,7 +778,7 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ConversationList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ConversationList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -692,15 +795,21 @@ export class ConversationsClient { /** * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. * - * @param {Intercom.unstable.ReplyConversationRequest} request + * {% admonition type="warning" name="Bot replies to inbound email" %} + * By default, bot or Operator replies to an inbound email conversation aren't sent to your customer. The reply is stored as an unnotifiable bot comment, and no `seen` receipt is generated until an email is actually delivered. + * + * To send these replies as outbound emails, reach out to your accounts team to enable the email-reply feature flag for your workspace. + * {% /admonition %} + * + * @param {Intercom.preview.ReplyConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.conversations.replyConversation({ + * await client.preview.conversations.replyConversation({ * id: "123 or \"last\"", * body: { * message_type: "comment", @@ -711,7 +820,7 @@ export class ConversationsClient { * }) * * @example - * await client.unstable.conversations.replyConversation({ + * await client.preview.conversations.replyConversation({ * id: "123 or \"last\"", * body: { * message_type: "note", @@ -722,7 +831,7 @@ export class ConversationsClient { * }) * * @example - * await client.unstable.conversations.replyConversation({ + * await client.preview.conversations.replyConversation({ * id: "123 or \"last\"", * body: { * message_type: "quick_reply", @@ -739,7 +848,7 @@ export class ConversationsClient { * }) * * @example - * await client.unstable.conversations.replyConversation({ + * await client.preview.conversations.replyConversation({ * id: "123 or \"last\"", * body: { * message_type: "comment", @@ -754,7 +863,7 @@ export class ConversationsClient { * }) * * @example - * await client.unstable.conversations.replyConversation({ + * await client.preview.conversations.replyConversation({ * id: "123 or \"last\"", * body: { * message_type: "comment", @@ -765,16 +874,16 @@ export class ConversationsClient { * }) */ public replyConversation( - request: Intercom.unstable.ReplyConversationRequest, + request: Intercom.preview.ReplyConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__replyConversation(request, requestOptions)); } private async __replyConversation( - request: Intercom.unstable.ReplyConversationRequest, + request: Intercom.preview.ReplyConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, body: _body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -803,23 +912,23 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -839,15 +948,15 @@ export class ConversationsClient { * - Open a conversation which is `snoozed` or `closed` * - Assign a conversation to an admin and/or team. * - * @param {Intercom.unstable.ManageConversationRequest} request + * @param {Intercom.preview.ManageConversationRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.conversations.manageConversation({ + * await client.preview.conversations.manageConversation({ * id: "123", * body: { * message_type: "close", @@ -857,7 +966,7 @@ export class ConversationsClient { * }) * * @example - * await client.unstable.conversations.manageConversation({ + * await client.preview.conversations.manageConversation({ * id: "123", * body: { * message_type: "snoozed", @@ -867,7 +976,7 @@ export class ConversationsClient { * }) * * @example - * await client.unstable.conversations.manageConversation({ + * await client.preview.conversations.manageConversation({ * id: "123", * body: { * message_type: "open", @@ -876,7 +985,7 @@ export class ConversationsClient { * }) * * @example - * await client.unstable.conversations.manageConversation({ + * await client.preview.conversations.manageConversation({ * id: "123", * body: { * message_type: "assignment", @@ -887,16 +996,16 @@ export class ConversationsClient { * }) */ public manageConversation( - request: Intercom.unstable.ManageConversationRequest, + request: Intercom.preview.ManageConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__manageConversation(request, requestOptions)); } private async __manageConversation( - request: Intercom.unstable.ManageConversationRequest, + request: Intercom.preview.ManageConversationRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, body: _body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -925,23 +1034,23 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -955,50 +1064,33 @@ export class ConversationsClient { } /** - * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. - * - * {% admonition type="warning" name="Contacts without an email" %} - * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. - * {% /admonition %} + * List all pause/resume events for a conversation. These events track when teammates paused or resumed handling a conversation. * + * Requires the `read_conversations` OAuth scope. * - * @param {Intercom.unstable.AttachContactToConversationRequest} request + * @param {Intercom.preview.ListHandlingEventsRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.conversations.attachContactToConversation({ - * id: "123", - * admin_id: "12345", - * customer: { - * intercom_user_id: "6762f19b1bb69f9f2193bbd4" - * } - * }) - * - * @example - * await client.unstable.conversations.attachContactToConversation({ - * id: "123", - * admin_id: "12345", - * customer: { - * intercom_user_id: "6762f19e1bb69f9f2193bbd5" - * } + * await client.preview.conversations.listHandlingEvents({ + * id: "123" * }) */ - public attachContactToConversation( - request: Intercom.unstable.AttachContactToConversationRequest, + public listHandlingEvents( + request: Intercom.preview.ListHandlingEventsRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachContactToConversation(request, requestOptions)); + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listHandlingEvents(request, requestOptions)); } - private async __attachContactToConversation( - request: Intercom.unstable.AttachContactToConversationRequest, + private async __listHandlingEvents( + request: Intercom.preview.ListHandlingEventsRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; + ): Promise> { + const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -1011,14 +1103,11 @@ export class ConversationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}/customers`, + `conversations/${core.url.encodePathParam(id)}/handling_events`, ), - method: "POST", + method: "GET", headers: _headers, - contentType: "application/json", queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1026,23 +1115,18 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.HandlingEventList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -1055,46 +1139,63 @@ export class ConversationsClient { return handleNonStatusCodeError( _response.error, _response.rawResponse, - "POST", - "/conversations/{id}/customers", + "GET", + "/conversations/{id}/handling_events", ); } /** - * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * List the human-in-the-loop (HITL) events for a conversation. When Fin is unsure of an answer it can consult a teammate before replying, proposing a draft that the teammate approves, steers with free-text feedback, or takes over. Each consultation is returned as a series of events, oldest first, across every consultation on the conversation. * - * {% admonition type="warning" name="Contacts without an email" %} - * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. - * {% /admonition %} + * Requires the `read_conversations` OAuth scope, and the caller must be able to access the conversation. + * + * Events are only recorded once a consultation has ended, so a consultation still awaiting a teammate does not appear. + * + * Which fields appear in `data` depends on `event_type`: * + * | `event_type` | `data` fields | + * |---|---| + * | `fin_consultation_started` | `channel`, `rule_threshold_percent`, `confidence_percent`, `sharp_ask`, `ask_rationale`, `issue_summary`, `customer_question` | + * | `fin_draft_proposed` | `draft` | + * | `fin_teammate_input_received` | `round_index`, `teammate_input`, `reviewer_admin_id`, `regeneration_outcome` | + * | `fin_draft_revised` | `round_index`, `revised_draft`, `regeneration_outcome` | + * | `fin_consultation_finished` | `outcome`, `approved_draft_type`, `final_draft`, `sent_text`, `reviewer_admin_id`, `duration_seconds`, `rounds_count`, `payload_truncated` | * - * @param {Intercom.unstable.DetachContactFromConversationRequest} request + * A consultation always produces a `fin_consultation_started` and a `fin_consultation_finished` event. `fin_draft_proposed` appears when Fin proposed a draft. `fin_teammate_input_received` appears once per round of teammate feedback, and `fin_draft_revised` once per round where Fin produced a revised draft in response. + * + * Notes on interpreting the response: + * + * - `hitl_cycle_id` identifies the consultation, so it is the same on every event of one consultation. It is not unique per event. A conversation can hold several consultations — a consultation that replaces an outstanding one finishes with an `outcome` of `superseded`. + * - `conversation_part_id` links an event to a conversation part where one exists. It is `null` in ordinary cases: teammate feedback given through the inbox creates no conversation part, a revised draft has no part of its own, and a consultation that escalated or was superseded sent no reply. + * - `created_at` on `fin_draft_proposed` is approximate. It reports when the consultation started, which is when the draft was proposed. + * - `rule_id`, `rule_name` and `rule_threshold_percent` are recorded when the consultation begins and are not updated afterwards, so a rule that has since been renamed or retuned will not match its current settings. They are `null` for consultations not triggered by a rule. + * - `reviewer_admin_id` identifies the teammate involved in that event: on `fin_teammate_input_received` the teammate who gave the feedback, and on `fin_consultation_finished` the teammate who approved the draft or took over. On a consultation with several rounds these can be different teammates. + * - `rounds_count` counts every round of teammate feedback the consultation had. Only the ten most recent rounds are retained, so a heavily steered consultation returns fewer `fin_teammate_input_received` events than `rounds_count`. + * - Redacting a conversation removes this data. Depending on how it was redacted, the conversation either returns no events or returns events whose text fields are all `null`. + * + * @param {Intercom.preview.ListHitlEventsRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} - * @throws {@link Intercom.unstable.UnprocessableEntityError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.conversations.detachContactFromConversation({ - * conversation_id: "123", - * contact_id: "123", - * admin_id: "5017690" + * await client.preview.conversations.listHitlEvents({ + * id: "123" * }) */ - public detachContactFromConversation( - request: Intercom.unstable.DetachContactFromConversationRequest, + public listHitlEvents( + request: Intercom.preview.ListHitlEventsRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachContactFromConversation(request, requestOptions)); + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listHitlEvents(request, requestOptions)); } - private async __detachContactFromConversation( - request: Intercom.unstable.DetachContactFromConversationRequest, + private async __listHitlEvents( + request: Intercom.preview.ListHitlEventsRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, contact_id: contactId, ..._body } = request; + ): Promise> { + const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -1107,14 +1208,11 @@ export class ConversationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/customers/${core.url.encodePathParam(contactId)}`, + `conversations/${core.url.encodePathParam(id)}/hitl_events`, ), - method: "DELETE", + method: "GET", headers: _headers, - contentType: "application/json", queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1122,28 +1220,18 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.HitlEventList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.unstable.UnprocessableEntityError( - _response.error.body as unknown, - _response.rawResponse, - ); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -1156,39 +1244,52 @@ export class ConversationsClient { return handleNonStatusCodeError( _response.error, _response.rawResponse, - "DELETE", - "/conversations/{conversation_id}/customers/{contact_id}", + "GET", + "/conversations/{id}/hitl_events", ); } /** - * List all pause/resume events for a conversation. These events track when teammates paused or resumed handling a conversation. + * List side conversations for a given conversation. Side conversations are internal threads created by teammates from within a conversation. + * + * Each side conversation includes its conversation parts (messages). Results are paginated. * * Requires the `read_conversations` OAuth scope. * - * @param {Intercom.unstable.ListHandlingEventsRequest} request + * @param {Intercom.preview.ListSideConversationsRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.conversations.listHandlingEvents({ - * id: "123" + * await client.preview.conversations.listSideConversations({ + * id: "123", + * page: 1, + * per_page: 1 * }) */ - public listHandlingEvents( - request: Intercom.unstable.ListHandlingEventsRequest, + public listSideConversations( + request: Intercom.preview.ListSideConversationsRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listHandlingEvents(request, requestOptions)); + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listSideConversations(request, requestOptions)); } - private async __listHandlingEvents( - request: Intercom.unstable.ListHandlingEventsRequest, + private async __listSideConversations( + request: Intercom.preview.ListSideConversationsRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id } = request; + ): Promise> { + const { id, page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -1201,11 +1302,11 @@ export class ConversationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}/handling_events`, + `conversations/${core.url.encodePathParam(id)}/side_conversations`, ), method: "GET", headers: _headers, - queryParameters: requestOptions?.queryParams, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1213,18 +1314,21 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.HandlingEventList, rawResponse: _response.rawResponse }; + return { + data: _response.body as Intercom.preview.SideConversationList, + rawResponse: _response.rawResponse, + }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -1238,49 +1342,44 @@ export class ConversationsClient { _response.error, _response.rawResponse, "GET", - "/conversations/{id}/handling_events", + "/conversations/{id}/side_conversations", ); } /** - * You can redact a conversation part or the source message of a conversation (as seen in the source object). + * Merge a secondary (source) conversation into a primary (target) conversation. + * The secondary conversation is closed and linked to the primary, which + * becomes the surviving thread. Returns the primary conversation on success. * - * {% admonition type="info" name="Redacting parts and messages" %} - * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. - * {% /admonition %} + * Requires `write_conversations` OAuth scope. When the secondary is a ticket, + * `write_tickets` scope is also required. * - * - * @param {Intercom.unstable.RedactConversationRequest} request + * @param {Intercom.preview.MergeConversationsRequestBody} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.conversations.redactConversation({ - * type: "conversation_part", - * conversation_id: "19894788788", - * conversation_part_id: "19381789428" - * }) + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.conversations.redactConversation({ - * type: "conversation_part", - * conversation_id: "really_123_doesnt_exist", - * conversation_part_id: "really_123_doesnt_exist" + * await client.preview.conversations.mergeConversation({ + * id: "123", + * merge_into_conversation_id: 456 * }) */ - public redactConversation( - request: Intercom.unstable.RedactConversationRequest, + public mergeConversation( + request: Intercom.preview.MergeConversationsRequestBody, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__redactConversation(request, requestOptions)); + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__mergeConversation(request, requestOptions)); } - private async __redactConversation( - request: Intercom.unstable.RedactConversationRequest, + private async __mergeConversation( + request: Intercom.preview.MergeConversationsRequestBody, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { + const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -1293,14 +1392,14 @@ export class ConversationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "conversations/redact", + `conversations/${core.url.encodePathParam(id)}/merge`, ), method: "POST", headers: _headers, contentType: "application/json", queryParameters: requestOptions?.queryParams, requestType: "json", - body: request, + body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1308,18 +1407,28 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -1329,40 +1438,40 @@ export class ConversationsClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/redact"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/{id}/merge"); } /** * You can convert a conversation to a ticket. * - * @param {Intercom.unstable.ConvertConversationToTicketRequest} request + * @param {Intercom.preview.ConvertConversationToTicketRequest} request * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.preview.BadRequestError} * * @example - * await client.unstable.conversations.convertConversationToTicket({ + * await client.preview.conversations.convertConversationToTicket({ * id: 1, * ticket_type_id: "53" * }) * * @example - * await client.unstable.conversations.convertConversationToTicket({ + * await client.preview.conversations.convertConversationToTicket({ * id: 1, * ticket_type_id: "54" * }) */ public convertConversationToTicket( - request: Intercom.unstable.ConvertConversationToTicketRequest, + request: Intercom.preview.ConvertConversationToTicketRequest, requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__convertConversationToTicket(request, requestOptions)); } private async __convertConversationToTicket( - request: Intercom.unstable.ConvertConversationToTicketRequest, + request: Intercom.preview.ConvertConversationToTicketRequest, requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -1391,13 +1500,13 @@ export class ConversationsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Ticket | undefined, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Ticket | undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -1409,4 +1518,100 @@ export class ConversationsClient { return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/{id}/convert"); } + + /** + * List all deleted conversation IDs. + * + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is `20` results per page. You can navigate to next pages using the `page` param. + * {% /admonition %} + * + * @param {Intercom.preview.ListDeletedConversationIdsRequest} request + * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.conversations.listDeletedConversationIds({ + * page: 1, + * per_page: 1, + * order: "desc" + * }) + */ + public listDeletedConversationIds( + request: Intercom.preview.ListDeletedConversationIdsRequest = {}, + requestOptions?: ConversationsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listDeletedConversationIds(request, requestOptions)); + } + + private async __listDeletedConversationIds( + request: Intercom.preview.ListDeletedConversationIdsRequest = {}, + requestOptions?: ConversationsClient.RequestOptions, + ): Promise> { + const { page, per_page: perPage, order } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (order != null) { + _queryParams.order = order; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations/deleted", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.DeletedConversationList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/conversations/deleted"); + } } diff --git a/src/api/resources/unstable/resources/emails/client/index.ts b/src/api/resources/preview/resources/conversations/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/emails/client/index.ts rename to src/api/resources/preview/resources/conversations/client/index.ts diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts similarity index 76% rename from src/api/resources/unstable/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts rename to src/api/resources/preview/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts index 5985d835..87b2857f 100644 --- a/src/api/resources/unstable/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts +++ b/src/api/resources/preview/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts @@ -20,5 +20,7 @@ export interface ConvertConversationToTicketRequest { id: number; /** The ID of the type of ticket you want to convert the conversation to */ ticket_type_id: string; - attributes?: Intercom.unstable.TicketRequestCustomAttributes; + /** The ID of the ticket state associated with the ticket type. */ + ticket_state_id?: string; + attributes?: Intercom.preview.TicketRequestCustomAttributes; } diff --git a/src/api/resources/unstable/resources/conversations/client/requests/CreateConversationRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/CreateConversationRequest.ts similarity index 77% rename from src/api/resources/unstable/resources/conversations/client/requests/CreateConversationRequest.ts rename to src/api/resources/preview/resources/conversations/client/requests/CreateConversationRequest.ts index 0f8bcd9a..701cf274 100644 --- a/src/api/resources/unstable/resources/conversations/client/requests/CreateConversationRequest.ts +++ b/src/api/resources/preview/resources/conversations/client/requests/CreateConversationRequest.ts @@ -7,7 +7,8 @@ * type: "user", * id: "6762f11b1bb69f9f2193bba3" * }, - * body: "Hello there" + * body: "Hello there", + * brand_id: "123" * } * * @example @@ -23,8 +24,14 @@ export interface CreateConversationRequest { from: CreateConversationRequest.From; /** The content of the message. HTML is not supported. */ body: string; + /** The title of the email. Only applicable if the message type is email. */ + subject?: string; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; /** The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom. */ created_at?: number; + /** The unique identifier of the brand to associate with this conversation. */ + brand_id?: string; } export namespace CreateConversationRequest { diff --git a/src/api/resources/preview/resources/conversations/client/requests/DeleteConversationRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/DeleteConversationRequest.ts new file mode 100644 index 00000000..bec6dd0c --- /dev/null +++ b/src/api/resources/preview/resources/conversations/client/requests/DeleteConversationRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1, + * retain_metrics: true + * } + */ +export interface DeleteConversationRequest { + /** id */ + id: number; + /** If true (default), deletes the conversation while retaining reporting data. If false, deletes the conversation and all associated reporting data. Setting to false requires the `delete_conversations_and_metrics` OAuth scope. */ + retain_metrics?: boolean; +} diff --git a/src/api/resources/preview/resources/conversations/client/requests/ListConversationsRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/ListConversationsRequest.ts new file mode 100644 index 00000000..53e85455 --- /dev/null +++ b/src/api/resources/preview/resources/conversations/client/requests/ListConversationsRequest.ts @@ -0,0 +1,29 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * per_page: 1, + * starting_after: "starting_after", + * include_monitors: true, + * include_scorecards: true + * } + * + * @example + * { + * per_page: 1, + * starting_after: "starting_after", + * include_monitors: true, + * include_scorecards: true + * } + */ +export interface ListConversationsRequest { + /** How many results per page */ + per_page?: number; + /** String used to get the next page of conversations. */ + starting_after?: string; + /** If set to true, the response will include a `monitor_evaluations` array on each conversation with any QA monitor results that flagged it. */ + include_monitors?: boolean; + /** If set to true, the response will include a `scorecards` array on each conversation with any QA scorecard results. */ + include_scorecards?: boolean; +} diff --git a/src/api/resources/preview/resources/conversations/client/requests/ListDeletedConversationIdsRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/ListDeletedConversationIdsRequest.ts new file mode 100644 index 00000000..2c87a4ff --- /dev/null +++ b/src/api/resources/preview/resources/conversations/client/requests/ListDeletedConversationIdsRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * page: 1, + * per_page: 1, + * order: "desc" + * } + */ +export interface ListDeletedConversationIdsRequest { + /** The page of results to fetch. Defaults to first page */ + page?: number; + /** How many results per page */ + per_page?: number; + /** `asc` or `desc`. Returns the conversation IDs in ascending or descending order. Defaults to desc */ + order?: string; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ListHandlingEventsRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/ListHandlingEventsRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/conversations/client/requests/ListHandlingEventsRequest.ts rename to src/api/resources/preview/resources/conversations/client/requests/ListHandlingEventsRequest.ts diff --git a/src/api/resources/preview/resources/conversations/client/requests/ListHitlEventsRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/ListHitlEventsRequest.ts new file mode 100644 index 00000000..bc1ffc28 --- /dev/null +++ b/src/api/resources/preview/resources/conversations/client/requests/ListHitlEventsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123" + * } + */ +export interface ListHitlEventsRequest { + /** The identifier for the conversation as given by Intercom. */ + id: string; +} diff --git a/src/api/resources/preview/resources/conversations/client/requests/ListSideConversationsRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/ListSideConversationsRequest.ts new file mode 100644 index 00000000..4f00abfc --- /dev/null +++ b/src/api/resources/preview/resources/conversations/client/requests/ListSideConversationsRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123", + * page: 1, + * per_page: 1 + * } + */ +export interface ListSideConversationsRequest { + /** The identifier for the conversation as given by Intercom. */ + id: string; + /** The page number of results to return (starting from 1). */ + page?: number; + /** The number of side conversations to return per page (max 50). */ + per_page?: number; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ManageConversationRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/ManageConversationRequest.ts similarity index 95% rename from src/api/resources/unstable/resources/conversations/client/requests/ManageConversationRequest.ts rename to src/api/resources/preview/resources/conversations/client/requests/ManageConversationRequest.ts index 54ff3cf5..d6d39c25 100644 --- a/src/api/resources/unstable/resources/conversations/client/requests/ManageConversationRequest.ts +++ b/src/api/resources/preview/resources/conversations/client/requests/ManageConversationRequest.ts @@ -56,5 +56,5 @@ import type * as Intercom from "../../../../../../index.js"; export interface ManageConversationRequest { /** The identifier for the conversation as given by Intercom. */ id: string; - body: Intercom.unstable.ManageConversationRequestBody; + body: Intercom.preview.ManageConversationRequestBody; } diff --git a/src/api/resources/preview/resources/conversations/client/requests/MergeConversationsRequestBody.ts b/src/api/resources/preview/resources/conversations/client/requests/MergeConversationsRequestBody.ts new file mode 100644 index 00000000..c6725beb --- /dev/null +++ b/src/api/resources/preview/resources/conversations/client/requests/MergeConversationsRequestBody.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123", + * merge_into_conversation_id: 456 + * } + */ +export interface MergeConversationsRequestBody { + /** The identifier for the secondary (source) conversation to merge away. */ + id: string; + /** The ID of the primary (target) conversation to merge into. */ + merge_into_conversation_id: number; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ReplyConversationRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/ReplyConversationRequest.ts similarity index 97% rename from src/api/resources/unstable/resources/conversations/client/requests/ReplyConversationRequest.ts rename to src/api/resources/preview/resources/conversations/client/requests/ReplyConversationRequest.ts index 3653ec6d..f5d0f854 100644 --- a/src/api/resources/unstable/resources/conversations/client/requests/ReplyConversationRequest.ts +++ b/src/api/resources/preview/resources/conversations/client/requests/ReplyConversationRequest.ts @@ -71,5 +71,5 @@ import type * as Intercom from "../../../../../../index.js"; export interface ReplyConversationRequest { /** The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation */ id: string; - body: Intercom.unstable.ReplyConversationRequestBody; + body: Intercom.preview.ReplyConversationRequestBody; } diff --git a/src/api/resources/preview/resources/conversations/client/requests/RetrieveConversationRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/RetrieveConversationRequest.ts new file mode 100644 index 00000000..3adcebd4 --- /dev/null +++ b/src/api/resources/preview/resources/conversations/client/requests/RetrieveConversationRequest.ts @@ -0,0 +1,51 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1, + * display_as: "plaintext", + * include_translations: true, + * include_email_history: true, + * include_monitors: true, + * include_scorecards: true + * } + * + * @example + * { + * id: 1, + * display_as: "plaintext", + * include_translations: true, + * include_email_history: true, + * include_monitors: true, + * include_scorecards: true + * } + * + * @example + * { + * id: 1, + * display_as: "plaintext", + * include_translations: true, + * include_email_history: true, + * include_monitors: true, + * include_scorecards: true + * } + */ +export interface RetrieveConversationRequest { + /** The id of the conversation to target */ + id: number; + /** Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. Inline links are rendered as `label (url)`, preserving the link URL alongside the visible text. */ + display_as?: string; + /** If set to true, conversation parts will be translated to the detected language of the conversation. */ + include_translations?: boolean; + /** If set to true, the source of the conversation will include the email history. */ + include_email_history?: boolean; + /** If set to true, the response will include a `monitor_evaluations` array with any QA monitor results that flagged this conversation. */ + include_monitors?: boolean; + /** If set to true, the response will include a `scorecards` array with any QA scorecard results for this conversation. */ + include_scorecards?: boolean; + /** A comma-separated list of conversation part types to keep; only parts of these types are returned. Values are the names this version returns in a part's `part_type` field, such as `assignment`, `note` or `snoozed`; an unrecognised name returns a 422 rather than being silently ignored, so a typo fails loudly instead of filtering nothing. Two names need care — a part type this version does not recognise is returned as `unknown`, and `unknown` is not itself an accepted filter value, so those parts are removed by naming the types you do want rather than by filtering them out directly; and the part type that versions below 2.6 return as `note_and_reopen` is named `note_and_unsnooze` here. Up to 50 values are accepted, and `include_part_types` cannot be combined with `exclude_part_types`; both cases return a 422. Supply one comma-separated value; repeating the parameter is not read as a combined list, and only the last occurrence is used. The filter is applied before the conversation parts limit, so the newest matching parts are returned. Available on the Preview version; a 422 is returned on any other version. */ + include_part_types?: string | string[]; + /** A comma-separated list of conversation part types to drop; parts of these types are omitted and all others are returned. Values are the names this version returns in a part's `part_type` field, such as `assignment`, `note` or `snoozed`; an unrecognised name returns a 422 rather than being silently ignored, so a typo fails loudly instead of filtering nothing. Two names need care — a part type this version does not recognise is returned as `unknown`, and `unknown` is not itself an accepted filter value, so those parts are removed by naming the types you do want rather than by filtering them out directly; and the part type that versions below 2.6 return as `note_and_reopen` is named `note_and_unsnooze` here. Up to 50 values are accepted, and `include_part_types` cannot be combined with `exclude_part_types`; both cases return a 422. Supply one comma-separated value; repeating the parameter is not read as a combined list, and only the last occurrence is used. The filter is applied before the conversation parts limit, so the newest matching parts are returned. Available on the Preview version; a 422 is returned on any other version. */ + exclude_part_types?: string | string[]; +} diff --git a/src/api/resources/preview/resources/conversations/client/requests/SearchConversationsRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/SearchConversationsRequest.ts new file mode 100644 index 00000000..6e510662 --- /dev/null +++ b/src/api/resources/preview/resources/conversations/client/requests/SearchConversationsRequest.ts @@ -0,0 +1,50 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * include_monitors: true, + * include_scorecards: true, + * body: { + * query: { + * operator: "AND", + * value: [{ + * field: "created_at", + * operator: ">", + * value: "1306054154" + * }] + * }, + * pagination: { + * per_page: 5 + * } + * } + * } + * + * @example + * { + * include_monitors: true, + * include_scorecards: true, + * body: { + * query: { + * operator: "AND", + * value: [{ + * field: "created_at", + * operator: ">", + * value: "1306054154" + * }] + * }, + * pagination: { + * per_page: 5 + * } + * } + * } + */ +export interface SearchConversationsRequest { + /** If set to true, the response will include a `monitor_evaluations` array on each conversation with any QA monitor results that flagged it. */ + include_monitors?: boolean; + /** If set to true, the response will include a `scorecards` array on each conversation with any QA scorecard results. */ + include_scorecards?: boolean; + body: Intercom.preview.SearchRequest; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts b/src/api/resources/preview/resources/conversations/client/requests/UpdateConversationRequest.ts similarity index 50% rename from src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts rename to src/api/resources/preview/resources/conversations/client/requests/UpdateConversationRequest.ts index 9e2a3dea..1ce02f6d 100644 --- a/src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts +++ b/src/api/resources/preview/resources/conversations/client/requests/UpdateConversationRequest.ts @@ -9,9 +9,10 @@ import type * as Intercom from "../../../../../../index.js"; * display_as: "plaintext", * read: true, * title: "new conversation title", + * priority: "high", + * admin_id: "394051", * custom_attributes: { - * "issue_type": "Billing", - * "priority": "High" + * "issue_type": "Billing" * } * } * @@ -30,22 +31,39 @@ import type * as Intercom from "../../../../../../index.js"; * display_as: "plaintext", * read: true, * title: "new conversation title", + * priority: "high", + * admin_id: "394051", * custom_attributes: { - * "issue_type": "Billing", - * "priority": "High" + * "issue_type": "Billing" * } * } */ export interface UpdateConversationRequest { /** The id of the conversation to target */ id: number; - /** Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. */ + /** Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. Inline links are rendered as `label (url)`, preserving the link URL alongside the visible text. */ display_as?: string; /** Mark a conversation as read within Intercom. */ read?: boolean; /** The title given to the conversation */ title?: string; - custom_attributes?: Intercom.unstable.CustomAttributes; + /** The priority level to set on the conversation. Accepts one of none, low, medium, high, or urgent. Set none to clear an existing priority. */ + priority?: UpdateConversationRequest.Priority; + /** The ID of the teammate to attribute the priority change to. Defaults to Operator when omitted, and is only used alongside priority. */ + admin_id?: string; + custom_attributes?: Intercom.preview.CustomAttributes; /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. */ company_id?: string; } + +export namespace UpdateConversationRequest { + /** The priority level to set on the conversation. Accepts one of none, low, medium, high, or urgent. Set none to clear an existing priority. */ + export const Priority = { + None: "none", + Low: "low", + Medium: "medium", + High: "high", + Urgent: "urgent", + } as const; + export type Priority = (typeof Priority)[keyof typeof Priority]; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/index.ts b/src/api/resources/preview/resources/conversations/client/requests/index.ts similarity index 63% rename from src/api/resources/unstable/resources/conversations/client/requests/index.ts rename to src/api/resources/preview/resources/conversations/client/requests/index.ts index 3733a95d..efbf5336 100644 --- a/src/api/resources/unstable/resources/conversations/client/requests/index.ts +++ b/src/api/resources/preview/resources/conversations/client/requests/index.ts @@ -1,11 +1,14 @@ -export type { AttachContactToConversationRequest } from "./AttachContactToConversationRequest.js"; export type { ConvertConversationToTicketRequest } from "./ConvertConversationToTicketRequest.js"; export type { CreateConversationRequest } from "./CreateConversationRequest.js"; export type { DeleteConversationRequest } from "./DeleteConversationRequest.js"; -export type { DetachContactFromConversationRequest } from "./DetachContactFromConversationRequest.js"; export type { ListConversationsRequest } from "./ListConversationsRequest.js"; +export type { ListDeletedConversationIdsRequest } from "./ListDeletedConversationIdsRequest.js"; export type { ListHandlingEventsRequest } from "./ListHandlingEventsRequest.js"; +export type { ListHitlEventsRequest } from "./ListHitlEventsRequest.js"; +export type { ListSideConversationsRequest } from "./ListSideConversationsRequest.js"; export type { ManageConversationRequest } from "./ManageConversationRequest.js"; +export type { MergeConversationsRequestBody } from "./MergeConversationsRequestBody.js"; export type { ReplyConversationRequest } from "./ReplyConversationRequest.js"; export type { RetrieveConversationRequest } from "./RetrieveConversationRequest.js"; +export type { SearchConversationsRequest } from "./SearchConversationsRequest.js"; export type { UpdateConversationRequest } from "./UpdateConversationRequest.js"; diff --git a/src/api/resources/unstable/resources/emails/index.ts b/src/api/resources/preview/resources/conversations/index.ts similarity index 100% rename from src/api/resources/unstable/resources/emails/index.ts rename to src/api/resources/preview/resources/conversations/index.ts diff --git a/src/api/resources/preview/resources/conversations/types/index.ts b/src/api/resources/preview/resources/conversations/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/conversations/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/conversations/types/types.ts b/src/api/resources/preview/resources/conversations/types/types.ts new file mode 100644 index 00000000..f916c02d --- /dev/null +++ b/src/api/resources/preview/resources/conversations/types/types.ts @@ -0,0 +1,342 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +export type ManageConversationRequestBody = + | Intercom.preview.ManageConversationRequestBody.Close + | Intercom.preview.ManageConversationRequestBody.Snoozed + | Intercom.preview.ManageConversationRequestBody.Open + | Intercom.preview.ManageConversationRequestBody.Assignment; + +export namespace ManageConversationRequestBody { + export interface Close extends Intercom.preview.CloseConversationRequest { + message_type: "close"; + } + + export interface Snoozed extends Intercom.preview.SnoozeConversationRequest { + message_type: "snoozed"; + } + + export interface Open extends Intercom.preview.OpenConversationRequest { + message_type: "open"; + } + + export interface Assignment extends Intercom.preview.AssignConversationRequest { + message_type: "assignment"; + } +} + +/** + * The data returned about your conversations when you list or search them. + */ +export interface ConversationListItem { + /** Always conversation. */ + type?: string; + /** The id representing the conversation. */ + id?: string; + /** The title given to the conversation. */ + title?: string; + /** The time the conversation was created. */ + created_at?: number; + /** The last time the conversation was updated. */ + updated_at?: number; + /** The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. */ + waiting_since?: number; + /** If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. */ + snoozed_until?: number; + /** Indicates whether a conversation is open (true) or closed (false). */ + open?: boolean; + /** Can be set to "open", "closed" or "snoozed". */ + state?: ConversationListItem.State; + /** Indicates whether a conversation has been read. */ + read?: boolean; + /** The priority level of the conversation. Returns one of none, low, medium, high, or urgent. */ + priority?: ConversationListItem.Priority; + /** The id of the admin assigned to the conversation. If it's not assigned to an admin it will return 0. */ + admin_assignee_id?: number; + /** The id of the team assigned to the conversation. If it's not assigned to a team it will return 0. */ + team_assignee_id?: number; + /** The company associated with the conversation. */ + company?: Intercom.preview.Company; + tags?: Intercom.preview.Tags; + conversation_rating?: Intercom.preview.ConversationRating; + source?: Intercom.preview.ConversationSource; + contacts?: Intercom.preview.ConversationContacts; + teammates?: Intercom.preview.ConversationTeammates; + custom_attributes?: Intercom.preview.CustomAttributes; + first_contact_reply?: Intercom.preview.ConversationFirstContactReply; + sla_applied?: Intercom.preview.SlaApplied; + statistics?: Intercom.preview.ConversationStatistics; + linked_objects?: Intercom.preview.LinkedObjectList; + /** Indicates whether the AI Agent participated in the conversation. */ + ai_agent_participated?: boolean; + ai_agent?: Intercom.preview.AiAgent; + /** Indicates whether the Sales Agent participated in the conversation. */ + sales_agent_participated?: boolean; + sales_agent?: Intercom.preview.SalesAgent; + /** The channel through which the conversation was initiated and its current channel. */ + channel?: Intercom.preview.ConversationChannel; + /** References linking this conversation to records in an external helpdesk or CRM system. Populated for Fin Standalone workspaces synced from an external platform; an empty array otherwise. Sorted alphabetically by `type` and capped at 20 entries. */ + external_references?: Intercom.preview.ConversationExternalReference[]; + /** QA monitor evaluations that flagged this conversation. Only included when `include_monitors=true` is passed as a query parameter. */ + monitor_evaluations?: Intercom.preview.ConversationMonitorEvaluation[]; + /** QA scorecard results for this conversation. Only included when `include_scorecards=true` is passed as a query parameter. */ + scorecards?: Intercom.preview.ConversationScorecard[]; +} + +export namespace ConversationListItem { + /** Can be set to "open", "closed" or "snoozed". */ + export const State = { + Open: "open", + Closed: "closed", + Snoozed: "snoozed", + } as const; + export type State = (typeof State)[keyof typeof State]; + /** The priority level of the conversation. Returns one of none, low, medium, high, or urgent. */ + export const Priority = { + None: "none", + Low: "low", + Medium: "medium", + High: "high", + Urgent: "urgent", + } as const; + export type Priority = (typeof Priority)[keyof typeof Priority]; +} + +/** + * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. + */ +export interface Conversation { + /** Always conversation. */ + type?: string; + /** The id representing the conversation. */ + id?: string; + /** The title given to the conversation. */ + title?: string; + /** The time the conversation was created. */ + created_at?: number; + /** The last time the conversation was updated. */ + updated_at?: number; + /** The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. */ + waiting_since?: number; + /** If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. */ + snoozed_until?: number; + /** Indicates whether a conversation is open (true) or closed (false). */ + open?: boolean; + /** Can be set to "open", "closed" or "snoozed". */ + state?: Conversation.State; + /** Indicates whether a conversation has been read. */ + read?: boolean; + /** The priority level of the conversation. Returns one of none, low, medium, high, or urgent. */ + priority?: Conversation.Priority; + /** The id of the admin assigned to the conversation. If it's not assigned to an admin it will return 0. */ + admin_assignee_id?: number; + /** The id of the team assigned to the conversation. If it's not assigned to a team it will return 0. */ + team_assignee_id?: number; + /** The company associated with the conversation. */ + company?: Intercom.preview.Company; + tags?: Intercom.preview.Tags; + conversation_rating?: Intercom.preview.ConversationRating; + source?: Intercom.preview.ConversationSource; + contacts?: Intercom.preview.ConversationContacts; + teammates?: Intercom.preview.ConversationTeammates; + custom_attributes?: Intercom.preview.CustomAttributes; + first_contact_reply?: Intercom.preview.ConversationFirstContactReply; + sla_applied?: Intercom.preview.SlaApplied; + statistics?: Intercom.preview.ConversationStatistics; + conversation_parts?: Intercom.preview.ConversationParts; + linked_objects?: Intercom.preview.LinkedObjectList; + ai_topics?: Intercom.preview.AiTopics; + /** Indicates whether the AI Agent participated in the conversation. */ + ai_agent_participated?: boolean; + ai_agent?: Intercom.preview.AiAgent; + /** Indicates whether the Sales Agent participated in the conversation. */ + sales_agent_participated?: boolean; + sales_agent?: Intercom.preview.SalesAgent; + /** The channel through which the conversation was initiated and its current channel. */ + channel?: Intercom.preview.ConversationChannel; + /** References linking this conversation to records in an external helpdesk or CRM system. Populated for Fin Standalone workspaces synced from an external platform; an empty array otherwise. Sorted alphabetically by `type` and capped at 20 entries. */ + external_references?: Intercom.preview.ConversationExternalReference[]; + /** QA monitor evaluations that flagged this conversation. Only included when `include_monitors=true` is passed as a query parameter. */ + monitor_evaluations?: Intercom.preview.ConversationMonitorEvaluation[]; + /** QA scorecard results for this conversation. Only included when `include_scorecards=true` is passed as a query parameter. */ + scorecards?: Intercom.preview.ConversationScorecard[]; +} + +export namespace Conversation { + /** Can be set to "open", "closed" or "snoozed". */ + export const State = { + Open: "open", + Closed: "closed", + Snoozed: "snoozed", + } as const; + export type State = (typeof State)[keyof typeof State]; + /** The priority level of the conversation. Returns one of none, low, medium, high, or urgent. */ + export const Priority = { + None: "none", + Low: "low", + Medium: "medium", + High: "high", + Urgent: "urgent", + } as const; + export type Priority = (typeof Priority)[keyof typeof Priority]; +} + +/** + * A QA monitor evaluation that flagged this conversation. Returned in the `monitor_evaluations` array on conversation responses when `include_monitors=true` is passed. + */ +export interface ConversationMonitorEvaluation { + /** The unique identifier of the monitor that produced this evaluation. */ + monitor_id?: string; + /** The name of the monitor at the time of evaluation. Null if the monitor has since been deleted. */ + monitor_name?: string; + /** The type of the monitor. Null if the monitor has since been deleted. */ + monitor_type?: string; + /** The evaluation outcome reported by the monitor. */ + result?: string; + /** The reasoning provided by the monitor for its result. May be null if no reasoning was generated. */ + explanation?: string; + /** The time the monitor evaluated this conversation. Null in the rare case the underlying record's timestamp is not yet set. */ + evaluated_at?: number; +} + +/** + * A QA scorecard result for this conversation. Returned in the `scorecards` array on conversation responses when `include_scorecards=true` is passed. + */ +export interface ConversationScorecard { + /** The unique identifier of the scorecard definition. */ + scorecard_id?: string; + /** The unique identifier of the specific scorecard version that produced this result. */ + scorecard_version_id?: string; + /** The name of the scorecard. */ + name?: string; + /** The type of scorecard. */ + scorecard_type?: string; + /** Whether the conversation passed the scorecard. Null when the scorecard has not been scored. */ + passed?: boolean; + /** The numeric score for the scorecard. Null when the scorecard has not been scored. */ + score?: number; + /** The numeric score produced by AI evaluation, if applicable. Null when not AI-scored. */ + ai_score?: number; + /** The time the scorecard was last evaluated. Null in the rare case the underlying record's timestamp is not yet set. */ + evaluated_at?: number; + reviewed_teammate?: Intercom.preview.ConversationScorecardReviewedTeammate; + reviewer?: Intercom.preview.ConversationScorecardReviewer; + /** The status of the review of this scorecard, as shown in the QA reviews list in Intercom. `unreviewed` while the review is waiting for a reviewer's verdict; `submitted` once the review has been submitted; `passed_review`, `needs_fix`, `wont_fix` or `fix_complete` when a teammate set a specific outcome. Null when no review exists for this scorecard. */ + review_status?: ConversationScorecard.ReviewStatus; + /** The notes teammates left on the QA review linked to this scorecard entry. Empty when the scorecard has no linked review. */ + notes?: Intercom.preview.ConversationScorecardNote[]; + /** Per-evaluator results within this scorecard. */ + evaluators?: Intercom.preview.ConversationScorecardEvaluator[]; +} + +export namespace ConversationScorecard { + /** The status of the review of this scorecard, as shown in the QA reviews list in Intercom. `unreviewed` while the review is waiting for a reviewer's verdict; `submitted` once the review has been submitted; `passed_review`, `needs_fix`, `wont_fix` or `fix_complete` when a teammate set a specific outcome. Null when no review exists for this scorecard. */ + export const ReviewStatus = { + Unreviewed: "unreviewed", + Submitted: "submitted", + PassedReview: "passed_review", + NeedsFix: "needs_fix", + WontFix: "wont_fix", + FixComplete: "fix_complete", + } as const; + export type ReviewStatus = (typeof ReviewStatus)[keyof typeof ReviewStatus]; +} + +/** + * Who reviewed this scorecard. `ai` when Fin auto-reviewed it; `admin` when a teammate did. Null when no review exists for this scorecard or no reviewer has been assigned yet. + */ +export interface ConversationScorecardReviewer { + /** The kind of reviewer. `ai` if Fin auto-reviewed the scorecard; `admin` if a teammate reviewed it. */ + type?: ConversationScorecardReviewer.Type; + /** The id of the admin who reviewed the scorecard. Present only when `type` is `admin`. */ + admin_id?: string; +} + +export namespace ConversationScorecardReviewer { + /** The kind of reviewer. `ai` if Fin auto-reviewed the scorecard; `admin` if a teammate reviewed it. */ + export const Type = { + Ai: "ai", + Admin: "admin", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * A note a teammate left on the QA review of this scorecard. + */ +export interface ConversationScorecardNote { + /** The id of the note. */ + id?: string; + /** The time the note was created. */ + created_at?: number; + /** The time the note was last edited. Equal to `created_at` when the note has never been edited. */ + updated_at?: number; + author?: Intercom.preview.ConversationScorecardNoteAuthor; + /** The text of the note exactly as the teammate entered it. Plain text; it is not rendered as HTML. */ + body?: string; +} + +/** + * Who wrote the note. Null when the teammate who wrote it has since been deleted. + */ +export interface ConversationScorecardNoteAuthor { + /** The kind of author. `admin` when a teammate wrote the note; `ai` when Fin did. */ + type?: ConversationScorecardNoteAuthor.Type; + /** The id of the admin who wrote the note. Present only when `type` is `admin`. */ + admin_id?: string; +} + +export namespace ConversationScorecardNoteAuthor { + /** The kind of author. `admin` when a teammate wrote the note; `ai` when Fin did. */ + export const Type = { + Ai: "ai", + Admin: "admin", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * The teammate (or AI agent) whose handling of the conversation was reviewed by this scorecard. + */ +export interface ConversationScorecardReviewedTeammate { + /** The kind of reviewee. `ai` if the conversation was handled by Fin or scored without a specific teammate; `admin` if a specific teammate was reviewed. */ + type?: ConversationScorecardReviewedTeammate.Type; + /** The id of the admin who was reviewed. Present only when `type` is `admin`. */ + admin_id?: string; +} + +export namespace ConversationScorecardReviewedTeammate { + /** The kind of reviewee. `ai` if the conversation was handled by Fin or scored without a specific teammate; `admin` if a specific teammate was reviewed. */ + export const Type = { + Ai: "ai", + Admin: "admin", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * A single evaluator within a scorecard, including its result for this conversation. + */ +export interface ConversationScorecardEvaluator { + /** The unique identifier of the evaluator (criterion) within the scorecard. */ + evaluator_id?: string; + /** The evaluator's result for this conversation. Null if the evaluator was not scored. */ + result?: Intercom.preview.ConversationScorecardEvaluatorResult; +} + +/** + * The outcome of a single evaluator within a scorecard. + */ +export interface ConversationScorecardEvaluatorResult { + /** The evaluator's selected value (typically a label such as `pass`, `fail`, or a category identifier). */ + value?: string; + /** The origin of the result (for example, `ai` or `human`). */ + source?: string; + /** A free-text explanation of the result. */ + reasoning?: string; + /** Identifiers for structured reasons assigned to the result, if any. */ + reason_ids?: string[]; + /** Free-text entered by the reviewer to supplement or stand in for the structured `reason_ids` — typically captured when the reviewer selects an "Other" option or adds a custom note. Null when not provided. */ + other_text?: string; +} diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/Client.ts b/src/api/resources/preview/resources/conversationsAttributes/client/Client.ts new file mode 100644 index 00000000..955fd412 --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/Client.ts @@ -0,0 +1,716 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace ConversationsAttributesClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Manage custom attributes for conversations + */ +export class ConversationsAttributesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ConversationsAttributesClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * You can fetch a list of all conversation attributes for your workspace. + * + * @param {Intercom.preview.ListConversationAttributesRequest} request + * @param {ConversationsAttributesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.conversationsAttributes.listConversationAttributes({ + * include_archived: true + * }) + */ + public listConversationAttributes( + request: Intercom.preview.ListConversationAttributesRequest = {}, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listConversationAttributes(request, requestOptions)); + } + + private async __listConversationAttributes( + request: Intercom.preview.ListConversationAttributesRequest = {}, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): Promise> { + const { include_archived: includeArchived } = request; + const _queryParams: Record = {}; + if (includeArchived != null) { + _queryParams.include_archived = includeArchived.toString(); + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations/attributes", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationAttributeList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/conversations/attributes"); + } + + /** + * Create a new conversation attribute. + * + * @param {Intercom.preview.CreateConversationAttributeRequest} request + * @param {ConversationsAttributesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.conversationsAttributes.createConversationAttribute({ + * data_type: "string", + * name: "api_test_attr" + * }) + */ + public createConversationAttribute( + request: Intercom.preview.CreateConversationAttributeRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createConversationAttribute(request, requestOptions)); + } + + private async __createConversationAttribute( + request: Intercom.preview.CreateConversationAttributeRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations/attributes", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationAttribute, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/attributes"); + } + + /** + * Retrieve a single conversation attribute by ID. + * + * @param {Intercom.preview.GetConversationAttributeRequest} request + * @param {ConversationsAttributesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.conversationsAttributes.getConversationAttribute({ + * id: 1 + * }) + */ + public getConversationAttribute( + request: Intercom.preview.GetConversationAttributeRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getConversationAttribute(request, requestOptions)); + } + + private async __getConversationAttribute( + request: Intercom.preview.GetConversationAttributeRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/attributes/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationAttribute, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/conversations/attributes/{id}", + ); + } + + /** + * Update an existing conversation attribute. + * + * @param {Intercom.preview.UpdateConversationAttributeRequest} request + * @param {ConversationsAttributesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.conversationsAttributes.updateConversationAttribute({ + * id: 1, + * name: "api_test_renamed", + * description: "Updated via API" + * }) + */ + public updateConversationAttribute( + request: Intercom.preview.UpdateConversationAttributeRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateConversationAttribute(request, requestOptions)); + } + + private async __updateConversationAttribute( + request: Intercom.preview.UpdateConversationAttributeRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/attributes/${core.url.encodePathParam(id)}`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationAttribute, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PUT", + "/conversations/attributes/{id}", + ); + } + + /** + * Archive a conversation attribute (soft delete). The attribute is marked as archived but not permanently deleted. + * + * @param {Intercom.preview.DeleteConversationAttributeRequest} request + * @param {ConversationsAttributesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.conversationsAttributes.deleteConversationAttribute({ + * id: 1 + * }) + */ + public deleteConversationAttribute( + request: Intercom.preview.DeleteConversationAttributeRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteConversationAttribute(request, requestOptions)); + } + + private async __deleteConversationAttribute( + request: Intercom.preview.DeleteConversationAttributeRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/attributes/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationAttribute, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/conversations/attributes/{id}", + ); + } + + /** + * Add a new option to a list-type conversation attribute. Returns the full attribute with the updated options array. + * + * @param {Intercom.preview.CreateConversationAttributeOptionRequest} request + * @param {ConversationsAttributesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.conversationsAttributes.createConversationAttributeOption({ + * id: 1, + * body: { + * label: "High" + * } + * }) + */ + public createConversationAttributeOption( + request: Intercom.preview.CreateConversationAttributeOptionRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createConversationAttributeOption(request, requestOptions)); + } + + private async __createConversationAttributeOption( + request: Intercom.preview.CreateConversationAttributeOptionRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): Promise> { + const { id, body: _body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/attributes/${core.url.encodePathParam(id)}/options`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationAttribute, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/conversations/attributes/{id}/options", + ); + } + + /** + * Update the label of a single option on a list-type conversation attribute. Returns the full attribute with the updated options array. + * + * @param {Intercom.preview.UpdateConversationAttributeOptionRequest} request + * @param {ConversationsAttributesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.conversationsAttributes.updateConversationAttributeOption({ + * id: 1, + * option_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + * label: "Renamed" + * }) + */ + public updateConversationAttributeOption( + request: Intercom.preview.UpdateConversationAttributeOptionRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateConversationAttributeOption(request, requestOptions)); + } + + private async __updateConversationAttributeOption( + request: Intercom.preview.UpdateConversationAttributeOptionRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): Promise> { + const { id, option_id: optionId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/attributes/${core.url.encodePathParam(id)}/options/${core.url.encodePathParam(optionId)}`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationAttribute, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PUT", + "/conversations/attributes/{id}/options/{option_id}", + ); + } + + /** + * Archive a single option on a list-type conversation attribute (soft delete). The option remains in the response with `archived: true`. Returns the full attribute with the updated options array. + * + * @param {Intercom.preview.DeleteConversationAttributeOptionRequest} request + * @param {ConversationsAttributesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.conversationsAttributes.deleteConversationAttributeOption({ + * id: 1, + * option_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" + * }) + */ + public deleteConversationAttributeOption( + request: Intercom.preview.DeleteConversationAttributeOptionRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteConversationAttributeOption(request, requestOptions)); + } + + private async __deleteConversationAttributeOption( + request: Intercom.preview.DeleteConversationAttributeOptionRequest, + requestOptions?: ConversationsAttributesClient.RequestOptions, + ): Promise> { + const { id, option_id: optionId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/attributes/${core.url.encodePathParam(id)}/options/${core.url.encodePathParam(optionId)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ConversationAttribute, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/conversations/attributes/{id}/options/{option_id}", + ); + } +} diff --git a/src/api/resources/unstable/resources/export/client/index.ts b/src/api/resources/preview/resources/conversationsAttributes/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/export/client/index.ts rename to src/api/resources/preview/resources/conversationsAttributes/client/index.ts diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/requests/CreateConversationAttributeOptionRequest.ts b/src/api/resources/preview/resources/conversationsAttributes/client/requests/CreateConversationAttributeOptionRequest.ts new file mode 100644 index 00000000..bbc0b565 --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/requests/CreateConversationAttributeOptionRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * id: 1, + * body: { + * label: "High" + * } + * } + */ +export interface CreateConversationAttributeOptionRequest { + /** The conversation attribute id */ + id: number; + body: Intercom.preview.CreateConversationAttributeOptionRequestBody; +} diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/requests/DeleteConversationAttributeOptionRequest.ts b/src/api/resources/preview/resources/conversationsAttributes/client/requests/DeleteConversationAttributeOptionRequest.ts new file mode 100644 index 00000000..b24ec61d --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/requests/DeleteConversationAttributeOptionRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1, + * option_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" + * } + */ +export interface DeleteConversationAttributeOptionRequest { + /** The conversation attribute id */ + id: number; + /** The UUID of the list option to archive (from the `id` field in the options array) */ + option_id: string; +} diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/requests/DeleteConversationAttributeRequest.ts b/src/api/resources/preview/resources/conversationsAttributes/client/requests/DeleteConversationAttributeRequest.ts new file mode 100644 index 00000000..37f47f52 --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/requests/DeleteConversationAttributeRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1 + * } + */ +export interface DeleteConversationAttributeRequest { + /** The conversation attribute id */ + id: number; +} diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/requests/GetConversationAttributeRequest.ts b/src/api/resources/preview/resources/conversationsAttributes/client/requests/GetConversationAttributeRequest.ts new file mode 100644 index 00000000..54232805 --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/requests/GetConversationAttributeRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1 + * } + */ +export interface GetConversationAttributeRequest { + /** The conversation attribute id */ + id: number; +} diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/requests/ListConversationAttributesRequest.ts b/src/api/resources/preview/resources/conversationsAttributes/client/requests/ListConversationAttributesRequest.ts new file mode 100644 index 00000000..025b7a0e --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/requests/ListConversationAttributesRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * include_archived: true + * } + */ +export interface ListConversationAttributesRequest { + /** Include archived attributes in the list. Default `false`. */ + include_archived?: boolean; +} diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/requests/UpdateConversationAttributeOptionRequest.ts b/src/api/resources/preview/resources/conversationsAttributes/client/requests/UpdateConversationAttributeOptionRequest.ts new file mode 100644 index 00000000..bfe32ce4 --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/requests/UpdateConversationAttributeOptionRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1, + * option_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + * label: "Renamed" + * } + */ +export interface UpdateConversationAttributeOptionRequest { + /** The conversation attribute id */ + id: number; + /** The UUID of the list option to update (from the `id` field in the options array) */ + option_id: string; + /** The updated label for the option. */ + label: string; +} diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/requests/UpdateConversationAttributeRequest.ts b/src/api/resources/preview/resources/conversationsAttributes/client/requests/UpdateConversationAttributeRequest.ts new file mode 100644 index 00000000..73a205c6 --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/requests/UpdateConversationAttributeRequest.ts @@ -0,0 +1,47 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1, + * name: "api_test_renamed", + * description: "Updated via API" + * } + */ +export interface UpdateConversationAttributeRequest { + /** The conversation attribute id */ + id: number; + /** Name of the attribute. */ + name?: string; + /** Readable description of the attribute. */ + description?: string; + /** (String data type only) Whether this string attribute is multiline. */ + multiline?: boolean; + /** Whether this attribute is required. */ + required?: boolean; + /** Team IDs that can see this attribute. Empty array means all teams. */ + visible_to_team_ids?: string[]; + /** (Relationship data type only) Reference configuration for related objects. */ + reference?: UpdateConversationAttributeRequest.Reference; +} + +export namespace UpdateConversationAttributeRequest { + /** + * (Relationship data type only) Reference configuration for related objects. + */ + export interface Reference { + /** The cardinality of the relationship: `one` or `many`. */ + type: Reference.Type; + /** The ID of the related custom object type. */ + object_type_id?: string; + } + + export namespace Reference { + /** The cardinality of the relationship: `one` or `many`. */ + export const Type = { + One: "one", + Many: "many", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } +} diff --git a/src/api/resources/preview/resources/conversationsAttributes/client/requests/index.ts b/src/api/resources/preview/resources/conversationsAttributes/client/requests/index.ts new file mode 100644 index 00000000..0e6d587d --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/client/requests/index.ts @@ -0,0 +1,7 @@ +export type { CreateConversationAttributeOptionRequest } from "./CreateConversationAttributeOptionRequest.js"; +export type { DeleteConversationAttributeOptionRequest } from "./DeleteConversationAttributeOptionRequest.js"; +export type { DeleteConversationAttributeRequest } from "./DeleteConversationAttributeRequest.js"; +export type { GetConversationAttributeRequest } from "./GetConversationAttributeRequest.js"; +export type { ListConversationAttributesRequest } from "./ListConversationAttributesRequest.js"; +export type { UpdateConversationAttributeOptionRequest } from "./UpdateConversationAttributeOptionRequest.js"; +export type { UpdateConversationAttributeRequest } from "./UpdateConversationAttributeRequest.js"; diff --git a/src/api/resources/unstable/resources/export/index.ts b/src/api/resources/preview/resources/conversationsAttributes/index.ts similarity index 100% rename from src/api/resources/unstable/resources/export/index.ts rename to src/api/resources/preview/resources/conversationsAttributes/index.ts diff --git a/src/api/resources/preview/resources/conversationsAttributes/types/index.ts b/src/api/resources/preview/resources/conversationsAttributes/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/conversationsAttributes/types/types.ts b/src/api/resources/preview/resources/conversationsAttributes/types/types.ts new file mode 100644 index 00000000..b659b701 --- /dev/null +++ b/src/api/resources/preview/resources/conversationsAttributes/types/types.ts @@ -0,0 +1,50 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * Conversation Attributes represent custom metadata fields for conversations. They support type-specific properties: strings (multiline), lists (options), and relationships (reference). + */ +export type ConversationAttribute = + | Intercom.preview.ConversationAttribute.String + | Intercom.preview.ConversationAttribute.Integer + | Intercom.preview.ConversationAttribute.List + | Intercom.preview.ConversationAttribute.Decimal + | Intercom.preview.ConversationAttribute.Boolean + | Intercom.preview.ConversationAttribute.Datetime + | Intercom.preview.ConversationAttribute.Relationship + | Intercom.preview.ConversationAttribute.Files; + +export namespace ConversationAttribute { + export interface String extends Intercom.preview.ConversationAttributeStringType { + data_type: "string"; + } + + export interface Integer extends Intercom.preview.ConversationAttributeIntegerType { + data_type: "integer"; + } + + export interface List extends Intercom.preview.ConversationAttributeListType { + data_type: "list"; + } + + export interface Decimal extends Intercom.preview.ConversationAttributeDecimalType { + data_type: "decimal"; + } + + export interface Boolean extends Intercom.preview.ConversationAttributeBooleanType { + data_type: "boolean"; + } + + export interface Datetime extends Intercom.preview.ConversationAttributeDatetimeType { + data_type: "datetime"; + } + + export interface Relationship extends Intercom.preview.ConversationAttributeRelationshipType { + data_type: "relationship"; + } + + export interface Files extends Intercom.preview.ConversationAttributeFilesType { + data_type: "files"; + } +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/Client.ts b/src/api/resources/preview/resources/customObjectInstances/client/Client.ts similarity index 71% rename from src/api/resources/unstable/resources/customObjectInstances/client/Client.ts rename to src/api/resources/preview/resources/customObjectInstances/client/Client.ts index a8ff8f05..543b90ca 100644 --- a/src/api/resources/unstable/resources/customObjectInstances/client/Client.ts +++ b/src/api/resources/preview/resources/customObjectInstances/client/Client.ts @@ -29,36 +29,69 @@ export class CustomObjectInstancesClient { } /** - * Fetch a Custom Object Instance by external_id. + * List instances of a custom object type. Three modes are supported: + * - **No filter** — returns all instances for the type. + * - **`references_contact_id`** — returns instances associated with the given contact. + * - **`references_conversation_id`** — returns instances associated with the given conversation. * - * @param {Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest} request + * When **`external_id`** is provided, returns a single matching instance (not a list). + * + * @param {Intercom.preview.ListCustomObjectInstancesRequest} request * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ + * await client.preview.customObjectInstances.listCustomObjectInstances({ * custom_object_type_identifier: "Order", - * external_id: "external_id" + * references_contact_id: "references_contact_id", + * references_conversation_id: "references_conversation_id", + * external_id: "external_id", + * page: 1, + * per_page: 1 * }) */ - public getCustomObjectInstancesByExternalId( - request: Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest, + public listCustomObjectInstances( + request: Intercom.preview.ListCustomObjectInstancesRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise( - this.__getCustomObjectInstancesByExternalId(request, requestOptions), - ); + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listCustomObjectInstances(request, requestOptions)); } - private async __getCustomObjectInstancesByExternalId( - request: Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest, + private async __listCustomObjectInstances( + request: Intercom.preview.ListCustomObjectInstancesRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request; + ): Promise> { + const { + custom_object_type_identifier: customObjectTypeIdentifier, + references_contact_id: referencesContactId, + references_conversation_id: referencesConversationId, + external_id: externalId, + page, + per_page: perPage, + } = request; const _queryParams: Record = {}; - _queryParams.external_id = externalId; + if (referencesContactId != null) { + _queryParams.references_contact_id = referencesContactId; + } + + if (referencesConversationId != null) { + _queryParams.references_conversation_id = referencesConversationId; + } + + if (externalId != null) { + _queryParams.external_id = externalId; + } + + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -84,7 +117,7 @@ export class CustomObjectInstancesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.CustomObjectInstance | undefined, + data: _response.body as Intercom.preview.CustomObjectInstancesPaginatedList, rawResponse: _response.rawResponse, }; } @@ -92,12 +125,12 @@ export class CustomObjectInstancesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -118,14 +151,14 @@ export class CustomObjectInstancesClient { /** * Create or update a custom object instance * - * @param {Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest} request + * @param {Intercom.preview.CreateOrUpdateCustomObjectInstanceRequest} request * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.customObjectInstances.createCustomObjectInstances({ + * await client.preview.customObjectInstances.createCustomObjectInstances({ * custom_object_type_identifier: "Order", * external_id: "123", * external_created_at: 1392036272, @@ -137,16 +170,16 @@ export class CustomObjectInstancesClient { * }) */ public createCustomObjectInstances( - request: Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest, + request: Intercom.preview.CreateOrUpdateCustomObjectInstanceRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createCustomObjectInstances(request, requestOptions)); } private async __createCustomObjectInstances( - request: Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest, + request: Intercom.preview.CreateOrUpdateCustomObjectInstanceRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { + ): Promise> { const { custom_object_type_identifier: customObjectTypeIdentifier, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -176,7 +209,7 @@ export class CustomObjectInstancesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.CustomObjectInstance | undefined, + data: _response.body as Intercom.preview.CustomObjectInstance | undefined, rawResponse: _response.rawResponse, }; } @@ -184,12 +217,12 @@ export class CustomObjectInstancesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -210,29 +243,29 @@ export class CustomObjectInstancesClient { /** * Delete a single Custom Object instance by external_id. * - * @param {Intercom.unstable.DeleteCustomObjectInstancesByIdRequest} request + * @param {Intercom.preview.DeleteCustomObjectInstancesByIdRequest} request * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ + * await client.preview.customObjectInstances.deleteCustomObjectInstancesById({ * custom_object_type_identifier: "Order", * external_id: "external_id" * }) */ public deleteCustomObjectInstancesById( - request: Intercom.unstable.DeleteCustomObjectInstancesByIdRequest, + request: Intercom.preview.DeleteCustomObjectInstancesByIdRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteCustomObjectInstancesById(request, requestOptions)); } private async __deleteCustomObjectInstancesById( - request: Intercom.unstable.DeleteCustomObjectInstancesByIdRequest, + request: Intercom.preview.DeleteCustomObjectInstancesByIdRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { + ): Promise> { const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request; const _queryParams: Record = {}; _queryParams.external_id = externalId; @@ -261,7 +294,7 @@ export class CustomObjectInstancesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.CustomObjectInstanceDeleted, + data: _response.body as Intercom.preview.CustomObjectInstanceDeleted, rawResponse: _response.rawResponse, }; } @@ -269,12 +302,12 @@ export class CustomObjectInstancesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -295,29 +328,29 @@ export class CustomObjectInstancesClient { /** * Fetch a Custom Object Instance by id. * - * @param {Intercom.unstable.GetCustomObjectInstancesByIdRequest} request + * @param {Intercom.preview.GetCustomObjectInstancesByIdRequest} request * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.customObjectInstances.getCustomObjectInstancesById({ + * await client.preview.customObjectInstances.getCustomObjectInstancesById({ * custom_object_type_identifier: "Order", * id: "id" * }) */ public getCustomObjectInstancesById( - request: Intercom.unstable.GetCustomObjectInstancesByIdRequest, + request: Intercom.preview.GetCustomObjectInstancesByIdRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getCustomObjectInstancesById(request, requestOptions)); } private async __getCustomObjectInstancesById( - request: Intercom.unstable.GetCustomObjectInstancesByIdRequest, + request: Intercom.preview.GetCustomObjectInstancesByIdRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { + ): Promise> { const { custom_object_type_identifier: customObjectTypeIdentifier, id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -344,7 +377,7 @@ export class CustomObjectInstancesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.CustomObjectInstance | undefined, + data: _response.body as Intercom.preview.CustomObjectInstance | undefined, rawResponse: _response.rawResponse, }; } @@ -352,12 +385,12 @@ export class CustomObjectInstancesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -378,31 +411,31 @@ export class CustomObjectInstancesClient { /** * Delete a single Custom Object instance using the Intercom defined id. * - * @param {Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest} request + * @param {Intercom.preview.DeleteCustomObjectInstancesByExternalIdRequest} request * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ + * await client.preview.customObjectInstances.deleteCustomObjectInstancesByExternalId({ * custom_object_type_identifier: "Order", * id: "id" * }) */ public deleteCustomObjectInstancesByExternalId( - request: Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest, + request: Intercom.preview.DeleteCustomObjectInstancesByExternalIdRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise( this.__deleteCustomObjectInstancesByExternalId(request, requestOptions), ); } private async __deleteCustomObjectInstancesByExternalId( - request: Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest, + request: Intercom.preview.DeleteCustomObjectInstancesByExternalIdRequest, requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { + ): Promise> { const { custom_object_type_identifier: customObjectTypeIdentifier, id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -429,7 +462,7 @@ export class CustomObjectInstancesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.CustomObjectInstanceDeleted, + data: _response.body as Intercom.preview.CustomObjectInstanceDeleted, rawResponse: _response.rawResponse, }; } @@ -437,12 +470,12 @@ export class CustomObjectInstancesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/unstable/resources/helpCenter/client/index.ts b/src/api/resources/preview/resources/customObjectInstances/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/helpCenter/client/index.ts rename to src/api/resources/preview/resources/customObjectInstances/client/index.ts diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts b/src/api/resources/preview/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts rename to src/api/resources/preview/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts b/src/api/resources/preview/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts rename to src/api/resources/preview/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts b/src/api/resources/preview/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts rename to src/api/resources/preview/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts b/src/api/resources/preview/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts rename to src/api/resources/preview/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts diff --git a/src/api/resources/preview/resources/customObjectInstances/client/requests/ListCustomObjectInstancesRequest.ts b/src/api/resources/preview/resources/customObjectInstances/client/requests/ListCustomObjectInstancesRequest.ts new file mode 100644 index 00000000..073c84d8 --- /dev/null +++ b/src/api/resources/preview/resources/customObjectInstances/client/requests/ListCustomObjectInstancesRequest.ts @@ -0,0 +1,27 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * custom_object_type_identifier: "Order", + * references_contact_id: "references_contact_id", + * references_conversation_id: "references_conversation_id", + * external_id: "external_id", + * page: 1, + * per_page: 1 + * } + */ +export interface ListCustomObjectInstancesRequest { + /** The unique identifier of the custom object type that defines the structure of the custom object instance. */ + custom_object_type_identifier: string; + /** Return instances associated with the given contact ID. */ + references_contact_id?: string; + /** Return instances associated with the given conversation ID. */ + references_conversation_id?: string; + /** Return the single instance with this external ID. When provided, the response is a single object rather than a list. */ + external_id?: string; + /** Page number of results to fetch. */ + page?: number; + /** Number of results per page. Maximum 150. */ + per_page?: number; +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/index.ts b/src/api/resources/preview/resources/customObjectInstances/client/requests/index.ts similarity index 79% rename from src/api/resources/unstable/resources/customObjectInstances/client/requests/index.ts rename to src/api/resources/preview/resources/customObjectInstances/client/requests/index.ts index 07816781..5ad54129 100644 --- a/src/api/resources/unstable/resources/customObjectInstances/client/requests/index.ts +++ b/src/api/resources/preview/resources/customObjectInstances/client/requests/index.ts @@ -1,5 +1,5 @@ export type { CreateOrUpdateCustomObjectInstanceRequest } from "./CreateOrUpdateCustomObjectInstanceRequest.js"; export type { DeleteCustomObjectInstancesByExternalIdRequest } from "./DeleteCustomObjectInstancesByExternalIdRequest.js"; export type { DeleteCustomObjectInstancesByIdRequest } from "./DeleteCustomObjectInstancesByIdRequest.js"; -export type { GetCustomObjectInstancesByExternalIdRequest } from "./GetCustomObjectInstancesByExternalIdRequest.js"; export type { GetCustomObjectInstancesByIdRequest } from "./GetCustomObjectInstancesByIdRequest.js"; +export type { ListCustomObjectInstancesRequest } from "./ListCustomObjectInstancesRequest.js"; diff --git a/src/api/resources/unstable/resources/helpCenter/index.ts b/src/api/resources/preview/resources/customObjectInstances/index.ts similarity index 100% rename from src/api/resources/unstable/resources/helpCenter/index.ts rename to src/api/resources/preview/resources/customObjectInstances/index.ts diff --git a/src/api/resources/preview/resources/customObjectInstances/types/index.ts b/src/api/resources/preview/resources/customObjectInstances/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/customObjectInstances/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts b/src/api/resources/preview/resources/customObjectInstances/types/types.ts similarity index 73% rename from src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts rename to src/api/resources/preview/resources/customObjectInstances/types/types.ts index a4363acf..7e1dabfc 100644 --- a/src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts +++ b/src/api/resources/preview/resources/customObjectInstances/types/types.ts @@ -1,5 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Intercom from "../../../../../index.js"; + /** * A Custom Object Instance represents an instance of a custom object type. This allows you to create and set custom attributes to store data about your customers that is not already captured by Intercom. The parent object includes recommended default attributes and you can add your own custom attributes. */ @@ -21,3 +23,16 @@ export interface CustomObjectInstance { /** The custom attributes you have set on the custom object instance. */ custom_attributes?: Record; } + +/** + * A paginated list of custom object instances. + */ +export interface CustomObjectInstancesPaginatedList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.preview.PagesLink; + /** A count of the total number of custom object instances. */ + total_count?: number; + /** An array of Custom Object Instance objects. */ + data?: (Intercom.preview.CustomObjectInstance | undefined)[]; +} diff --git a/src/api/resources/unstable/resources/dataAttributes/client/Client.ts b/src/api/resources/preview/resources/dataAttributes/client/Client.ts similarity index 74% rename from src/api/resources/unstable/resources/dataAttributes/client/Client.ts rename to src/api/resources/preview/resources/dataAttributes/client/Client.ts index 1778c2d1..907e7584 100644 --- a/src/api/resources/unstable/resources/dataAttributes/client/Client.ts +++ b/src/api/resources/preview/resources/dataAttributes/client/Client.ts @@ -26,30 +26,35 @@ export class DataAttributesClient { } /** - * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + * You can fetch a list of all data attributes belonging to a workspace for contacts or companies. * - * @param {Intercom.unstable.LisDataAttributesRequest} request + * {% admonition type="warning" name="Conversation attributes removed" %} + * Conversation attributes are no longer returned by this endpoint. Calling without a `model` parameter no longer includes them in the response, and `model=conversation` returns a `422` error. Use [GET /conversations/attributes](/docs/references/preview/rest-api/api.intercom.io/conversations-attributes/listconversationattributes) instead. + * {% /admonition %} + * + * @param {Intercom.preview.LisDataAttributesRequest} request * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.dataAttributes.lisDataAttributes({ + * await client.preview.dataAttributes.lisDataAttributes({ * model: "contact", * include_archived: true * }) */ public lisDataAttributes( - request: Intercom.unstable.LisDataAttributesRequest = {}, + request: Intercom.preview.LisDataAttributesRequest = {}, requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__lisDataAttributes(request, requestOptions)); } private async __lisDataAttributes( - request: Intercom.unstable.LisDataAttributesRequest = {}, + request: Intercom.preview.LisDataAttributesRequest = {}, requestOptions?: DataAttributesClient.RequestOptions, - ): Promise> { + ): Promise> { const { model, include_archived: includeArchived } = request; const _queryParams: Record = {}; if (model != null) { @@ -84,14 +89,19 @@ export class DataAttributesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.DataAttributeList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.DataAttributeList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); default: @@ -112,25 +122,25 @@ export class DataAttributesClient { * @param {unknown} request * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.dataAttributes.createDataAttribute({ + * await client.preview.dataAttributes.createDataAttribute({ * "key": "value" * }) */ public createDataAttribute( request?: unknown, requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createDataAttribute(request, requestOptions)); } private async __createDataAttribute( request?: unknown, requestOptions?: DataAttributesClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -158,16 +168,16 @@ export class DataAttributesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.DataAttribute, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.DataAttribute, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -190,16 +200,16 @@ export class DataAttributesClient { * > * > It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead. * - * @param {Intercom.unstable.UpdateDataAttributeRequest} request + * @param {Intercom.preview.UpdateDataAttributeRequest} request * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * @throws {@link Intercom.unstable.UnprocessableEntityError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.dataAttributes.updateDataAttribute({ + * await client.preview.dataAttributes.updateDataAttribute({ * id: 1, * body: { * "key": "value" @@ -207,16 +217,16 @@ export class DataAttributesClient { * }) */ public updateDataAttribute( - request: Intercom.unstable.UpdateDataAttributeRequest, + request: Intercom.preview.UpdateDataAttributeRequest, requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateDataAttribute(request, requestOptions)); } private async __updateDataAttribute( - request: Intercom.unstable.UpdateDataAttributeRequest, + request: Intercom.preview.UpdateDataAttributeRequest, requestOptions?: DataAttributesClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, body: _body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -245,22 +255,22 @@ export class DataAttributesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.DataAttribute, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.DataAttribute, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); case 422: - throw new Intercom.unstable.UnprocessableEntityError( + throw new Intercom.preview.UnprocessableEntityError( _response.error.body as unknown, _response.rawResponse, ); diff --git a/src/api/resources/unstable/resources/internalArticles/client/index.ts b/src/api/resources/preview/resources/dataAttributes/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/internalArticles/client/index.ts rename to src/api/resources/preview/resources/dataAttributes/client/index.ts diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts b/src/api/resources/preview/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts similarity index 68% rename from src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts rename to src/api/resources/preview/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts index 89b6ac5f..dd86874f 100644 --- a/src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts +++ b/src/api/resources/preview/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts @@ -10,8 +10,8 @@ import type * as Intercom from "../../../../../../index.js"; * } */ export interface LisDataAttributesRequest { - /** Specify the data attribute model to return. */ - model?: Intercom.unstable.LisDataAttributesRequestModel; + /** Specify the data attribute model to return. For conversation attributes, use `GET /conversations/attributes` instead. */ + model?: Intercom.preview.LisDataAttributesRequestModel; /** Include archived attributes in the list. By default we return only non archived data attributes. */ include_archived?: boolean; } diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts b/src/api/resources/preview/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts rename to src/api/resources/preview/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/index.ts b/src/api/resources/preview/resources/dataAttributes/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataAttributes/client/requests/index.ts rename to src/api/resources/preview/resources/dataAttributes/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/internalArticles/index.ts b/src/api/resources/preview/resources/dataAttributes/index.ts similarity index 100% rename from src/api/resources/unstable/resources/internalArticles/index.ts rename to src/api/resources/preview/resources/dataAttributes/index.ts diff --git a/src/api/resources/preview/resources/dataAttributes/types/index.ts b/src/api/resources/preview/resources/dataAttributes/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/dataAttributes/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts b/src/api/resources/preview/resources/dataAttributes/types/types.ts similarity index 80% rename from src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts rename to src/api/resources/preview/resources/dataAttributes/types/types.ts index 090b36d1..8d6739af 100644 --- a/src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts +++ b/src/api/resources/preview/resources/dataAttributes/types/types.ts @@ -1,7 +1,14 @@ // This file was auto-generated by Fern from our API Definition. +export const LisDataAttributesRequestModel = { + Contact: "contact", + Company: "company", +} as const; +export type LisDataAttributesRequestModel = + (typeof LisDataAttributesRequestModel)[keyof typeof LisDataAttributesRequestModel]; + /** - * Data Attributes are metadata used to describe your contact, company and conversation models. These include standard and custom attributes. By using the data attributes endpoint, you can get the global list of attributes for your workspace, as well as create and archive custom attributes. + * Data Attributes are metadata used to describe your contact and company models. These include standard and custom attributes. By using the data attributes endpoint, you can get the global list of attributes for your workspace, as well as create and archive custom attributes. */ export interface DataAttribute { /** Value is `data_attribute`. */ @@ -54,6 +61,7 @@ export namespace DataAttribute { Float: "float", Boolean: "boolean", Date: "date", + Datetime: "datetime", } as const; export type DataType = (typeof DataType)[keyof typeof DataType]; } diff --git a/src/api/resources/preview/resources/dataConnectors/client/Client.ts b/src/api/resources/preview/resources/dataConnectors/client/Client.ts new file mode 100644 index 00000000..f2b8f00a --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/Client.ts @@ -0,0 +1,724 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace DataConnectorsClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Everything about your Data Connectors + */ +export class DataConnectorsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: DataConnectorsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Returns a paginated list of all data connectors for the workspace, ordered by most recently updated first. Data connectors allow workflows and AI agents to make HTTP requests to external APIs. + * + * @param {Intercom.preview.ListDataConnectorsRequest} request + * @param {DataConnectorsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.dataConnectors.listDataConnectors({ + * per_page: 1, + * starting_after: "starting_after" + * }) + */ + public listDataConnectors( + request: Intercom.preview.ListDataConnectorsRequest = {}, + requestOptions?: DataConnectorsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listDataConnectors(request, requestOptions)); + } + + private async __listDataConnectors( + request: Intercom.preview.ListDataConnectorsRequest = {}, + requestOptions?: DataConnectorsClient.RequestOptions, + ): Promise> { + const { per_page: perPage, starting_after: startingAfter } = request; + const _queryParams: Record = {}; + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (startingAfter != null) { + _queryParams.starting_after = startingAfter; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "data_connectors", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.DataConnectorList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/data_connectors"); + } + + /** + * Create a new data connector. The connector is created in `draft` state. Configure its URL, headers, data inputs, and other settings, then set it to `live` when ready. + * + * @param {Intercom.preview.CreateDataConnectorRequest} request + * @param {DataConnectorsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.dataConnectors.createDataConnector({ + * name: "Get Order Status", + * description: "Looks up order status from an external service", + * http_method: "get", + * url: "https://api.example.com/orders/{{order_id}}/status", + * direct_fin_usage: true, + * audiences: ["leads", "visitors"], + * headers: [{ + * name: "Content-Type", + * value: "application/json" + * }], + * data_inputs: [{ + * name: "order_id", + * type: "string", + * description: "The order ID to look up", + * required: true, + * default_value: "" + * }], + * customer_authentication: true, + * bypass_authentication: false, + * validate_missing_attributes: true + * }) + * + * @example + * await client.preview.dataConnectors.createDataConnector({ + * name: "My Connector" + * }) + * + * @example + * await client.preview.dataConnectors.createDataConnector({ + * name: "Order Lookup", + * mock_response: { + * "order": { + * "id": 12345, + * "status": "shipped" + * } + * } + * }) + */ + public createDataConnector( + request: Intercom.preview.CreateDataConnectorRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createDataConnector(request, requestOptions)); + } + + private async __createDataConnector( + request: Intercom.preview.CreateDataConnectorRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "data_connectors", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.DataConnectorDetail, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/data_connectors"); + } + + /** + * You can retrieve the full detail of a single data connector by its ID. + * + * The response includes configuration, data inputs, response fields, and object mappings. + * + * @param {Intercom.preview.RetrieveDataConnectorRequest} request + * @param {DataConnectorsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.dataConnectors.retrieveDataConnector({ + * id: "12345", + * state_version: "draft" + * }) + */ + public retrieveDataConnector( + request: Intercom.preview.RetrieveDataConnectorRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveDataConnector(request, requestOptions)); + } + + private async __retrieveDataConnector( + request: Intercom.preview.RetrieveDataConnectorRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): Promise> { + const { id, state_version: stateVersion } = request; + const _queryParams: Record = {}; + if (stateVersion != null) { + _queryParams.state_version = stateVersion; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `data_connectors/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.DataConnectorDetail, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/data_connectors/{id}"); + } + + /** + * Delete an existing data connector. The connector must be in `draft` state and must not be in use by any workflows or AI agents. + * + * @param {Intercom.preview.DeleteDataConnectorRequest} request + * @param {DataConnectorsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.ConflictError} + * + * @example + * await client.preview.dataConnectors.deleteDataConnector({ + * id: "12345" + * }) + */ + public deleteDataConnector( + request: Intercom.preview.DeleteDataConnectorRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteDataConnector(request, requestOptions)); + } + + private async __deleteDataConnector( + request: Intercom.preview.DeleteDataConnectorRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `data_connectors/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.DeletedDataConnectorObject, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Intercom.preview.ConflictError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/data_connectors/{id}"); + } + + /** + * Update an existing data connector. Only provided fields are changed. Set `state` to `live` or `draft` to change the connector's state. + * + * @param {Intercom.preview.UpdateDataConnectorRequest} request + * @param {DataConnectorsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.ConflictError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.dataConnectors.updateDataConnector({ + * id: "12345", + * name: "Updated Connector Name", + * description: "Updated description" + * }) + * + * @example + * await client.preview.dataConnectors.updateDataConnector({ + * id: "12345", + * state: "live" + * }) + * + * @example + * await client.preview.dataConnectors.updateDataConnector({ + * id: "12345", + * state: "draft" + * }) + * + * @example + * await client.preview.dataConnectors.updateDataConnector({ + * id: "12345", + * mock_response: { + * "user": { + * "name": "Alice", + * "email": "alice@example.com" + * } + * } + * }) + */ + public updateDataConnector( + request: Intercom.preview.UpdateDataConnectorRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateDataConnector(request, requestOptions)); + } + + private async __updateDataConnector( + request: Intercom.preview.UpdateDataConnectorRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `data_connectors/${core.url.encodePathParam(id)}`, + ), + method: "PATCH", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.DataConnectorDetail, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Intercom.preview.ConflictError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/data_connectors/{id}"); + } + + /** + * Retrieve paginated execution logs for a specific data connector. + * Results from the last hour are returned by default. Use `start_ts` and `end_ts` to customize the time range. + * + * Request/response bodies are excluded by default. Use `include_bodies=true` to include them. + * + * @param {Intercom.preview.ListDataConnectorExecutionResultsRequest} request + * @param {DataConnectorsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.dataConnectors.listDataConnectorExecutionResults({ + * data_connector_id: "12345", + * per_page: 1, + * starting_after: "starting_after", + * success: "true", + * error_type: "request_configuration_error", + * start_ts: 1, + * end_ts: 1, + * include_bodies: "true" + * }) + */ + public listDataConnectorExecutionResults( + request: Intercom.preview.ListDataConnectorExecutionResultsRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listDataConnectorExecutionResults(request, requestOptions)); + } + + private async __listDataConnectorExecutionResults( + request: Intercom.preview.ListDataConnectorExecutionResultsRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): Promise> { + const { + data_connector_id: dataConnectorId, + per_page: perPage, + starting_after: startingAfter, + success, + error_type: errorType, + start_ts: startTs, + end_ts: endTs, + include_bodies: includeBodies, + } = request; + const _queryParams: Record = {}; + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (startingAfter != null) { + _queryParams.starting_after = startingAfter; + } + + if (success != null) { + _queryParams.success = success; + } + + if (errorType != null) { + _queryParams.error_type = errorType; + } + + if (startTs != null) { + _queryParams.start_ts = startTs.toString(); + } + + if (endTs != null) { + _queryParams.end_ts = endTs.toString(); + } + + if (includeBodies != null) { + _queryParams.include_bodies = includeBodies; + } + + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `data_connectors/${core.url.encodePathParam(dataConnectorId)}/execution_results`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.DataConnectorExecutionResultList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/data_connectors/{data_connector_id}/execution_results", + ); + } + + /** + * Retrieve details for a specific data connector execution result. + * Always includes request/response bodies and the sanitised request URL. + * + * @param {Intercom.preview.ShowDataConnectorExecutionResultRequest} request + * @param {DataConnectorsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.dataConnectors.showDataConnectorExecutionResult({ + * data_connector_id: "12345", + * id: "99001" + * }) + */ + public showDataConnectorExecutionResult( + request: Intercom.preview.ShowDataConnectorExecutionResultRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__showDataConnectorExecutionResult(request, requestOptions)); + } + + private async __showDataConnectorExecutionResult( + request: Intercom.preview.ShowDataConnectorExecutionResultRequest, + requestOptions?: DataConnectorsClient.RequestOptions, + ): Promise> { + const { data_connector_id: dataConnectorId, id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `data_connectors/${core.url.encodePathParam(dataConnectorId)}/execution_results/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.DataConnectorExecutionResult, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/data_connectors/{data_connector_id}/execution_results/{id}", + ); + } +} diff --git a/src/api/resources/unstable/resources/jobs/client/index.ts b/src/api/resources/preview/resources/dataConnectors/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/jobs/client/index.ts rename to src/api/resources/preview/resources/dataConnectors/client/index.ts diff --git a/src/api/resources/preview/resources/dataConnectors/client/requests/CreateDataConnectorRequest.ts b/src/api/resources/preview/resources/dataConnectors/client/requests/CreateDataConnectorRequest.ts new file mode 100644 index 00000000..9d658ca0 --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/requests/CreateDataConnectorRequest.ts @@ -0,0 +1,134 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * name: "Get Order Status", + * description: "Looks up order status from an external service", + * http_method: "get", + * url: "https://api.example.com/orders/{{order_id}}/status", + * direct_fin_usage: true, + * audiences: ["leads", "visitors"], + * headers: [{ + * name: "Content-Type", + * value: "application/json" + * }], + * data_inputs: [{ + * name: "order_id", + * type: "string", + * description: "The order ID to look up", + * required: true, + * default_value: "" + * }], + * customer_authentication: true, + * bypass_authentication: false, + * validate_missing_attributes: true + * } + * + * @example + * { + * name: "My Connector" + * } + * + * @example + * { + * name: "Order Lookup", + * mock_response: { + * "order": { + * "id": 12345, + * "status": "shipped" + * } + * } + * } + */ +export interface CreateDataConnectorRequest { + /** The name of the data connector. */ + name: string; + /** A description of what this data connector does. */ + description?: string; + /** The HTTP method used when calling the external API. */ + http_method?: CreateDataConnectorRequest.HttpMethod; + /** The URL of the external API endpoint. Supports template variables like `{{order_id}}`. */ + url?: string; + /** The request body template. Supports template variables. */ + body?: string; + /** Whether the connector is used directly by Fin (true) or only in workflows (false). Defaults to false. */ + direct_fin_usage?: boolean; + /** The user types this connector is available for. */ + audiences?: CreateDataConnectorRequest.Audiences.Item[]; + /** HTTP headers to include in the request. */ + headers?: CreateDataConnectorRequest.Headers.Item[]; + /** Input parameters accepted by the connector. */ + data_inputs?: CreateDataConnectorRequest.DataInputs.Item[]; + /** Whether the connector requires customer authentication before executing. Defaults to false. */ + customer_authentication?: boolean; + /** Whether authentication is bypassed entirely (public endpoint). Defaults to false. */ + bypass_authentication?: boolean; + /** Whether to validate that all required data inputs have values before executing. */ + validate_missing_attributes?: boolean; + /** A sample JSON response from the external API. Auto-generates `response_fields` and sets `configuration_response_type` to `mock_response_type`. */ + mock_response?: Record; + /** IDs of authentication tokens to attach to this data connector. */ + token_ids?: string[]; +} + +export namespace CreateDataConnectorRequest { + /** The HTTP method used when calling the external API. */ + export const HttpMethod = { + Get: "get", + Post: "post", + Put: "put", + Delete: "delete", + Patch: "patch", + } as const; + export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod]; + export type Audiences = Audiences.Item[]; + + export namespace Audiences { + export const Item = { + Leads: "leads", + Users: "users", + Visitors: "visitors", + } as const; + export type Item = (typeof Item)[keyof typeof Item]; + } + + export type Headers = Headers.Item[]; + + export namespace Headers { + export interface Item { + /** The header name. */ + name?: string; + /** The header value. Supports template variables. */ + value?: string; + } + } + + export type DataInputs = DataInputs.Item[]; + + export namespace DataInputs { + export interface Item { + /** The parameter name. */ + name?: string; + /** The parameter type. */ + type?: Item.Type; + /** A description of the parameter. */ + description?: string; + /** Whether the parameter is required. */ + required?: boolean; + /** The default value for the parameter. Defaults to an empty string if omitted. */ + default_value?: string; + } + + export namespace Item { + /** The parameter type. */ + export const Type = { + String: "string", + Integer: "integer", + Decimal: "decimal", + Boolean: "boolean", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } +} diff --git a/src/api/resources/preview/resources/dataConnectors/client/requests/DeleteDataConnectorRequest.ts b/src/api/resources/preview/resources/dataConnectors/client/requests/DeleteDataConnectorRequest.ts new file mode 100644 index 00000000..10714ab7 --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/requests/DeleteDataConnectorRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "12345" + * } + */ +export interface DeleteDataConnectorRequest { + /** The unique identifier of the data connector */ + id: string; +} diff --git a/src/api/resources/preview/resources/dataConnectors/client/requests/ListDataConnectorExecutionResultsRequest.ts b/src/api/resources/preview/resources/dataConnectors/client/requests/ListDataConnectorExecutionResultsRequest.ts new file mode 100644 index 00000000..fa2550e7 --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/requests/ListDataConnectorExecutionResultsRequest.ts @@ -0,0 +1,35 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * data_connector_id: "12345", + * per_page: 1, + * starting_after: "starting_after", + * success: "true", + * error_type: "request_configuration_error", + * start_ts: 1, + * end_ts: 1, + * include_bodies: "true" + * } + */ +export interface ListDataConnectorExecutionResultsRequest { + /** The unique identifier for the data connector. */ + data_connector_id: string; + /** The number of results per page (1-30, default 10). */ + per_page?: number; + /** Cursor for pagination. Use the value from `pages.next.starting_after` in a previous response. */ + starting_after?: string; + /** Filter by success status. Use `true`, `false`, or omit for all. */ + success?: Intercom.preview.ListDataConnectorExecutionResultsRequestSuccess; + /** Filter by error type. */ + error_type?: Intercom.preview.ListDataConnectorExecutionResultsRequestErrorType; + /** Unix timestamp for start of time range (default 1 hour ago). */ + start_ts?: number; + /** Unix timestamp for end of time range (default now). */ + end_ts?: number; + /** Include request/response bodies in the response (default false). */ + include_bodies?: Intercom.preview.ListDataConnectorExecutionResultsRequestIncludeBodies; +} diff --git a/src/api/resources/preview/resources/dataConnectors/client/requests/ListDataConnectorsRequest.ts b/src/api/resources/preview/resources/dataConnectors/client/requests/ListDataConnectorsRequest.ts new file mode 100644 index 00000000..87decd8c --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/requests/ListDataConnectorsRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * per_page: 1, + * starting_after: "starting_after" + * } + */ +export interface ListDataConnectorsRequest { + /** The number of results to return per page. Defaults to 20, minimum 1, maximum 50. */ + per_page?: number; + /** The cursor value from `pages.next.starting_after` in a previous response. Used to paginate through results. */ + starting_after?: string; +} diff --git a/src/api/resources/preview/resources/dataConnectors/client/requests/RetrieveDataConnectorRequest.ts b/src/api/resources/preview/resources/dataConnectors/client/requests/RetrieveDataConnectorRequest.ts new file mode 100644 index 00000000..a78b3be2 --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/requests/RetrieveDataConnectorRequest.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * id: "12345", + * state_version: "draft" + * } + */ +export interface RetrieveDataConnectorRequest { + /** The unique identifier of the data connector. */ + id: string; + /** Which version of the data connector to return. Defaults to live. */ + state_version?: Intercom.preview.RetrieveDataConnectorRequestStateVersion; +} diff --git a/src/api/resources/preview/resources/dataConnectors/client/requests/ShowDataConnectorExecutionResultRequest.ts b/src/api/resources/preview/resources/dataConnectors/client/requests/ShowDataConnectorExecutionResultRequest.ts new file mode 100644 index 00000000..6119a6cd --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/requests/ShowDataConnectorExecutionResultRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * data_connector_id: "12345", + * id: "99001" + * } + */ +export interface ShowDataConnectorExecutionResultRequest { + /** The unique identifier for the data connector. */ + data_connector_id: string; + /** The unique identifier for the execution result. */ + id: string; +} diff --git a/src/api/resources/preview/resources/dataConnectors/client/requests/UpdateDataConnectorRequest.ts b/src/api/resources/preview/resources/dataConnectors/client/requests/UpdateDataConnectorRequest.ts new file mode 100644 index 00000000..e48de240 --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/requests/UpdateDataConnectorRequest.ts @@ -0,0 +1,134 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "12345", + * name: "Updated Connector Name", + * description: "Updated description" + * } + * + * @example + * { + * id: "12345", + * state: "live" + * } + * + * @example + * { + * id: "12345", + * state: "draft" + * } + * + * @example + * { + * id: "12345", + * mock_response: { + * "user": { + * "name": "Alice", + * "email": "alice@example.com" + * } + * } + * } + */ +export interface UpdateDataConnectorRequest { + /** The unique identifier of the data connector. */ + id: string; + /** The name of the data connector. */ + name?: string; + /** A description of what this data connector does. */ + description?: string; + /** The desired state of the connector. */ + state?: UpdateDataConnectorRequest.State; + /** The HTTP method used by the data connector. */ + http_method?: UpdateDataConnectorRequest.HttpMethod; + /** The URL of the external API endpoint. Supports template variables like `{{order_id}}`. */ + url?: string; + /** The request body template. Supports template variables. */ + body?: string; + /** Whether this connector is used directly by Fin. */ + direct_fin_usage?: boolean; + /** The audience types this connector targets. */ + audiences?: UpdateDataConnectorRequest.Audiences.Item[]; + /** HTTP headers to include in the request. */ + headers?: UpdateDataConnectorRequest.Headers.Item[]; + /** The input parameters accepted by this data connector. Replaces all existing inputs. */ + data_inputs?: UpdateDataConnectorRequest.DataInputs.Item[]; + /** Whether OTP authentication is enabled for this connector. */ + customer_authentication?: boolean; + /** Whether authentication is bypassed for this connector. */ + bypass_authentication?: boolean; + /** Whether to validate missing attributes before execution. */ + validate_missing_attributes?: boolean; + /** A sample JSON response from the external API. Auto-generates `response_fields` and sets `configuration_response_type` to `mock_response_type`. */ + mock_response?: Record; + /** IDs of authentication tokens to attach to this data connector. An empty array removes all tokens. */ + token_ids?: string[]; +} + +export namespace UpdateDataConnectorRequest { + /** The desired state of the connector. */ + export const State = { + Draft: "draft", + Live: "live", + } as const; + export type State = (typeof State)[keyof typeof State]; + /** The HTTP method used by the data connector. */ + export const HttpMethod = { + Get: "get", + Post: "post", + Put: "put", + Delete: "delete", + Patch: "patch", + } as const; + export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod]; + export type Audiences = Audiences.Item[]; + + export namespace Audiences { + export const Item = { + Leads: "leads", + Users: "users", + Visitors: "visitors", + } as const; + export type Item = (typeof Item)[keyof typeof Item]; + } + + export type Headers = Headers.Item[]; + + export namespace Headers { + export interface Item { + /** The header name. */ + name?: string; + /** The header value. Supports template variables. */ + value?: string; + } + } + + export type DataInputs = DataInputs.Item[]; + + export namespace DataInputs { + export interface Item { + /** The name of the input parameter. */ + name?: string; + /** The data type of the input. */ + type?: Item.Type; + /** A description of the input parameter. Required for each input. */ + description?: string; + /** Whether this input is required. */ + required?: boolean; + /** The default value for this input, if any. */ + default_value?: string; + } + + export namespace Item { + /** The data type of the input. */ + export const Type = { + String: "string", + Integer: "integer", + Decimal: "decimal", + Boolean: "boolean", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } +} diff --git a/src/api/resources/preview/resources/dataConnectors/client/requests/index.ts b/src/api/resources/preview/resources/dataConnectors/client/requests/index.ts new file mode 100644 index 00000000..21905045 --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/client/requests/index.ts @@ -0,0 +1,7 @@ +export type { CreateDataConnectorRequest } from "./CreateDataConnectorRequest.js"; +export type { DeleteDataConnectorRequest } from "./DeleteDataConnectorRequest.js"; +export type { ListDataConnectorExecutionResultsRequest } from "./ListDataConnectorExecutionResultsRequest.js"; +export type { ListDataConnectorsRequest } from "./ListDataConnectorsRequest.js"; +export type { RetrieveDataConnectorRequest } from "./RetrieveDataConnectorRequest.js"; +export type { ShowDataConnectorExecutionResultRequest } from "./ShowDataConnectorExecutionResultRequest.js"; +export type { UpdateDataConnectorRequest } from "./UpdateDataConnectorRequest.js"; diff --git a/src/api/resources/unstable/resources/jobs/index.ts b/src/api/resources/preview/resources/dataConnectors/index.ts similarity index 100% rename from src/api/resources/unstable/resources/jobs/index.ts rename to src/api/resources/preview/resources/dataConnectors/index.ts diff --git a/src/api/resources/preview/resources/dataConnectors/types/index.ts b/src/api/resources/preview/resources/dataConnectors/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/dataConnectors/types/types.ts b/src/api/resources/preview/resources/dataConnectors/types/types.ts new file mode 100644 index 00000000..196ca403 --- /dev/null +++ b/src/api/resources/preview/resources/dataConnectors/types/types.ts @@ -0,0 +1,413 @@ +// This file was auto-generated by Fern from our API Definition. + +export const RetrieveDataConnectorRequestStateVersion = { + Draft: "draft", + Live: "live", +} as const; +export type RetrieveDataConnectorRequestStateVersion = + (typeof RetrieveDataConnectorRequestStateVersion)[keyof typeof RetrieveDataConnectorRequestStateVersion]; + +export const ListDataConnectorExecutionResultsRequestSuccess = { + True: "true", + False: "false", +} as const; +export type ListDataConnectorExecutionResultsRequestSuccess = + (typeof ListDataConnectorExecutionResultsRequestSuccess)[keyof typeof ListDataConnectorExecutionResultsRequestSuccess]; + +export const ListDataConnectorExecutionResultsRequestErrorType = { + RequestConfigurationError: "request_configuration_error", + FaradayError: "faraday_error", + ThreeRdPartyError: "3rd_party_error", + ResponseMappingError: "response_mapping_error", + TokenRefreshError: "token_refresh_error", + FinActionResponseFormattingError: "fin_action_response_formatting_error", + FinActionIdentityVerificationError: "fin_action_identity_verification_error", + EmailVerificationError: "email_verification_error", + NonFinStandaloneActionIdentityVerificationError: "non_fin_standalone_action_identity_verification_error", + RequestValidationError: "request_validation_error", + ClientSideActionError: "client_side_action_error", +} as const; +export type ListDataConnectorExecutionResultsRequestErrorType = + (typeof ListDataConnectorExecutionResultsRequestErrorType)[keyof typeof ListDataConnectorExecutionResultsRequestErrorType]; + +export const ListDataConnectorExecutionResultsRequestIncludeBodies = { + True: "true", + False: "false", +} as const; +export type ListDataConnectorExecutionResultsRequestIncludeBodies = + (typeof ListDataConnectorExecutionResultsRequestIncludeBodies)[keyof typeof ListDataConnectorExecutionResultsRequestIncludeBodies]; + +/** + * A data connector allows you to make HTTP requests to external APIs from Intercom workflows and AI agents. + */ +export interface DataConnector { + /** The type of object - `data_connector`. */ + type?: "data_connector"; + /** The unique identifier for the data connector. */ + id?: string; + /** The name of the data connector. */ + name?: string; + /** A description of what this data connector does. */ + description?: string; + /** The current state of the data connector. */ + state?: DataConnector.State; + /** The HTTP method used by the data connector. */ + http_method?: DataConnector.HttpMethod; + /** Whether this data connector is assigned to Fin for direct usage. */ + direct_fin_usage?: boolean; + /** The ID of the admin who created this data connector. */ + created_by_admin_id?: string; + /** The ID of the admin who last updated this data connector. */ + updated_by_admin_id?: string; + /** The time the data connector was created. */ + created_at?: string; + /** The time the data connector was last updated. */ + updated_at?: string; + /** The URL path to fetch execution results for this connector. */ + execution_results_url?: string; +} + +export namespace DataConnector { + /** The current state of the data connector. */ + export const State = { + Draft: "draft", + Live: "live", + } as const; + export type State = (typeof State)[keyof typeof State]; + /** The HTTP method used by the data connector. */ + export const HttpMethod = { + Get: "get", + Post: "post", + Put: "put", + Delete: "delete", + Patch: "patch", + } as const; + export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod]; +} + +/** + * Full detail view of a data connector, returned by `GET /data_connectors/{id}`. + * Includes configuration, data inputs, response fields, and object mappings. + */ +export interface DataConnectorDetail { + /** The type of object - `data_connector`. */ + type?: "data_connector"; + /** The unique identifier for the data connector. */ + id?: string; + /** The name of the data connector. */ + name?: string; + /** A description of what this data connector does. */ + description?: string; + /** The current state of the data connector. */ + state?: DataConnectorDetail.State; + /** The URL of the external API endpoint. Supports template variables like `{{order_id}}`. */ + url?: string; + /** The request body template. Supports template variables. */ + body?: string; + /** HTTP headers for the request. Header values are always redacted as `"****"` in responses. */ + headers?: DataConnectorDetail.Headers.Item[]; + /** The HTTP method used by the data connector. */ + http_method?: DataConnectorDetail.HttpMethod; + /** Whether this connector is used directly by Fin. */ + direct_fin_usage?: boolean; + /** The audience types this connector targets. */ + audiences?: DataConnectorDetail.Audiences.Item[]; + /** How the connector executes. */ + execution_type?: DataConnectorDetail.ExecutionType; + /** The expected response format from the connector. */ + configuration_response_type?: DataConnectorDetail.ConfigurationResponseType; + /** The type of data transformation applied to the response. */ + data_transformation_type?: DataConnectorDetail.DataTransformationType; + /** + * The code block used to transform the connector's response when `data_transformation_type` is + * `code_block_transformation`. Omitted if the connector has no transform code block configured. + */ + transform_code_block?: DataConnectorDetail.TransformCodeBlock; + /** The name of the client-side function, if applicable. */ + client_function_name?: string; + /** Timeout in milliseconds for the client function, if applicable. */ + client_function_timeout_ms?: number; + /** The input parameters accepted by this data connector. */ + data_inputs?: DataConnectorDetail.DataInputs.Item[]; + /** The fields returned in the connector response. */ + response_fields?: DataConnectorDetail.ResponseFields.Item[]; + /** Mappings from connector response objects to Intercom objects. */ + object_mappings?: DataConnectorDetail.ObjectMappings.Item[]; + /** IDs of authentication tokens associated with this connector. */ + token_ids?: string[]; + /** Whether OTP authentication is enabled for this connector. */ + customer_authentication?: boolean; + /** Whether authentication is bypassed for this connector. */ + bypass_authentication?: boolean; + /** Whether to validate missing attributes before execution. */ + validate_missing_attributes?: boolean; + /** The ID of the admin who created this connector. */ + created_by_admin_id?: string; + /** The ID of the admin who last updated this connector. */ + updated_by_admin_id?: string; + /** The time the data connector was created. */ + created_at?: string; + /** The time the data connector was last updated. */ + updated_at?: string; + /** The URL path to fetch execution results for this connector. */ + execution_results_url?: string; +} + +export namespace DataConnectorDetail { + /** The current state of the data connector. */ + export const State = { + Draft: "draft", + Live: "live", + } as const; + export type State = (typeof State)[keyof typeof State]; + export type Headers = Headers.Item[]; + + export namespace Headers { + export interface Item { + /** The header name. */ + name?: string; + /** Always `"****"` in responses. */ + value?: string; + } + } + + /** The HTTP method used by the data connector. */ + export const HttpMethod = { + Get: "get", + Post: "post", + Put: "put", + Delete: "delete", + Patch: "patch", + } as const; + export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod]; + export type Audiences = Audiences.Item[]; + + export namespace Audiences { + export const Item = { + Users: "users", + Leads: "leads", + Visitors: "visitors", + } as const; + export type Item = (typeof Item)[keyof typeof Item]; + } + + /** How the connector executes. */ + export const ExecutionType = { + ServerSide: "server_side", + ClientSide: "client_side", + } as const; + export type ExecutionType = (typeof ExecutionType)[keyof typeof ExecutionType]; + /** The expected response format from the connector. */ + export const ConfigurationResponseType = { + TestResponseType: "test_response_type", + MockResponseType: "mock_response_type", + } as const; + export type ConfigurationResponseType = (typeof ConfigurationResponseType)[keyof typeof ConfigurationResponseType]; + /** The type of data transformation applied to the response. */ + export const DataTransformationType = { + FullAccess: "full_access", + RedactedAccess: "redacted_access", + CodeBlockTransformation: "code_block_transformation", + } as const; + export type DataTransformationType = (typeof DataTransformationType)[keyof typeof DataTransformationType]; + + /** + * The code block used to transform the connector's response when `data_transformation_type` is + * `code_block_transformation`. Omitted if the connector has no transform code block configured. + */ + export interface TransformCodeBlock { + /** The source code of the transform code block. */ + code?: string; + /** The programming language of the transform code block. Currently always `python`. */ + language?: string; + } + + export type DataInputs = DataInputs.Item[]; + + export namespace DataInputs { + export interface Item { + /** The name of the input parameter. */ + name?: string; + /** The data type of the input. */ + type?: Item.Type; + /** A description of the input parameter. */ + description?: string; + /** Whether this input is required. */ + required?: boolean; + /** The default value for this input, if any. */ + default_value?: string; + } + + export namespace Item { + /** The data type of the input. */ + export const Type = { + String: "string", + Integer: "integer", + Decimal: "decimal", + Boolean: "boolean", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } + + export type ResponseFields = ResponseFields.Item[]; + + export namespace ResponseFields { + export interface Item { + /** The JSON path of the response field. */ + path?: string; + /** The data type of the response field. */ + type?: Item.Type; + /** An example value for this field. */ + example_value?: unknown; + /** Whether this field is redacted in logs. */ + redacted?: boolean; + } + + export namespace Item { + /** The data type of the response field. */ + export const Type = { + Unknown: "unknown", + String: "string", + Integer: "integer", + Decimal: "decimal", + Datetime: "datetime", + Boolean: "boolean", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } + + export type ObjectMappings = ObjectMappings.Item[]; + + export namespace ObjectMappings { + export interface Item { + response_object_path?: string; + intercom_object_type?: Item.IntercomObjectType; + attribute_mappings?: Item.AttributeMappings.Item[]; + reference_mappings?: Item.ReferenceMappings.Item[]; + } + + export namespace Item { + export const IntercomObjectType = { + Conversation: "conversation", + User: "user", + } as const; + export type IntercomObjectType = (typeof IntercomObjectType)[keyof typeof IntercomObjectType]; + export type AttributeMappings = AttributeMappings.Item[]; + + export namespace AttributeMappings { + export interface Item { + response_attribute_path?: string; + intercom_attribute_identifier?: string; + mapping_type?: Item.MappingType; + } + + export namespace Item { + export const MappingType = { + PrimitiveMapping: "primitive_mapping", + ContextMapping: "context_mapping", + } as const; + export type MappingType = (typeof MappingType)[keyof typeof MappingType]; + } + } + + export type ReferenceMappings = ReferenceMappings.Item[]; + + export namespace ReferenceMappings { + export interface Item { + intercom_object_type?: Item.IntercomObjectType; + intercom_attribute_identifier?: string; + } + + export namespace Item { + export const IntercomObjectType = { + Conversation: "conversation", + User: "user", + } as const; + export type IntercomObjectType = (typeof IntercomObjectType)[keyof typeof IntercomObjectType]; + } + } + } + } +} + +/** + * An execution result from a data connector HTTP request. + */ +export interface DataConnectorExecutionResult { + /** The type of object - `data_connector.execution`. */ + type?: "data_connector.execution"; + /** The unique identifier for the execution result. */ + id?: string; + /** The unique identifier of the data connector that produced this result. */ + data_connector_id?: string; + /** Whether the execution was successful. */ + success?: boolean; + /** The HTTP status code returned by the external API. */ + http_status?: number; + /** The HTTP method used for the request. */ + http_method?: DataConnectorExecutionResult.HttpMethod; + /** The type of error that occurred, if any. */ + error_type?: DataConnectorExecutionResult.ErrorType; + /** A human-readable error message. Query parameters, userinfo, and fragments in URLs are redacted. */ + error_message?: string; + /** The execution time in milliseconds. */ + execution_time_ms?: number; + /** The type of source that triggered this execution. */ + source_type?: DataConnectorExecutionResult.SourceType; + /** The identifier of the source that triggered this execution. */ + source_id?: string; + /** The conversation associated with this execution, if any. */ + conversation_id?: string; + /** The time the execution occurred. */ + created_at?: string; + /** The request URL. Query parameters, userinfo, and fragments are redacted. */ + request_url?: string; + /** The request body sent to the external API. */ + request_body?: string; + /** The response body from the external API. */ + response_body?: string; + /** The raw (unmapped) response body. */ + raw_response_body?: string; +} + +export namespace DataConnectorExecutionResult { + /** The HTTP method used for the request. */ + export const HttpMethod = { + Get: "get", + Post: "post", + Put: "put", + Delete: "delete", + Patch: "patch", + } as const; + export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod]; + /** The type of error that occurred, if any. */ + export const ErrorType = { + RequestConfigurationError: "request_configuration_error", + FaradayError: "faraday_error", + ThreeRdPartyError: "3rd_party_error", + ResponseMappingError: "response_mapping_error", + TokenRefreshError: "token_refresh_error", + FinActionResponseFormattingError: "fin_action_response_formatting_error", + FinActionIdentityVerificationError: "fin_action_identity_verification_error", + EmailVerificationError: "email_verification_error", + NonFinStandaloneActionIdentityVerificationError: "non_fin_standalone_action_identity_verification_error", + RequestValidationError: "request_validation_error", + ClientSideActionError: "client_side_action_error", + } as const; + export type ErrorType = (typeof ErrorType)[keyof typeof ErrorType]; + /** The type of source that triggered this execution. */ + export const SourceType = { + CustomBot: "custom_bot", + InboundCustomBot: "inbound_custom_bot", + ButtonCustomBot: "button_custom_bot", + Answer: "answer", + Workflow: "workflow", + SavedReply: "saved_reply", + TriggerableCustomBot: "triggerable_custom_bot", + Inbox: "inbox", + Fin: "fin", + } as const; + export type SourceType = (typeof SourceType)[keyof typeof SourceType]; +} diff --git a/src/api/resources/unstable/resources/dataEvents/client/Client.ts b/src/api/resources/preview/resources/dataEvents/client/Client.ts similarity index 91% rename from src/api/resources/unstable/resources/dataEvents/client/Client.ts rename to src/api/resources/preview/resources/dataEvents/client/Client.ts index ad66e987..6123cd27 100644 --- a/src/api/resources/unstable/resources/dataEvents/client/Client.ts +++ b/src/api/resources/preview/resources/dataEvents/client/Client.ts @@ -42,13 +42,13 @@ export class DataEventsClient { * * You can optionally define the result page size as well with the `per_page` parameter. * - * @param {Intercom.unstable.LisDataEventsRequest} request + * @param {Intercom.preview.LisDataEventsRequest} request * @param {DataEventsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.dataEvents.lisDataEvents({ + * await client.preview.dataEvents.lisDataEvents({ * filter: { * user_id: "user_id" * }, @@ -56,16 +56,16 @@ export class DataEventsClient { * }) */ public lisDataEvents( - request: Intercom.unstable.LisDataEventsRequest, + request: Intercom.preview.LisDataEventsRequest, requestOptions?: DataEventsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__lisDataEvents(request, requestOptions)); } private async __lisDataEvents( - request: Intercom.unstable.LisDataEventsRequest, + request: Intercom.preview.LisDataEventsRequest, requestOptions?: DataEventsClient.RequestOptions, - ): Promise> { + ): Promise> { const { filter, type: type_, summary } = request; const _queryParams: Record = {}; _queryParams.filter = typeof filter === "string" ? filter : toJson(filter); @@ -98,14 +98,14 @@ export class DataEventsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.DataEventSummary, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.DataEventSummary, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -167,10 +167,10 @@ export class DataEventsClient { * @param {Intercom.CreateDataEventRequestTwo} request * @param {DataEventsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.dataEvents.createDataEvent({ + * await client.preview.dataEvents.createDataEvent({ * "key": "value" * }) */ @@ -218,8 +218,8 @@ export class DataEventsClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -238,23 +238,23 @@ export class DataEventsClient { * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. * * - * @param {Intercom.unstable.CreateDataEventSummariesRequest} request + * @param {Intercom.preview.CreateDataEventSummariesRequest} request * @param {DataEventsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.dataEvents.dataEventSummaries() + * await client.preview.dataEvents.dataEventSummaries() */ public dataEventSummaries( - request: Intercom.unstable.CreateDataEventSummariesRequest = {}, + request: Intercom.preview.CreateDataEventSummariesRequest = {}, requestOptions?: DataEventsClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__dataEventSummaries(request, requestOptions)); } private async __dataEventSummaries( - request: Intercom.unstable.CreateDataEventSummariesRequest = {}, + request: Intercom.preview.CreateDataEventSummariesRequest = {}, requestOptions?: DataEventsClient.RequestOptions, ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); @@ -290,8 +290,8 @@ export class DataEventsClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/unstable/resources/macros/client/index.ts b/src/api/resources/preview/resources/dataEvents/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/macros/client/index.ts rename to src/api/resources/preview/resources/dataEvents/client/index.ts diff --git a/src/api/resources/unstable/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts b/src/api/resources/preview/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts rename to src/api/resources/preview/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts diff --git a/src/api/resources/unstable/resources/dataEvents/client/requests/LisDataEventsRequest.ts b/src/api/resources/preview/resources/dataEvents/client/requests/LisDataEventsRequest.ts similarity index 87% rename from src/api/resources/unstable/resources/dataEvents/client/requests/LisDataEventsRequest.ts rename to src/api/resources/preview/resources/dataEvents/client/requests/LisDataEventsRequest.ts index 0dc68cfc..b9adc40b 100644 --- a/src/api/resources/unstable/resources/dataEvents/client/requests/LisDataEventsRequest.ts +++ b/src/api/resources/preview/resources/dataEvents/client/requests/LisDataEventsRequest.ts @@ -12,7 +12,7 @@ import type * as Intercom from "../../../../../../index.js"; * } */ export interface LisDataEventsRequest { - filter: Intercom.unstable.LisDataEventsRequestFilter; + filter: Intercom.preview.LisDataEventsRequestFilter; /** The value must be user */ type: string; /** summary flag */ diff --git a/src/api/resources/unstable/resources/dataEvents/client/requests/index.ts b/src/api/resources/preview/resources/dataEvents/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataEvents/client/requests/index.ts rename to src/api/resources/preview/resources/dataEvents/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/macros/index.ts b/src/api/resources/preview/resources/dataEvents/index.ts similarity index 100% rename from src/api/resources/unstable/resources/macros/index.ts rename to src/api/resources/preview/resources/dataEvents/index.ts diff --git a/src/api/resources/preview/resources/dataEvents/types/index.ts b/src/api/resources/preview/resources/dataEvents/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/dataEvents/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts b/src/api/resources/preview/resources/dataEvents/types/types.ts similarity index 81% rename from src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts rename to src/api/resources/preview/resources/dataEvents/types/types.ts index a88a24e6..ca395b86 100644 --- a/src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts +++ b/src/api/resources/preview/resources/dataEvents/types/types.ts @@ -1,5 +1,16 @@ // This file was auto-generated by Fern from our API Definition. +export type LisDataEventsRequestFilter = + | { + user_id: string; + } + | { + intercom_user_id: string; + } + | { + email: string; + }; + /** * Data events are used to notify Intercom of changes to your data. */ @@ -19,5 +30,5 @@ export interface DataEvent { /** An email address for your user. An email should only be used where your application uses email to uniquely identify users. */ email?: string; /** Optional metadata about the event. */ - metadata?: Record; + metadata?: Record; } diff --git a/src/api/resources/unstable/resources/dataExport/client/Client.ts b/src/api/resources/preview/resources/dataExport/client/Client.ts similarity index 84% rename from src/api/resources/unstable/resources/dataExport/client/Client.ts rename to src/api/resources/preview/resources/dataExport/client/Client.ts index 9381c9f5..03e480b3 100644 --- a/src/api/resources/unstable/resources/dataExport/client/Client.ts +++ b/src/api/resources/preview/resources/dataExport/client/Client.ts @@ -16,7 +16,7 @@ export declare namespace DataExportClient { } /** - * Everything about your Data Exports + * Export message delivery and engagement statistics (opens, clicks, replies, completions, dismissals, unsubscribes, bounces) for outbound content such as Emails, Posts, Custom Bots, Surveys, Tours, and Series. */ export class DataExportClient { protected readonly _options: NormalizedClientOptionsWithAuth; @@ -28,6 +28,8 @@ export class DataExportClient { /** * To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. * + * This endpoint exports **message delivery and engagement data** for outbound content (Emails, Posts, Custom Bots, Surveys, Tours, Series, and more). The exported data includes who received each message, when they received it, and how they engaged with it (opens, clicks, replies, completions, dismissals, unsubscribes, and bounces). It does not export raw message or conversation content. + * * The only parameters you need to provide are the range of dates that you want exported. * * >🚧 Limit of one active job @@ -42,26 +44,26 @@ export class DataExportClient { * > * > Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99. * - * @param {Intercom.unstable.CreateDataExportsRequest} request + * @param {Intercom.preview.CreateDataExportsRequest} request * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.unstable.dataExport.createDataExport({ + * await client.preview.dataExport.createDataExport({ * created_at_after: 1734519776, * created_at_before: 1734537776 * }) */ public createDataExport( - request: Intercom.unstable.CreateDataExportsRequest, + request: Intercom.preview.CreateDataExportsRequest, requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createDataExport(request, requestOptions)); } private async __createDataExport( - request: Intercom.unstable.CreateDataExportsRequest, + request: Intercom.preview.CreateDataExportsRequest, requestOptions?: DataExportClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -89,7 +91,7 @@ export class DataExportClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.DataExport, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -110,25 +112,25 @@ export class DataExportClient { * > 🚧 Jobs expire after two days * > All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available. * - * @param {Intercom.unstable.GetDataExportRequest} request + * @param {Intercom.preview.GetDataExportRequest} request * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.unstable.dataExport.getDataExport({ + * await client.preview.dataExport.getDataExport({ * job_identifier: "job_identifier" * }) */ public getDataExport( - request: Intercom.unstable.GetDataExportRequest, + request: Intercom.preview.GetDataExportRequest, requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getDataExport(request, requestOptions)); } private async __getDataExport( - request: Intercom.unstable.GetDataExportRequest, + request: Intercom.preview.GetDataExportRequest, requestOptions?: DataExportClient.RequestOptions, - ): Promise> { + ): Promise> { const { job_identifier: jobIdentifier } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -154,7 +156,7 @@ export class DataExportClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.DataExport, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -176,25 +178,25 @@ export class DataExportClient { /** * You can cancel your job * - * @param {Intercom.unstable.CancelDataExportRequest} request + * @param {Intercom.preview.CancelDataExportRequest} request * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.unstable.dataExport.cancelDataExport({ + * await client.preview.dataExport.cancelDataExport({ * job_identifier: "job_identifier" * }) */ public cancelDataExport( - request: Intercom.unstable.CancelDataExportRequest, + request: Intercom.preview.CancelDataExportRequest, requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__cancelDataExport(request, requestOptions)); } private async __cancelDataExport( - request: Intercom.unstable.CancelDataExportRequest, + request: Intercom.preview.CancelDataExportRequest, requestOptions?: DataExportClient.RequestOptions, - ): Promise> { + ): Promise> { const { job_identifier: jobIdentifier } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -220,7 +222,7 @@ export class DataExportClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.DataExport, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -248,23 +250,23 @@ export class DataExportClient { * > * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. * - * @param {Intercom.unstable.DownloadDataExportRequest} request + * @param {Intercom.preview.DownloadDataExportRequest} request * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.unstable.dataExport.downloadDataExport({ + * await client.preview.dataExport.downloadDataExport({ * job_identifier: "job_identifier" * }) */ public downloadDataExport( - request: Intercom.unstable.DownloadDataExportRequest, + request: Intercom.preview.DownloadDataExportRequest, requestOptions?: DataExportClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__downloadDataExport(request, requestOptions)); } private async __downloadDataExport( - request: Intercom.unstable.DownloadDataExportRequest, + request: Intercom.preview.DownloadDataExportRequest, requestOptions?: DataExportClient.RequestOptions, ): Promise> { const { job_identifier: jobIdentifier } = request; diff --git a/src/api/resources/unstable/resources/messages/client/index.ts b/src/api/resources/preview/resources/dataExport/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/messages/client/index.ts rename to src/api/resources/preview/resources/dataExport/client/index.ts diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/CancelDataExportRequest.ts b/src/api/resources/preview/resources/dataExport/client/requests/CancelDataExportRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/dataExport/client/requests/CancelDataExportRequest.ts rename to src/api/resources/preview/resources/dataExport/client/requests/CancelDataExportRequest.ts diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/CreateDataExportsRequest.ts b/src/api/resources/preview/resources/dataExport/client/requests/CreateDataExportsRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/dataExport/client/requests/CreateDataExportsRequest.ts rename to src/api/resources/preview/resources/dataExport/client/requests/CreateDataExportsRequest.ts diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/DownloadDataExportRequest.ts b/src/api/resources/preview/resources/dataExport/client/requests/DownloadDataExportRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/dataExport/client/requests/DownloadDataExportRequest.ts rename to src/api/resources/preview/resources/dataExport/client/requests/DownloadDataExportRequest.ts diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/GetDataExportRequest.ts b/src/api/resources/preview/resources/dataExport/client/requests/GetDataExportRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/dataExport/client/requests/GetDataExportRequest.ts rename to src/api/resources/preview/resources/dataExport/client/requests/GetDataExportRequest.ts diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/index.ts b/src/api/resources/preview/resources/dataExport/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/dataExport/client/requests/index.ts rename to src/api/resources/preview/resources/dataExport/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/messages/index.ts b/src/api/resources/preview/resources/dataExport/index.ts similarity index 100% rename from src/api/resources/unstable/resources/messages/index.ts rename to src/api/resources/preview/resources/dataExport/index.ts diff --git a/src/api/resources/preview/resources/dataExport/types/index.ts b/src/api/resources/preview/resources/dataExport/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/dataExport/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/dataExport/types/DataExport.ts b/src/api/resources/preview/resources/dataExport/types/types.ts similarity index 67% rename from src/api/resources/unstable/resources/dataExport/types/DataExport.ts rename to src/api/resources/preview/resources/dataExport/types/types.ts index c846e2bb..99833c73 100644 --- a/src/api/resources/unstable/resources/dataExport/types/DataExport.ts +++ b/src/api/resources/preview/resources/dataExport/types/types.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. /** - * The data export api is used to view all message sent & viewed in a given timeframe. + * The data export API is used to export message delivery and engagement statistics for outbound content (Emails, Posts, Custom Bots, Surveys, Tours, Series, and more) sent in a given timeframe. The exported data includes who received each message, when they received it, and how they engaged with it (opens, clicks, replies, completions, dismissals, unsubscribes, and bounces). */ export interface DataExport { /** The identifier for your job. */ diff --git a/src/api/resources/preview/resources/ecommerceConnectors/client/Client.ts b/src/api/resources/preview/resources/ecommerceConnectors/client/Client.ts new file mode 100644 index 00000000..5e0997b2 --- /dev/null +++ b/src/api/resources/preview/resources/ecommerceConnectors/client/Client.ts @@ -0,0 +1,258 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace EcommerceConnectorsClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Upload and manage product catalogs via ecommerce connectors. Supports single-file + * uploads (up to 99 MB) and multipart uploads for larger catalogs. + */ +export class EcommerceConnectorsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: EcommerceConnectorsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Upload a product catalog to an ecommerce connector. The catalog must be a JSON + * array of product objects. There are two upload modes: + * + * **Single-file upload** — POST a single catalog file (up to 99 MB per request). + * Omit `finalize` and `import_job_id`. Returns `202 Accepted` when sync has started. + * + * **Multipart upload** — For catalogs that must be split across multiple requests: + * + * 1. POST the first part with `finalize=false` (no `import_job_id`). The response + * returns an `import_job_id` and `next_part_number`. + * 2. POST each subsequent part with `finalize=false`, the `import_job_id` from step 1, + * and the `part_number` from the previous response. Each part must be ≤ 99 MB. + * 3. POST with `finalize=true` and the `import_job_id` to complete the upload and + * start the sync. No catalog file is required in the finalization request. + * + * Part uploads are idempotent — retrying the same `part_number` does not create + * a duplicate. If a response is lost, retry with the same `part_number`. + * + * ## Product object structure + * + * The catalog file must be a JSON array where each element is a product object. + * Only `id`, `title`, and `url` are required — all other fields are optional. + * + * | Field | Type | Required | Description | + * |---|---|---|---| + * | `id` | string | ✓ | Your unique product identifier. Used to match products on re-upload so only changed products are re-indexed. Also the delete key — any product ID absent from a new upload is removed from Fin's knowledge. Must be stable across uploads. | + * | `title` | string | ✓ | Product name. Used by Fin when searching for and recommending products. | + * | `url` | string | ✓ | Canonical product page URL shown in Fin's product recommendations. Must be a valid `https://` URL. | + * | `description` | string | | Product description that Fin reads to understand what the product is. HTML formatting is supported and safely sanitized (`description_html` takes precedence if both are provided). This is the primary field Fin uses to match products to shopper questions — a richer description leads to better recommendations. | + * | `featured_image_url` | string | | Primary product image shown in Fin's recommendation cards. Falls back to the first entry of `image_urls` if not provided. If no valid image can be resolved for a variant, that variant's card is not shown to the shopper. | + * | `image_urls` | string[] | | Additional product images. Used as a fallback when `featured_image_url` is absent or when a variant has no specific image. | + * | `price_min` | number | | Lowest price across all variants. If omitted, derived automatically from variant prices. Fin uses this to filter products when a shopper mentions a budget (e.g. "under $100"). Displayed as a range alongside `price_max`, or as a single value if both are equal. | + * | `price_max` | number | | Highest price across all variants. If omitted, derived from variant prices. Used alongside `price_min` for budget filtering and price display. | + * | `currency` | string | | ISO 4217 currency code (e.g. `"USD"`, `"EUR"`, `"GBP"`). Defaults to USD if omitted. Used to format prices with the correct symbol in Fin's responses and product cards. | + * | `in_stock` | boolean | | Whether the product is available to purchase. If omitted, derived from variant stock — the product is in stock if at least one variant has `in_stock: true`. Products with no in-stock variants are hidden from Fin entirely. | + * | `category_path` | string or string[] | Strongly recommended | Hierarchical category breadcrumb (e.g. `["Clothing", "Outerwear", "Jackets"]`). Fin understands the hierarchy — a shopper asking about "Clothing" sees products from all subcategories underneath it. The most specific category is shown in search results. | + * | `collections` | string[] | Strongly recommended | Collections or groupings this product belongs to in your store. Fin uses collections to understand your catalog's structure and answer questions like "what's in the sale collection?". | + * | `tags` | string[] | | Free-form keywords matching how shoppers phrase needs in chat (e.g. `["waterproof", "gift", "plus-size"]`). Complements `category_path` and `collections`. | + * | `available_options` | object[] | | Option types and their possible values (e.g. `{"name": "Size", "values": ["S", "M", "L"]}`). Fin uses these to understand what choices a shopper can make and to correctly filter variants when asked for a specific size, colour, or other attribute. | + * | `additional_data` | object | | Custom attributes for your business. Fin uses these to show each customer only relevant products. All keys must be consistent across all products in your catalog — the attribute schema is read from the first product in the file. | + * | `variants` | object[] | | Individual purchasable variants. Fin recommends specific variants (not just products), so populating variants with accurate stock, price, and option data leads to more precise recommendations. See the variant table below. | + * + * ### Variant object structure + * + * Each object in the `variants` array may contain: + * + * | Field | Type | Required | Description | + * |---|---|---|---| + * | `id` | string | ✓ | Unique identifier for this variant within the product. | + * | `title` | string | | Variant display name shown to shoppers (e.g. `"Small / Blue"`). | + * | `price` | number | | Price of this specific variant. Fin uses variant prices for precise budget filtering and displays the variant price in recommendation cards. | + * | `compare_at_price` | number | | Original price before a discount. When provided, Fin will naturally mention the saving (e.g. "down from $129 to $99"). | + * | `in_stock` | boolean | | Whether this variant is currently available. Out-of-stock variants are not shown in Fin's recommendation cards and Fin will not suggest them to shoppers. | + * | `image_url` | string | | Image specific to this variant. Takes precedence over the product's `featured_image_url`. Falls back to `featured_image_url`, then `image_urls`. If no valid image can be resolved, this variant's recommendation card will not be shown. | + * | `selected_options` | object[] | | The specific option values that define this variant (e.g. `[{"name": "Size", "value": "Small"}, {"name": "Color", "value": "Blue"}]`). Fin uses these to match shopper requests like "do you have this in medium?" to the correct variant. | + * | `url` | string | | Direct link to this variant's page. Takes precedence over the product URL in recommendation cards. If omitted, constructed automatically as `{product_url}?variant={id}`. | + * + * ### Example catalog file + * + * ```json + * [ + * { + * "id": "prod-12345", + * "title": "Classic Cotton T-Shirt", + * "url": "https://example.com/products/classic-cotton-t-shirt", + * "description": "A comfortable everyday t-shirt.", + * "featured_image_url": "https://cdn.example.com/images/t-shirt.jpg", + * "price_min": 19.99, + * "price_max": 29.99, + * "currency": "USD", + * "in_stock": true, + * "tags": ["organic", "bestseller"], + * "collections": ["Summer Collection"], + * "category_path": "Clothing > T-Shirts", + * "available_options": [ + * {"name": "Size", "values": ["S", "M", "L"]}, + * {"name": "Color", "values": ["White", "Blue"]} + * ], + * "variants": [ + * { + * "id": "var-001", + * "title": "S / White", + * "price": 19.99, + * "in_stock": true, + * "selected_options": [ + * {"name": "Size", "value": "S"}, + * {"name": "Color", "value": "White"} + * ] + * }, + * { + * "id": "var-002", + * "title": "M / Blue", + * "price": 29.99, + * "in_stock": true, + * "selected_options": [ + * {"name": "Size", "value": "M"}, + * {"name": "Color", "value": "Blue"} + * ] + * } + * ], + * "additional_data": { + * "sku": "TSHIRT-WHT-S", + * "vendor": "Acme Apparel" + * } + * } + * ] + * ``` + * + * @param {Intercom.preview.UploadEcommerceCatalogRequest} request + * @param {EcommerceConnectorsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.ConflictError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * @throws {@link Intercom.preview.ServiceUnavailableError} + * + * @example + * import { createReadStream } from "fs"; + * await client.preview.ecommerceConnectors.uploadEcommerceCatalog({ + * id: "42939" + * }) + */ + public uploadEcommerceCatalog( + request: Intercom.preview.UploadEcommerceCatalogRequest, + requestOptions?: EcommerceConnectorsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__uploadEcommerceCatalog(request, requestOptions)); + } + + private async __uploadEcommerceCatalog( + request: Intercom.preview.UploadEcommerceCatalogRequest, + requestOptions?: EcommerceConnectorsClient.RequestOptions, + ): Promise> { + const _request = await core.newFormData(); + if (request.catalog != null) { + await _request.appendFile("catalog", request.catalog); + } + + if (request.finalize != null) { + _request.append("finalize", request.finalize); + } + + if (request.import_job_id != null) { + _request.append("import_job_id", request.import_job_id); + } + + if (request.part_number != null) { + _request.append("part_number", request.part_number.toString()); + } + + const _maybeEncodedRequest = await _request.getRequest(); + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version, ..._maybeEncodedRequest.headers }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ecommerce/connectors/${core.url.encodePathParam(request.id)}/catalog`, + ), + method: "POST", + headers: _headers, + queryParameters: requestOptions?.queryParams, + requestType: "file", + duplex: _maybeEncodedRequest.duplex, + body: _maybeEncodedRequest.body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.EcommerceCatalogUploadPartResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Intercom.preview.ConflictError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + case 503: + throw new Intercom.preview.ServiceUnavailableError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/ecommerce/connectors/{id}/catalog", + ); + } +} diff --git a/src/api/resources/unstable/resources/news/client/index.ts b/src/api/resources/preview/resources/ecommerceConnectors/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/news/client/index.ts rename to src/api/resources/preview/resources/ecommerceConnectors/client/index.ts diff --git a/src/api/resources/preview/resources/ecommerceConnectors/client/requests/UploadEcommerceCatalogRequest.ts b/src/api/resources/preview/resources/ecommerceConnectors/client/requests/UploadEcommerceCatalogRequest.ts new file mode 100644 index 00000000..f6791e8e --- /dev/null +++ b/src/api/resources/preview/resources/ecommerceConnectors/client/requests/UploadEcommerceCatalogRequest.ts @@ -0,0 +1,56 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../../../../core/index.js"; + +/** + * @example + * { + * id: "42939" + * } + */ +export interface UploadEcommerceCatalogRequest { + /** The unique identifier of the ecommerce connector. */ + id: string; + /** + * The catalog JSON file. Required for all requests except finalization + * (`finalize=true`). Must be a valid JSON array of product objects. Max 99 MB. + * + * Each element in the array must conform to the + * [`ecommerce_catalog_product`](/docs/references/preview/rest-api/api.intercom.io/models/ecommerce_catalog_product) schema. + * The `id`, `title`, and `url` fields are required on every product; + * all other fields are optional. Variants, if provided, must conform to the + * [`ecommerce_catalog_variant`](/docs/references/preview/rest-api/api.intercom.io/models/ecommerce_catalog_variant) schema. + */ + catalog?: core.file.Uploadable | undefined; + /** + * Set to `true` to finalize a multipart upload session and start the catalog sync. + * No catalog file is required when finalizing. Set to `false` to upload a part in + * a multipart session. Omit entirely for a single-file upload. + */ + finalize?: UploadEcommerceCatalogRequest.Finalize; + /** + * The import job ID returned from the first multipart upload request. Required + * when uploading subsequent parts (`part_number` ≥ 2) and when finalizing + * a multipart session (`finalize=true`). + */ + import_job_id?: string; + /** + * The sequential part number for a multipart upload. Must be a positive integer. + * The server returns `next_part_number` in each response to guide the next request. + * Retrying the same `part_number` is safe and idempotent. + */ + part_number?: number; +} + +export namespace UploadEcommerceCatalogRequest { + /** + * Set to `true` to finalize a multipart upload session and start the catalog sync. + * No catalog file is required when finalizing. Set to `false` to upload a part in + * a multipart session. Omit entirely for a single-file upload. + */ + export const Finalize = { + True: "true", + False: "false", + } as const; + export type Finalize = (typeof Finalize)[keyof typeof Finalize]; +} diff --git a/src/api/resources/preview/resources/ecommerceConnectors/client/requests/index.ts b/src/api/resources/preview/resources/ecommerceConnectors/client/requests/index.ts new file mode 100644 index 00000000..e6730d39 --- /dev/null +++ b/src/api/resources/preview/resources/ecommerceConnectors/client/requests/index.ts @@ -0,0 +1 @@ +export type { UploadEcommerceCatalogRequest } from "./UploadEcommerceCatalogRequest.js"; diff --git a/src/api/resources/unstable/resources/switch/index.ts b/src/api/resources/preview/resources/ecommerceConnectors/index.ts similarity index 100% rename from src/api/resources/unstable/resources/switch/index.ts rename to src/api/resources/preview/resources/ecommerceConnectors/index.ts diff --git a/src/api/resources/unstable/resources/emails/client/Client.ts b/src/api/resources/preview/resources/emails/client/Client.ts similarity index 81% rename from src/api/resources/unstable/resources/emails/client/Client.ts rename to src/api/resources/preview/resources/emails/client/Client.ts index 80dc6bdf..9450a524 100644 --- a/src/api/resources/unstable/resources/emails/client/Client.ts +++ b/src/api/resources/preview/resources/emails/client/Client.ts @@ -30,20 +30,20 @@ export class EmailsClient { * * @param {EmailsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.emails.listEmails() + * await client.preview.emails.listEmails() */ public listEmails( requestOptions?: EmailsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listEmails(requestOptions)); } private async __listEmails( requestOptions?: EmailsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -68,14 +68,14 @@ export class EmailsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.EmailList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.EmailList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -93,28 +93,28 @@ export class EmailsClient { /** * Fetches a specific email setting by its unique identifier * - * @param {Intercom.unstable.RetrieveEmailRequest} request + * @param {Intercom.preview.RetrieveEmailRequest} request * @param {EmailsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.emails.retrieveEmail({ + * await client.preview.emails.retrieveEmail({ * id: "id" * }) */ public retrieveEmail( - request: Intercom.unstable.RetrieveEmailRequest, + request: Intercom.preview.RetrieveEmailRequest, requestOptions?: EmailsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__retrieveEmail(request, requestOptions)); } private async __retrieveEmail( - request: Intercom.unstable.RetrieveEmailRequest, + request: Intercom.preview.RetrieveEmailRequest, requestOptions?: EmailsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -140,18 +140,18 @@ export class EmailsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.EmailSetting, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.EmailSetting, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/unstable/resources/notes/client/index.ts b/src/api/resources/preview/resources/emails/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/notes/client/index.ts rename to src/api/resources/preview/resources/emails/client/index.ts diff --git a/src/api/resources/unstable/resources/emails/client/requests/RetrieveEmailRequest.ts b/src/api/resources/preview/resources/emails/client/requests/RetrieveEmailRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/emails/client/requests/RetrieveEmailRequest.ts rename to src/api/resources/preview/resources/emails/client/requests/RetrieveEmailRequest.ts diff --git a/src/api/resources/unstable/resources/emails/client/requests/index.ts b/src/api/resources/preview/resources/emails/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/emails/client/requests/index.ts rename to src/api/resources/preview/resources/emails/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/news/index.ts b/src/api/resources/preview/resources/emails/index.ts similarity index 100% rename from src/api/resources/unstable/resources/news/index.ts rename to src/api/resources/preview/resources/emails/index.ts diff --git a/src/api/resources/preview/resources/emails/types/index.ts b/src/api/resources/preview/resources/emails/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/emails/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/emails/types/EmailSetting.ts b/src/api/resources/preview/resources/emails/types/types.ts similarity index 79% rename from src/api/resources/unstable/resources/emails/types/EmailSetting.ts rename to src/api/resources/preview/resources/emails/types/types.ts index bd584aec..c4196128 100644 --- a/src/api/resources/unstable/resources/emails/types/EmailSetting.ts +++ b/src/api/resources/preview/resources/emails/types/types.ts @@ -1,5 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Intercom from "../../../../../index.js"; + /** * Represents a sender email address configuration */ @@ -25,3 +27,12 @@ export interface EmailSetting { /** Unix timestamp of last modification */ updated_at?: number; } + +/** + * A list of email settings + */ +export interface EmailList { + /** The type of object */ + type?: string; + data?: Intercom.preview.EmailSetting[]; +} diff --git a/src/api/resources/preview/resources/finAgent/client/Client.ts b/src/api/resources/preview/resources/finAgent/client/Client.ts new file mode 100644 index 00000000..9beeb770 --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/client/Client.ts @@ -0,0 +1,906 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace FinAgentClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Access Fin programmatically via the Fin Agent API endpoints. + * + *   + * + * {% admonition type="warning" %} + * Please reach out to your accounts team to discuss access and tailored, hands-on support. + * {% /admonition %} + * + *   + * + * Integration is centered around two endpoints (`/fin/start` and `/fin/reply`) and a set of events that notify your application of Fin's status and responses. Events can be delivered via webhooks or Server-Sent Events (SSE). You can also record a customer satisfaction rating with `/fin/csat`. + * + *   + * + * **Events** + * + * Configure a webhook endpoint in the Fin Agent API settings to receive events, or use the `sse_subscription_url` from the API response to subscribe via SSE. See the [setup guide](/docs/guides/fin-agent-api/setup) for configuration details. + * + * - `fin_status_updated` - Fired when Fin's status changes (escalated, resolved, complete) + * - `fin_replied` - Fired when Fin sends a reply to the user + * - `fin_reply_chunk` - SSE-only streaming event fired during reply generation (requires streaming enabled) + * - `csat_requested` - Fired when Fin asks the user to rate the conversation (submit the choice with `POST /fin/csat`) + * + * All webhook requests include an `X-Fin-Agent-API-Webhook-Signature` header for request validation. + */ +export class FinAgentClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: FinAgentClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Return a machine-readable, per-user list of what Fin can do for a given end user, so an + * orchestrating agent can decide which endpoint to call. + * + * The response is audience-matched to the supplied user: each live, API-triggerable + * procedure is checked against that user before being included, alongside the static + * `reply` and `ask` actions. + * + * @param {Intercom.preview.ListFinCapabilitiesRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.finAgent.listFinCapabilities({ + * user: { + * id: "123456" + * } + * }) + */ + public listFinCapabilities( + request: Intercom.preview.ListFinCapabilitiesRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listFinCapabilities(request, requestOptions)); + } + + private async __listFinCapabilities( + request: Intercom.preview.ListFinCapabilitiesRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/capabilities", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.ListFinCapabilitiesResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/capabilities"); + } + + /** + * Ask Fin a single, self-contained question and receive one informational answer. + * + * Unlike a conversation, `/fin/ask` is non-conversational: Fin will not ask follow-up + * questions, will not run procedures, and will not escalate to a human on its own. You can + * still escalate one yourself with `POST /fin/escalate`; the ask conversation is already + * closed after its one-shot answer, and escalation leaves it closed while routing the + * handoff separately. + * + * Fin's answer is delivered asynchronously via the `fin_replied` event. The conversation + * ends with a `complete` status — there is no `awaiting_user_reply` cycle. + * + * @param {Intercom.preview.AskFinRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.finAgent.askFin({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How do I reset my password?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * }) + * + * @example + * await client.preview.finAgent.askFin({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "And how long does that take to apply?", + * timestamp: "2025-01-24T10:02:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com", + * attributes: { + * "plan_type": "Pro" + * } + * }, + * conversation_metadata: { + * history: [{ + * author: "user", + * body: "How do I reset my password?", + * timestamp: "2025-01-24T10:01:20Z" + * }], + * attributes: { + * "order_id": "98765" + * } + * } + * }) + */ + public askFin( + request: Intercom.preview.AskFinRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__askFin(request, requestOptions)); + } + + private async __askFin( + request: Intercom.preview.AskFinRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/ask", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.AskFinResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/ask"); + } + + /** + * Send a follow-up message in an existing conversation. When Fin needs more information to + * complete an action, it sets the conversation to `awaiting_user_reply` — send the user's + * response so Fin can continue. + * + * @param {Intercom.preview.ReplyToFinRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.finAgent.replyToFin({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here's the information you requested.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * }) + * + * @example + * await client.preview.finAgent.replyToFin({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Thanks, here is my order number.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "Jane Smith", + * email: "jane.smith@example.com" + * }, + * settings: { + * follow_up_questions: false, + * email: true + * } + * }) + * + * @example + * await client.preview.finAgent.replyToFin({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here's the invoice you asked for.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * attachments: [{ + * type: "url", + * url: "https://example.com/invoice.pdf" + * }] + * }) + */ + public replyToFin( + request: Intercom.preview.ReplyToFinRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__replyToFin(request, requestOptions)); + } + + private async __replyToFin( + request: Intercom.preview.ReplyToFinRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/reply", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.ReplyToFinResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/reply"); + } + + /** + * Deterministically run a specific procedure on a new conversation. Calling this endpoint + * guarantees that the named procedure runs — there is no non-deterministic routing. + * + * Fin's progress is delivered asynchronously via events or Server-Sent Events. If the + * procedure pauses for user input, the conversation status becomes `awaiting_user_reply` — + * send the user's response with [`/fin/reply`](/docs/references/preview/rest-api/api.intercom.io/fin-agent/replytofin). + * + * @param {Intercom.preview.RunFinProcedureRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.finAgent.runFinProcedure({ + * procedure_id: "12345", + * conversation_id: "ext-123", + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * }) + * + * @example + * await client.preview.finAgent.runFinProcedure({ + * procedure_id: "12345", + * conversation_id: "ext-123", + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * message: { + * author: "agent", + * body: "Starting your refund request." + * }, + * conversation_metadata: { + * attributes: { + * "order_id": "98765" + * } + * }, + * settings: { + * email: true + * } + * }) + */ + public runFinProcedure( + request: Intercom.preview.RunFinProcedureRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__runFinProcedure(request, requestOptions)); + } + + private async __runFinProcedure( + request: Intercom.preview.RunFinProcedureRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const { procedure_id: procedureId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `fin/procedures/${core.url.encodePathParam(procedureId)}/run`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.RunFinProcedureResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/fin/procedures/{procedure_id}/run", + ); + } + + /** + * Hand a conversation off to a human teammate. If you use the Intercom Helpdesk, the + * handoff lands in your team inbox. + * + * Provide either `conversation_id` or `user`: + * + * - `conversation_id` — escalate an existing agent conversation, including one started + * with `/fin/ask`. On the Intercom Helpdesk, Fin by default summarises the conversation + * and opens a new Helpdesk conversation that carries the summary as an internal note. + * Escalation does not change the original agent conversation's assignment or open/closed + * state. Configure an escalation Operator Workflow to change this default. + * - `user` — escalate on behalf of a user with no prior agent conversation. On the Intercom + * Helpdesk, a new Helpdesk conversation is created for the teammate. Not supported on Fin + * for Platforms — see below. + * + * In both cases, pass the optional `context` to give the receiving teammate background your + * orchestrating agent has and Fin does not. On the Intercom Helpdesk, it appears above the + * summary in the internal note of the new conversation the teammate picks up. It is never + * shown to the end user. + * + * Escalating an existing conversation also sets its AI Agent resolution state to + * `escalated`, readable as `ai_agent.resolution_state` on the Conversations API. This is a + * resolution state, not a billable resolution. + * + * On Fin for Platforms, `conversation_id` is required — `user` is not supported and is + * rejected, because there is no Intercom Helpdesk in which to create a conversation. There + * is no Intercom inbox either, so an escalation that no workflow handles does not open a + * Helpdesk conversation for a teammate. `context` is not surfaced, and the conversation is + * left open for your platform to hand off and continue driving. + * + * You are notified over the existing webhook or SSE channel with an `escalated` status + * followed by `complete`. The `complete` status signals that Fin is done; it does not close + * the conversation. On the Intercom Helpdesk, the new human conversation remains open; on + * Fin for Platforms, the conversation remains open for whoever handles it on your platform. + * + * @param {unknown} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.finAgent.escalateFinConversation({ + * "conversation_id": "ext-123", + * "context": "Customer is requesting a refund and is frustrated." + * }) + * + * @example + * await client.preview.finAgent.escalateFinConversation({ + * "user": { + * "id": "123456", + * "name": "John Doe", + * "email": "john.doe@example.com" + * }, + * "context": "I need help with my billing issue" + * }) + */ + public escalateFinConversation( + request?: unknown, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__escalateFinConversation(request, requestOptions)); + } + + private async __escalateFinConversation( + request?: unknown, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/escalate", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.EscalateFinConversationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/escalate"); + } + + /** + * Record a customer's satisfaction rating for a conversation, with an optional free-text + * remark. + * + * Fin decides *when* to ask for a rating — this reuses the CSAT settings on your Fin + * workflow, not this API. When Fin asks, it fires a `csat_requested` event over webhooks or + * SSE carrying the rating options to show the user. Present those options, then submit the + * user's choice here. + * + * Submitting the same rating again, with no new remark, is a no-op and stays successful, + * so an at-least-once client can safely retry. Submitting a *different* rating updates the + * stored rating while the update window is still open, and a first remark can be added to + * an already-rated survey. Once a remark has been recorded the rating is locked and can no + * longer be changed. + * + * @param {Intercom.preview.SubmitFinCsatRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.finAgent.submitFinCsat({ + * conversation_id: "ext-123", + * rating: "amazing" + * }) + * + * @example + * await client.preview.finAgent.submitFinCsat({ + * conversation_id: "ext-123", + * rating: "amazing", + * remark: "Fin solved my problem in seconds." + * }) + */ + public submitFinCsat( + request: Intercom.preview.SubmitFinCsatRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__submitFinCsat(request, requestOptions)); + } + + private async __submitFinCsat( + request: Intercom.preview.SubmitFinCsatRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/csat", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.SubmitFinCsatResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/csat"); + } + + /** + * {% admonition type="info" name="Legacy — conversational mode" %} + * `/fin/start` powers the conversational model, where your own UI drives a back-and-forth with Fin. This endpoint is no longer actively developed and is maintained only for existing integrations — new functionality lands on the orchestration endpoints. + * {% /admonition %} + * + * Initialize Fin by passing it the user's message along with conversation history and user details. + * + * These additional pieces of context will be used by Fin to provide a better and more contextual answer to the user. + * + * Once Fin is initialized, it progresses through a series of statuses such as *thinking*, *replying*, *awaiting_user_reply*, or *resolved* before ending with a status of *complete*. + * + * During this workflow, the client should allow Fin to continue uninterrupted until a final *complete* status is returned, at which point control of the conversation passes back to the client. + * + * Events can be received via webhooks or Server-Sent Events (SSE) using the `sse_subscription_url` in the response. + * + * @param {Intercom.preview.StartFinConversationRequest} request + * @param {FinAgentClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.finAgent.startFinConversation({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * }) + * + * @example + * await client.preview.finAgent.startFinConversation({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I resolve my outstanding invoice?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "Jane Smith", + * email: "jane.smith@example.com" + * }, + * settings: { + * follow_up_questions: false, + * email: true + * } + * }) + * + * @example + * await client.preview.finAgent.startFinConversation({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com", + * attributes: { + * "plan_type": "Pro", + * "subscription_status": "active" + * } + * }, + * conversation_metadata: { + * history: [{ + * author: "user", + * body: "I need help", + * timestamp: "2025-01-24T10:00:01Z" + * }, { + * author: "agent", + * body: "What do you need help with?", + * timestamp: "2025-01-24T10:01:00Z" + * }], + * attributes: { + * "priority_level": "high", + * "department": "sales" + * } + * } + * }) + * + * @example + * await client.preview.finAgent.startFinConversation({ + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here is a screenshot of the issue", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * attachments: [{ + * type: "url", + * url: "https://example.com/document.pdf" + * }, { + * type: "file", + * name: "screenshot.png", + * content_type: "image/png", + * data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk..." + * }] + * }) + */ + public startFinConversation( + request: Intercom.preview.StartFinConversationRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__startFinConversation(request, requestOptions)); + } + + private async __startFinConversation( + request: Intercom.preview.StartFinConversationRequest, + requestOptions?: FinAgentClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "fin/start", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.StartFinConversationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin/start"); + } +} diff --git a/src/api/resources/unstable/resources/segments/client/index.ts b/src/api/resources/preview/resources/finAgent/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/segments/client/index.ts rename to src/api/resources/preview/resources/finAgent/client/index.ts diff --git a/src/api/resources/preview/resources/finAgent/client/requests/AskFinRequest.ts b/src/api/resources/preview/resources/finAgent/client/requests/AskFinRequest.ts new file mode 100644 index 00000000..d33a7801 --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/client/requests/AskFinRequest.ts @@ -0,0 +1,87 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How do I reset my password?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "And how long does that take to apply?", + * timestamp: "2025-01-24T10:02:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com", + * attributes: { + * "plan_type": "Pro" + * } + * }, + * conversation_metadata: { + * history: [{ + * author: "user", + * body: "How do I reset my password?", + * timestamp: "2025-01-24T10:01:20Z" + * }], + * attributes: { + * "order_id": "98765" + * } + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How do I reset my password?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How do I reset my password?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + */ +export interface AskFinRequest { + /** Your external conversation ID. Fin creates a conversation for this ID. If a conversation already exists for it, use `/fin/reply` instead. */ + conversation_id: string; + message: Intercom.preview.FinAgentMessage; + user: Intercom.preview.FinAgentUser; + conversation_metadata?: Intercom.preview.FinAgentConversationMetadata; + /** An array of attachments to include with the message. Maximum of 10 attachments. */ + attachments?: Intercom.preview.FinAgentAttachment[]; +} diff --git a/src/api/resources/preview/resources/finAgent/client/requests/ListFinCapabilitiesRequest.ts b/src/api/resources/preview/resources/finAgent/client/requests/ListFinCapabilitiesRequest.ts new file mode 100644 index 00000000..795cb10e --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/client/requests/ListFinCapabilitiesRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * user: { + * id: "123456" + * } + * } + */ +export interface ListFinCapabilitiesRequest { + user: Intercom.preview.FinAgentUser; +} diff --git a/src/api/resources/preview/resources/finAgent/client/requests/ReplyToFinRequest.ts b/src/api/resources/preview/resources/finAgent/client/requests/ReplyToFinRequest.ts new file mode 100644 index 00000000..adab8bf8 --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/client/requests/ReplyToFinRequest.ts @@ -0,0 +1,97 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here's the information you requested.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Thanks, here is my order number.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "Jane Smith", + * email: "jane.smith@example.com" + * }, + * settings: { + * follow_up_questions: false, + * email: true + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here's the invoice you asked for.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * attachments: [{ + * type: "url", + * url: "https://example.com/invoice.pdf" + * }] + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here's the information you requested.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here's the information you requested.", + * timestamp: "2025-01-24T09:01:00Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + */ +export interface ReplyToFinRequest { + /** The ID of the conversation. */ + conversation_id: string; + message: Intercom.preview.FinAgentMessage; + user: Intercom.preview.FinAgentUser; + /** An array of attachments to include with the message. Maximum of 10 attachments. */ + attachments?: Intercom.preview.FinAgentAttachment[]; + settings?: Intercom.preview.FinAgentSettings; +} diff --git a/src/api/resources/preview/resources/finAgent/client/requests/RunFinProcedureRequest.ts b/src/api/resources/preview/resources/finAgent/client/requests/RunFinProcedureRequest.ts new file mode 100644 index 00000000..8677a014 --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/client/requests/RunFinProcedureRequest.ts @@ -0,0 +1,91 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * procedure_id: "12345", + * conversation_id: "ext-123", + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * procedure_id: "12345", + * conversation_id: "ext-123", + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * message: { + * author: "agent", + * body: "Starting your refund request." + * }, + * conversation_metadata: { + * attributes: { + * "order_id": "98765" + * } + * }, + * settings: { + * email: true + * } + * } + * + * @example + * { + * procedure_id: "12345", + * conversation_id: "ext-123", + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * procedure_id: "12345", + * conversation_id: "ext-123", + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + */ +export interface RunFinProcedureRequest { + /** The ID of the procedure to run. */ + procedure_id: string; + /** Your external conversation ID. Fin creates a conversation for this ID. If a conversation already exists for it, use `/fin/reply` instead. */ + conversation_id: string; + user: Intercom.preview.FinAgentUser; + message?: Intercom.preview.FinAgentMessage; + /** Metadata about the conversation. Only attributes are accepted (no history). */ + conversation_metadata?: RunFinProcedureRequest.ConversationMetadata; + /** Optional settings to control Fin's behaviour for this procedure run. */ + settings?: RunFinProcedureRequest.Settings; +} + +export namespace RunFinProcedureRequest { + /** + * Metadata about the conversation. Only attributes are accepted (no history). + */ + export interface ConversationMetadata { + /** A hash of conversation attributes. Limit to 10 attributes. */ + attributes?: Record; + } + + /** + * Optional settings to control Fin's behaviour for this procedure run. + */ + export interface Settings { + /** When `true`, Fin formats its replies as email-style responses. Defaults to `false` (chat-style). */ + email?: boolean; + } +} diff --git a/src/api/resources/preview/resources/finAgent/client/requests/StartFinConversationRequest.ts b/src/api/resources/preview/resources/finAgent/client/requests/StartFinConversationRequest.ts new file mode 100644 index 00000000..39d10b62 --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/client/requests/StartFinConversationRequest.ts @@ -0,0 +1,137 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I resolve my outstanding invoice?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "Jane Smith", + * email: "jane.smith@example.com" + * }, + * settings: { + * follow_up_questions: false, + * email: true + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com", + * attributes: { + * "plan_type": "Pro", + * "subscription_status": "active" + * } + * }, + * conversation_metadata: { + * history: [{ + * author: "user", + * body: "I need help", + * timestamp: "2025-01-24T10:00:01Z" + * }, { + * author: "agent", + * body: "What do you need help with?", + * timestamp: "2025-01-24T10:01:00Z" + * }], + * attributes: { + * "priority_level": "high", + * "department": "sales" + * } + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "Here is a screenshot of the issue", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * }, + * attachments: [{ + * type: "url", + * url: "https://example.com/document.pdf" + * }, { + * type: "file", + * name: "screenshot.png", + * content_type: "image/png", + * data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk..." + * }] + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + * + * @example + * { + * conversation_id: "ext-123", + * message: { + * author: "user", + * body: "How can I see my account details?", + * timestamp: "2025-01-24T10:01:20Z" + * }, + * user: { + * id: "123456", + * name: "John Doe", + * email: "john.doe@example.com" + * } + * } + */ +export interface StartFinConversationRequest { + /** The ID of the conversation that is calling Fin via this API. */ + conversation_id: string; + message: Intercom.preview.FinAgentMessage; + user: Intercom.preview.FinAgentUser; + /** An array of attachments to include with the message. Maximum of 10 attachments. */ + attachments?: Intercom.preview.FinAgentAttachment[]; + conversation_metadata?: Intercom.preview.FinAgentConversationMetadata; + settings?: Intercom.preview.FinAgentSettings; +} diff --git a/src/api/resources/preview/resources/finAgent/client/requests/SubmitFinCsatRequest.ts b/src/api/resources/preview/resources/finAgent/client/requests/SubmitFinCsatRequest.ts new file mode 100644 index 00000000..8d3e7d5a --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/client/requests/SubmitFinCsatRequest.ts @@ -0,0 +1,36 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * conversation_id: "ext-123", + * rating: "amazing" + * } + * + * @example + * { + * conversation_id: "ext-123", + * rating: "amazing", + * remark: "Fin solved my problem in seconds." + * } + */ +export interface SubmitFinCsatRequest { + /** Your external conversation ID — the same ID you started the conversation with, and the one echoed on the `csat_requested` event. */ + conversation_id: string; + /** The rating the user selected — one of the `key` values from the `csat_requested` event's options. */ + rating: SubmitFinCsatRequest.Rating; + /** Optional free-text comment the user left alongside the rating. Can be added to an already-rated survey, but only once — the rating locks after a remark is recorded. */ + remark?: string; +} + +export namespace SubmitFinCsatRequest { + /** The rating the user selected — one of the `key` values from the `csat_requested` event's options. */ + export const Rating = { + Terrible: "terrible", + Bad: "bad", + Ok: "ok", + Good: "good", + Amazing: "amazing", + } as const; + export type Rating = (typeof Rating)[keyof typeof Rating]; +} diff --git a/src/api/resources/preview/resources/finAgent/client/requests/index.ts b/src/api/resources/preview/resources/finAgent/client/requests/index.ts new file mode 100644 index 00000000..043032db --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/client/requests/index.ts @@ -0,0 +1,6 @@ +export type { AskFinRequest } from "./AskFinRequest.js"; +export type { ListFinCapabilitiesRequest } from "./ListFinCapabilitiesRequest.js"; +export type { ReplyToFinRequest } from "./ReplyToFinRequest.js"; +export type { RunFinProcedureRequest } from "./RunFinProcedureRequest.js"; +export type { StartFinConversationRequest } from "./StartFinConversationRequest.js"; +export type { SubmitFinCsatRequest } from "./SubmitFinCsatRequest.js"; diff --git a/src/api/resources/unstable/resources/notes/index.ts b/src/api/resources/preview/resources/finAgent/index.ts similarity index 100% rename from src/api/resources/unstable/resources/notes/index.ts rename to src/api/resources/preview/resources/finAgent/index.ts diff --git a/src/api/resources/preview/resources/finAgent/types/index.ts b/src/api/resources/preview/resources/finAgent/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/finAgent/types/types.ts b/src/api/resources/preview/resources/finAgent/types/types.ts new file mode 100644 index 00000000..18491d36 --- /dev/null +++ b/src/api/resources/preview/resources/finAgent/types/types.ts @@ -0,0 +1,525 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +export interface ListFinCapabilitiesResponse { + /** The API version the capabilities document was generated for. */ + version?: string; + /** The list of capabilities available to this user. */ + capabilities?: ListFinCapabilitiesResponse.Capabilities.Item[]; +} + +export namespace ListFinCapabilitiesResponse { + export type Capabilities = Capabilities.Item[]; + + export namespace Capabilities { + export interface Item { + /** The kind of capability — `procedure` for a runnable procedure, or a static action such as `reply`, `ask`, or `escalate`. */ + type?: string; + /** The procedure ID. Present only when `type` is `procedure`. */ + id?: string; + /** The procedure name. Present only when `type` is `procedure`. */ + name?: string; + /** A human-readable description of the capability. */ + description?: string; + /** The endpoint path to call to use this capability. */ + endpoint?: string; + /** The HTTP method to use. */ + method?: string; + } + } +} + +export interface AskFinResponse { + /** The external ID of the conversation. */ + conversation_id?: string; + /** The ID of the user. */ + user_id?: string; + /** Fin's current status in the conversation workflow. */ + status?: AskFinResponse.Status; + /** The timestamp the response was created at, with millisecond precision. */ + created_at_ms?: string; + errors?: Intercom.preview.FinAgentAttributeErrors; + /** Optional. A URL to subscribe to Server-Sent Events (SSE) for this conversation, if SSE is enabled. The access token is a JWT with a 3-minute TTL. The token is revoked when Fin sets the conversation to complete status. When CSAT is enabled and a survey will follow the resolution, `complete` revocation is deferred until the `csat_requested` event is delivered or the token expires. */ + sse_subscription_url?: string; +} + +export namespace AskFinResponse { + /** Fin's current status in the conversation workflow. */ + export const Status = { + Thinking: "thinking", + Replying: "replying", + Resolved: "resolved", + Complete: "complete", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +export interface ReplyToFinResponse { + /** The ID of the conversation. */ + conversation_id?: string; + /** The ID of the user. */ + user_id?: string; + /** Fin's current status in the conversation workflow. */ + status?: ReplyToFinResponse.Status; + /** The timestamp the response was created at, with millisecond precision. */ + created_at_ms?: string; + errors?: Intercom.preview.FinAgentAttributeErrors; + /** Optional. A URL to subscribe to Server-Sent Events (SSE) for this conversation, if SSE is enabled. The access token is a JWT with a 3-minute TTL. The token is revoked when Fin sets the conversation to awaiting_user_reply or complete status. When CSAT is enabled and a survey will follow the resolution, `complete` revocation is deferred until the `csat_requested` event is delivered or the token expires. */ + sse_subscription_url?: string; +} + +export namespace ReplyToFinResponse { + /** Fin's current status in the conversation workflow. */ + export const Status = { + Thinking: "thinking", + Replying: "replying", + AwaitingUserReply: "awaiting_user_reply", + Escalated: "escalated", + Resolved: "resolved", + Complete: "complete", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +export interface RunFinProcedureResponse { + /** The ID of the conversation. */ + conversation_id?: string; + /** The ID of the user. */ + user_id?: string; + /** The ID of the procedure that was run. */ + procedure_id?: string; + /** Fin's current status in the conversation workflow. */ + status?: RunFinProcedureResponse.Status; + /** The timestamp the response was created at, with millisecond precision. */ + created_at_ms?: string; + errors?: Intercom.preview.FinAgentAttributeErrors; + /** Optional. A URL to subscribe to Server-Sent Events (SSE) for this conversation, if SSE is enabled. The access token is a JWT with a 3-minute TTL. The token is revoked when Fin sets the conversation to awaiting_user_reply or complete status. When CSAT is enabled and a survey will follow the resolution, `complete` revocation is deferred until the `csat_requested` event is delivered or the token expires. */ + sse_subscription_url?: string; +} + +export namespace RunFinProcedureResponse { + /** Fin's current status in the conversation workflow. */ + export const Status = { + Thinking: "thinking", + Replying: "replying", + AwaitingUserReply: "awaiting_user_reply", + Escalated: "escalated", + Resolved: "resolved", + Complete: "complete", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +export interface EscalateFinConversationResponse { + /** The external ID of the conversation. Returned when you escalate an existing conversation by `conversation_id` (echoed back). When you escalate a `user`, a new conversation is created and only `intercom_conversation_id` is returned. */ + conversation_id?: string; + /** The internal Intercom conversation ID. Returned when a new conversation was created for the escalation. */ + intercom_conversation_id?: string; + /** Optional. A URL to subscribe to Server-Sent Events (SSE) for this conversation, if SSE is enabled. The access token is a JWT with a 3-minute TTL. The token is revoked when Fin sets the conversation to complete status. When CSAT is enabled and a survey will follow the resolution, `complete` revocation is deferred until the `csat_requested` event is delivered or the token expires. Includes a `rewind` window so a subscriber that connects after the escalation is processed can still receive the `escalated` and `complete` events. */ + sse_subscription_url?: string; + /** The resulting status of the conversation. */ + status?: "escalated"; +} + +export interface SubmitFinCsatResponse { + /** The external ID of the rated conversation. */ + conversation_id?: string; + /** The rating now recorded on the conversation. */ + rating?: SubmitFinCsatResponse.Rating; + /** The result of the submission. */ + status?: "rated"; +} + +export namespace SubmitFinCsatResponse { + /** The rating now recorded on the conversation. */ + export const Rating = { + Terrible: "terrible", + Bad: "bad", + Ok: "ok", + Good: "good", + Amazing: "amazing", + } as const; + export type Rating = (typeof Rating)[keyof typeof Rating]; +} + +export interface StartFinConversationResponse { + /** The ID of the conversation. */ + conversation_id?: string; + /** The ID of the user. */ + user_id?: string; + /** Fin's current status in the conversation workflow. */ + status?: StartFinConversationResponse.Status; + /** The timestamp the response was created at, with millisecond precision. */ + created_at_ms?: string; + errors?: Intercom.preview.FinAgentAttributeErrors; + /** Optional. A URL to subscribe to Server-Sent Events (SSE) for this conversation, if SSE is enabled. The access token is a JWT with a 3-minute TTL. The token is revoked when Fin sets the conversation to awaiting_user_reply or complete status. When CSAT is enabled and a survey will follow the resolution, `complete` revocation is deferred until the `csat_requested` event is delivered or the token expires. */ + sse_subscription_url?: string; +} + +export namespace StartFinConversationResponse { + /** Fin's current status in the conversation workflow. */ + export const Status = { + Thinking: "thinking", + Replying: "replying", + AwaitingUserReply: "awaiting_user_reply", + Escalated: "escalated", + Resolved: "resolved", + Complete: "complete", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +/** + * A message exchanged within a Fin Agent conversation. + */ +export interface FinAgentMessage { + /** The author that created the message. */ + author: FinAgentMessage.Author; + /** + * The body of the message. Accepts both plain text and HTML format. + * When sending a message to Fin, this should contain the user's message. + * Fin's response will be returned as HTML. + */ + body: string; + /** + * The timestamp when the message was created. + * Used to deduplicate messages sent within a 5 minute window. + * Ideally should include milliseconds for higher precision. + */ + timestamp?: string; + /** + * The timestamp when the message was created, with millisecond precision. + * Only present in event responses (fin_replied). + */ + timestamp_ms?: string; +} + +export namespace FinAgentMessage { + /** The author that created the message. */ + export const Author = { + User: "user", + Agent: "agent", + Fin: "fin", + } as const; + export type Author = (typeof Author)[keyof typeof Author]; +} + +/** + * A user object representing the user in a Fin Agent conversation. + */ +export interface FinAgentUser { + /** + * The ID of the user. This value will be used to uniquely identify the user + * during a conversation with Fin. Maps to the user_id field on the Intercom User object. + */ + id: string; + /** The name of the user. */ + name?: string; + /** The email of the user. */ + email?: string; + /** + * A hash of attributes associated with the user. + * Attributes can be used by Fin to target content and responses. + * Limit to 10 attributes. + */ + attributes?: Record; +} + +/** + * An attachment object representing a file or URL attachment included with a message. + * Attachments can be used to provide additional context to Fin. + * Maximum of 10 attachments per request. + */ +export interface FinAgentAttachment { + /** The type of attachment. */ + type: FinAgentAttachment.Type; + /** The URL of the attachment. Required when type is 'url'. Must be publicly accessible. */ + url?: string; + /** The name of the file. Required when type is 'file'. */ + name?: string; + /** The MIME type of the file. Required when type is 'file'. */ + content_type?: string; + /** Base64-encoded file data. Required when type is 'file'. */ + data?: string; +} + +export namespace FinAgentAttachment { + /** The type of attachment. */ + export const Type = { + Url: "url", + File: "file", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * Metadata about the conversation, including history and attributes. + */ +export interface FinAgentConversationMetadata { + /** + * An array of previous messages in the conversation before Fin is initialized. + * This data provides context to Fin and helps generate a better answer. + * Limit to the last 10 messages. + */ + history?: Intercom.preview.FinAgentMessage[]; + /** + * A hash of attributes associated with the conversation. + * These attributes can be used by Fin to provide more contextual responses. + * Limit to 10 attributes. + */ + attributes?: Record; +} + +/** + * Contains error details if any user or conversation attribute updates failed. + */ +export interface FinAgentAttributeErrors { + /** User-related attribute errors. */ + user?: FinAgentAttributeErrors.User; + /** Conversation-related attribute errors. */ + conversation?: FinAgentAttributeErrors.Conversation; +} + +export namespace FinAgentAttributeErrors { + /** + * User-related attribute errors. + */ + export interface User { + /** Map of user attribute names to error messages. */ + attributes?: Record; + } + + /** + * Conversation-related attribute errors. + */ + export interface Conversation { + /** Map of conversation attribute names to error messages. */ + attributes?: Record; + } +} + +/** + * Optional settings to control Fin's behaviour for this request. + */ +export interface FinAgentSettings { + /** + * When `true` (default), Fin may ask clarifying questions and escalate to a human agent + * as needed. + * + * When `false`, Fin operates in non-conversational mode: it will not ask follow-up + * questions and will not escalate to a human agent. Use this when you want Fin to respond + * with a single, self-contained answer — for example, in asynchronous channels where + * back-and-forth conversation is not practical. + */ + follow_up_questions?: boolean; + /** + * When `true`, Fin formats its replies as email-style responses, suitable for sending + * directly to users via email. This adjusts tone and structure to match email conventions + * rather than chat. + * + * Defaults to `false`, which produces chat-style responses. + */ + email?: boolean; +} + +/** + * Event fired when Fin's status changes during a conversation. + * Fin will report its status to the client via this event. + */ +export interface FinAgentStatusUpdatedEvent { + /** The name of the event. */ + event_name: "fin_status_updated"; + /** The ID of the conversation. */ + conversation_id: string; + /** The ID of the user. */ + user_id: string; + /** + * Fin's current status. + * - awaiting_user_reply: Fin has finished replying and is waiting for the user to respond + * - escalated: The conversation has been escalated to a human + * - resolved: The user's query has been resolved + * - complete: Fin has completed its workflow. When CSAT is enabled a csat_requested event may follow, in which case the SSE stream is held open past complete until it is delivered or the token expires + */ + status: FinAgentStatusUpdatedEvent.Status; + /** + * Optional. A human-readable explanation of why the conversation was escalated. + * Only present when status is 'escalated'. + * Possible values include: + * - "Escalation requested by user" + * - "Escalation rule: {rule_name}" + * - "Escalation rule matched" + * - "Routed to team" + * - "Conversation finished without resolution" + */ + reason?: string; + /** The timestamp the event was created at, with millisecond precision. */ + created_at_ms: string; +} + +export namespace FinAgentStatusUpdatedEvent { + /** + * Fin's current status. + * - awaiting_user_reply: Fin has finished replying and is waiting for the user to respond + * - escalated: The conversation has been escalated to a human + * - resolved: The user's query has been resolved + * - complete: Fin has completed its workflow. When CSAT is enabled a csat_requested event may follow, in which case the SSE stream is held open past complete until it is delivered or the token expires + */ + export const Status = { + AwaitingUserReply: "awaiting_user_reply", + Escalated: "escalated", + Resolved: "resolved", + Complete: "complete", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +/** + * Event fired when Fin replies to a user. + * The content of the response will be contained in the message object. + * Intermediate replies have status 'replying'; a separate fin_status_updated + * event with 'awaiting_user_reply' fires once Fin's reply is done. + */ +export interface FinAgentRepliedEvent { + /** The name of the event. */ + event_name: "fin_replied"; + /** The ID of the conversation. */ + conversation_id: string; + /** The ID of the user. */ + user_id: string; + /** Fin's answer to the user's query. */ + message: FinAgentRepliedEvent.Message; + /** + * Fin's current status. + * - replying: Intermediate reply part; more parts may follow + * - awaiting_user_reply: Legacy status; instead use the fin_status_updated event with 'awaiting_user_reply', which fires once Fin's reply is done + */ + status: FinAgentRepliedEvent.Status; + /** + * Optional. Present when the reply was generated via streaming. + * Correlates this event with the fin_reply_chunk events that preceded it. + * Use this to know when to replace streamed chunk_text with the final message body. + */ + stream_id?: string; + /** The timestamp the event was created at, with millisecond precision. */ + created_at_ms: string; +} + +export namespace FinAgentRepliedEvent { + /** + * Fin's answer to the user's query. + */ + export interface Message { + /** A unique identifier for this message. */ + id?: string; + /** The author of the message (always 'fin' for this event). */ + author: "fin"; + /** The HTML body of Fin's response. */ + body: string; + /** The timestamp the message was created at, with millisecond precision. */ + timestamp_ms: string; + } + + /** + * Fin's current status. + * - replying: Intermediate reply part; more parts may follow + * - awaiting_user_reply: Legacy status; instead use the fin_status_updated event with 'awaiting_user_reply', which fires once Fin's reply is done + */ + export const Status = { + Replying: "replying", + AwaitingUserReply: "awaiting_user_reply", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +/** + * SSE-only event fired during streaming reply generation. + * Each chunk contains the full accumulated plain text of Fin's answer so far (cumulative, not a delta). + * Only delivered over SSE when streaming is enabled. Not available via webhooks. + * When the fin_replied event arrives with the same stream_id, replace streamed text with the final HTML body. + */ +export interface FinAgentReplyChunkEvent { + /** The name of the event. */ + event_name: "fin_reply_chunk"; + /** The ID of the conversation. */ + conversation_id: string; + /** + * A unique identifier for this streaming response. + * Correlates chunks with each other and with the eventual fin_replied event. + */ + stream_id: string; + /** 0-based counter for this chunk within the stream. Contiguous. */ + chunk_index: number; + /** + * The full accumulated plain text of Fin's answer so far. + * Each chunk supersedes the previous — replace rather than append. + */ + chunk_text: string; + /** Fin's current status (always 'replying' for this event). */ + status?: "replying"; + /** The timestamp the event was created at, with millisecond precision. */ + created_at_ms: string; +} + +/** + * Event fired when Fin asks the user to rate the conversation. + * Delivered via webhooks or SSE. Carries the rating options to present to the user; submit + * the user's choice with POST /fin/csat. Unlike the reply events it has no message — a + * rating survey is a set of options to choose from, not readable text. + * Over SSE this event arrives after Fin reaches 'complete'. Because a survey is expected, + * 'complete' does not close the stream: the connection is held open so this event can be + * delivered, and the token is revoked once it is sent. + */ +export interface FinAgentCsatRequestedEvent { + /** The name of the event. */ + event_name: "csat_requested"; + /** The ID of the conversation. */ + conversation_id: string; + /** The ID of the user. */ + user_id: string; + /** The rating survey to present to the user. */ + csat: FinAgentCsatRequestedEvent.Csat; + /** The timestamp the event was created at, with millisecond precision. */ + created_at_ms: string; +} + +export namespace FinAgentCsatRequestedEvent { + /** + * The rating survey to present to the user. + */ + export interface Csat { + /** The ordered rating options to show the user. */ + options: Csat.Options.Item[]; + } + + export namespace Csat { + export type Options = Options.Item[]; + + export namespace Options { + export interface Item { + /** The stable key to send back as 'rating' on POST /fin/csat. */ + key: Item.Key; + /** The emoji representing this rating. */ + emoji: string; + /** + * The human-readable label for this rating, localised to the conversation's + * detected language. Distinct from 'key' — display the label, but send back + * the key. + */ + label: string; + } + + export namespace Item { + /** The stable key to send back as 'rating' on POST /fin/csat. */ + export const Key = { + Terrible: "terrible", + Bad: "bad", + Ok: "ok", + Good: "good", + Amazing: "amazing", + } as const; + export type Key = (typeof Key)[keyof typeof Key]; + } + } + } +} diff --git a/src/api/resources/unstable/resources/articles/client/Client.ts b/src/api/resources/preview/resources/folders/client/Client.ts similarity index 56% rename from src/api/resources/unstable/resources/articles/client/Client.ts rename to src/api/resources/preview/resources/folders/client/Client.ts index 5ab11f3e..6d299bad 100644 --- a/src/api/resources/unstable/resources/articles/client/Client.ts +++ b/src/api/resources/preview/resources/folders/client/Client.ts @@ -9,45 +9,59 @@ import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStat import * as errors from "../../../../../../errors/index.js"; import * as Intercom from "../../../../../index.js"; -export declare namespace ArticlesClient { +export declare namespace FoldersClient { export interface Options extends BaseClientOptions {} export interface RequestOptions extends BaseRequestOptions {} } -/** - * Everything about your Articles - */ -export class ArticlesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class FoldersClient { + protected readonly _options: NormalizedClientOptionsWithAuth; - constructor(options: ArticlesClient.Options = {}) { + constructor(options: FoldersClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } /** - * You can fetch a list of all articles by making a GET request to `https://api.intercom.io/articles`. + * You can fetch a list of all folders for organizing content by making a GET request to `https://api.intercom.io/folders`. * - * > 📘 How are the articles sorted and ordered? - * > - * > Articles will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated articles first. + * @param {Intercom.preview.ListFoldersRequest} request + * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration. * - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.articles.listArticles() + * await client.preview.folders.listFolders({ + * page: 1, + * per_page: 50, + * parent_folder_id: 1 + * }) */ - public listArticles( - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listArticles(requestOptions)); + public listFolders( + request: Intercom.preview.ListFoldersRequest = {}, + requestOptions?: FoldersClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listFolders(request, requestOptions)); } - private async __listArticles( - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { + private async __listFolders( + request: Intercom.preview.ListFoldersRequest = {}, + requestOptions?: FoldersClient.RequestOptions, + ): Promise> { + const { page, per_page: perPage, parent_folder_id: parentFolderId } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams.page = page.toString(); + } + + if (perPage != null) { + _queryParams.per_page = perPage.toString(); + } + + if (parentFolderId != null) { + _queryParams.parent_folder_id = parentFolderId.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -60,11 +74,11 @@ export class ArticlesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "articles", + "folders", ), method: "GET", headers: _headers, - queryParameters: requestOptions?.queryParams, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -72,14 +86,14 @@ export class ArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.ArticleList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.ListFoldersResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -91,34 +105,38 @@ export class ArticlesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/folders"); } /** - * You can create a new article by making a POST request to `https://api.intercom.io/articles`. + * You can create a new folder for organizing content by making a POST request to `https://api.intercom.io/folders`. * - * @param {unknown} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.CreateFolderRequest} request + * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.articles.createArticle({ - * "key": "value" + * await client.preview.folders.createFolder({ + * folder: { + * name: "Product Documentation", + * description: "Internal product docs", + * emoji: "\uD83D\uDCDA" + * } * }) */ - public createArticle( - request?: unknown, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createArticle(request, requestOptions)); + public createFolder( + request: Intercom.preview.CreateFolderRequest, + requestOptions?: FoldersClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createFolder(request, requestOptions)); } - private async __createArticle( - request?: unknown, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { + private async __createFolder( + request: Intercom.preview.CreateFolderRequest, + requestOptions?: FoldersClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -131,7 +149,7 @@ export class ArticlesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "articles", + "folders", ), method: "POST", headers: _headers, @@ -146,16 +164,16 @@ export class ArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Article, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Folder, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -167,34 +185,34 @@ export class ArticlesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/articles"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/folders"); } /** - * You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. + * You can fetch the details of a single folder by making a GET request to `https://api.intercom.io/folders/`. * - * @param {Intercom.unstable.RetrieveArticleRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.RetrieveFolderRequest} request + * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.articles.retrieveArticle({ + * await client.preview.folders.retrieveFolder({ * id: 1 * }) */ - public retrieveArticle( - request: Intercom.unstable.RetrieveArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveArticle(request, requestOptions)); + public retrieveFolder( + request: Intercom.preview.RetrieveFolderRequest, + requestOptions?: FoldersClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveFolder(request, requestOptions)); } - private async __retrieveArticle( - request: Intercom.unstable.RetrieveArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { + private async __retrieveFolder( + request: Intercom.preview.RetrieveFolderRequest, + requestOptions?: FoldersClient.RequestOptions, + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -208,7 +226,7 @@ export class ArticlesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `articles/${core.url.encodePathParam(id)}`, + `folders/${core.url.encodePathParam(id)}`, ), method: "GET", headers: _headers, @@ -220,18 +238,18 @@ export class ArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Article, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Folder, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -241,35 +259,40 @@ export class ArticlesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/{id}"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/folders/{id}"); } /** - * You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. + * You can update a folder by making a PUT request to `https://api.intercom.io/folders/`. * - * @param {Intercom.unstable.DeleteArticleRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.UpdateFolderRequest} request + * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.articles.deleteArticle({ - * id: 1 + * await client.preview.folders.updateFolder({ + * id: 1, + * folder: { + * name: "Updated Product Documentation", + * emoji: "\uD83D\uDCD6" + * } * }) */ - public deleteArticle( - request: Intercom.unstable.DeleteArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteArticle(request, requestOptions)); + public updateFolder( + request: Intercom.preview.UpdateFolderRequest, + requestOptions?: FoldersClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateFolder(request, requestOptions)); } - private async __deleteArticle( - request: Intercom.unstable.DeleteArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __updateFolder( + request: Intercom.preview.UpdateFolderRequest, + requestOptions?: FoldersClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -282,11 +305,14 @@ export class ArticlesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `articles/${core.url.encodePathParam(id)}`, + `folders/${core.url.encodePathParam(id)}`, ), - method: "DELETE", + method: "PUT", headers: _headers, + contentType: "application/json", queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -294,21 +320,20 @@ export class ArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.DeletedArticleObject, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.Folder, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -318,54 +343,36 @@ export class ArticlesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/articles/{id}"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/folders/{id}"); } /** - * You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. + * You can delete a folder (if it contains no content) by making a DELETE request to `https://api.intercom.io/folders/`. * - * @param {Intercom.unstable.SearchArticlesRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.DeleteFolderRequest} request + * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.articles.searchArticles({ - * phrase: "Getting started", - * state: "published", - * help_center_id: 1, - * highlight: true + * await client.preview.folders.deleteFolder({ + * id: 1 * }) */ - public searchArticles( - request: Intercom.unstable.SearchArticlesRequest = {}, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__searchArticles(request, requestOptions)); + public deleteFolder( + request: Intercom.preview.DeleteFolderRequest, + requestOptions?: FoldersClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteFolder(request, requestOptions)); } - private async __searchArticles( - request: Intercom.unstable.SearchArticlesRequest = {}, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const { phrase, state, help_center_id: helpCenterId, highlight } = request; - const _queryParams: Record = {}; - if (phrase != null) { - _queryParams.phrase = phrase; - } - - if (state != null) { - _queryParams.state = state; - } - - if (helpCenterId != null) { - _queryParams.help_center_id = helpCenterId.toString(); - } - - if (highlight != null) { - _queryParams.highlight = highlight.toString(); - } - + private async __deleteFolder( + request: Intercom.preview.DeleteFolderRequest, + requestOptions?: FoldersClient.RequestOptions, + ): Promise> { + const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -378,11 +385,11 @@ export class ArticlesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "articles/search", + `folders/${core.url.encodePathParam(id)}`, ), - method: "GET", + method: "DELETE", headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + queryParameters: requestOptions?.queryParams, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -390,17 +397,21 @@ export class ArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ArticleSearchResponse, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.DeletedFolderObject, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); default: @@ -412,6 +423,6 @@ export class ArticlesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/search"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/folders/{id}"); } } diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/index.ts b/src/api/resources/preview/resources/folders/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/subscriptionTypes/client/index.ts rename to src/api/resources/preview/resources/folders/client/index.ts diff --git a/src/api/resources/preview/resources/folders/client/requests/CreateFolderRequest.ts b/src/api/resources/preview/resources/folders/client/requests/CreateFolderRequest.ts new file mode 100644 index 00000000..d653226f --- /dev/null +++ b/src/api/resources/preview/resources/folders/client/requests/CreateFolderRequest.ts @@ -0,0 +1,28 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * folder: { + * name: "Product Documentation", + * description: "Internal product docs", + * emoji: "\uD83D\uDCDA" + * } + * } + */ +export interface CreateFolderRequest { + folder: CreateFolderRequest.Folder; +} + +export namespace CreateFolderRequest { + export interface Folder { + /** The name of the folder */ + name: string; + /** The description of the folder */ + description?: string; + /** An emoji for the folder */ + emoji?: string; + /** The ID of the parent folder */ + parent_folder_id?: number; + } +} diff --git a/src/api/resources/preview/resources/folders/client/requests/DeleteFolderRequest.ts b/src/api/resources/preview/resources/folders/client/requests/DeleteFolderRequest.ts new file mode 100644 index 00000000..30de86c6 --- /dev/null +++ b/src/api/resources/preview/resources/folders/client/requests/DeleteFolderRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1 + * } + */ +export interface DeleteFolderRequest { + /** The unique identifier for the folder */ + id: number; +} diff --git a/src/api/resources/preview/resources/folders/client/requests/ListFoldersRequest.ts b/src/api/resources/preview/resources/folders/client/requests/ListFoldersRequest.ts new file mode 100644 index 00000000..b3135faf --- /dev/null +++ b/src/api/resources/preview/resources/folders/client/requests/ListFoldersRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * page: 1, + * per_page: 50, + * parent_folder_id: 1 + * } + */ +export interface ListFoldersRequest { + /** The page number */ + page?: number; + /** Number of results per page */ + per_page?: number; + /** Filter folders by parent folder ID. Use this to list only direct children of a specific folder. */ + parent_folder_id?: number; +} diff --git a/src/api/resources/preview/resources/folders/client/requests/RetrieveFolderRequest.ts b/src/api/resources/preview/resources/folders/client/requests/RetrieveFolderRequest.ts new file mode 100644 index 00000000..0ce810c5 --- /dev/null +++ b/src/api/resources/preview/resources/folders/client/requests/RetrieveFolderRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1 + * } + */ +export interface RetrieveFolderRequest { + /** The unique identifier for the folder */ + id: number; +} diff --git a/src/api/resources/preview/resources/folders/client/requests/UpdateFolderRequest.ts b/src/api/resources/preview/resources/folders/client/requests/UpdateFolderRequest.ts new file mode 100644 index 00000000..3be4fe06 --- /dev/null +++ b/src/api/resources/preview/resources/folders/client/requests/UpdateFolderRequest.ts @@ -0,0 +1,30 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1, + * folder: { + * name: "Updated Product Documentation", + * emoji: "\uD83D\uDCD6" + * } + * } + */ +export interface UpdateFolderRequest { + /** The unique identifier for the folder */ + id: number; + folder: UpdateFolderRequest.Folder; +} + +export namespace UpdateFolderRequest { + export interface Folder { + /** The name of the folder */ + name?: string; + /** The description of the folder */ + description?: string; + /** An emoji for the folder */ + emoji?: string; + /** The ID of the parent folder */ + parent_folder_id?: number; + } +} diff --git a/src/api/resources/preview/resources/folders/client/requests/index.ts b/src/api/resources/preview/resources/folders/client/requests/index.ts new file mode 100644 index 00000000..ec3c564a --- /dev/null +++ b/src/api/resources/preview/resources/folders/client/requests/index.ts @@ -0,0 +1,5 @@ +export type { CreateFolderRequest } from "./CreateFolderRequest.js"; +export type { DeleteFolderRequest } from "./DeleteFolderRequest.js"; +export type { ListFoldersRequest } from "./ListFoldersRequest.js"; +export type { RetrieveFolderRequest } from "./RetrieveFolderRequest.js"; +export type { UpdateFolderRequest } from "./UpdateFolderRequest.js"; diff --git a/src/api/resources/unstable/resources/segments/index.ts b/src/api/resources/preview/resources/folders/index.ts similarity index 100% rename from src/api/resources/unstable/resources/segments/index.ts rename to src/api/resources/preview/resources/folders/index.ts diff --git a/src/api/resources/preview/resources/folders/types/index.ts b/src/api/resources/preview/resources/folders/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/folders/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/folders/types/types.ts b/src/api/resources/preview/resources/folders/types/types.ts new file mode 100644 index 00000000..138d800a --- /dev/null +++ b/src/api/resources/preview/resources/folders/types/types.ts @@ -0,0 +1,33 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +export interface ListFoldersResponse { + type?: "list"; + data?: Intercom.preview.Folder[]; + /** Total number of folders */ + total_count?: number; + pages?: Intercom.preview.CursorPages; +} + +/** + * A folder for organizing content + */ +export interface Folder { + /** The unique identifier for the folder */ + id?: number; + /** The name of the folder */ + name?: string; + /** The description of the folder */ + description?: string; + /** An emoji associated with the folder */ + emoji?: string; + /** The ID of the parent folder, or null if this is a root folder */ + parent_folder_id?: number; + /** The number of content items in this folder */ + content_count?: number; + /** The time when the folder was created (seconds) */ + created_at?: number; + /** The time when the folder was last updated (seconds) */ + updated_at?: number; +} diff --git a/src/api/resources/unstable/resources/companies/client/Client.ts b/src/api/resources/preview/resources/helpCenter/client/Client.ts similarity index 51% rename from src/api/resources/unstable/resources/companies/client/Client.ts rename to src/api/resources/preview/resources/helpCenter/client/Client.ts index 575c345d..35e57da9 100644 --- a/src/api/resources/unstable/resources/companies/client/Client.ts +++ b/src/api/resources/preview/resources/helpCenter/client/Client.ts @@ -9,80 +9,55 @@ import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStat import * as errors from "../../../../../../errors/index.js"; import * as Intercom from "../../../../../index.js"; -export declare namespace CompaniesClient { +export declare namespace HelpCenterClient { export interface Options extends BaseClientOptions {} export interface RequestOptions extends BaseRequestOptions {} } /** - * Everything about your Companies + * Everything about your Help Center */ -export class CompaniesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class HelpCenterClient { + protected readonly _options: NormalizedClientOptionsWithAuth; - constructor(options: CompaniesClient.Options = {}) { + constructor(options: HelpCenterClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } /** - * You can fetch a single company by passing in `company_id` or `name`. + * You can fetch a list of all URL redirects for a help center by making a GET request to `https://api.intercom.io/help_center/help_centers/{help_center_id}/redirects`. * - * `https://api.intercom.io/companies?name={name}` + * Redirects are returned in descending order on the `updated_at` attribute. * - * `https://api.intercom.io/companies?company_id={company_id}` + * Requires the `read_help_center_redirects_scope` OAuth scope. Set `Intercom-Version: Preview`. * - * You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. + * @param {Intercom.preview.ListHelpCenterRedirectsRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * `https://api.intercom.io/companies?tag_id={tag_id}` - * - * `https://api.intercom.io/companies?segment_id={segment_id}` - * - * @param {Intercom.unstable.RetrieveCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.companies.retrieveCompany({ - * name: "my company", - * company_id: "12345", - * tag_id: "678910", - * segment_id: "98765", + * await client.preview.helpCenter.listHelpCenterRedirects({ + * help_center_id: "123", * page: 1, * per_page: 1 * }) */ - public retrieveCompany( - request: Intercom.unstable.RetrieveCompanyRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveCompany(request, requestOptions)); + public listHelpCenterRedirects( + request: Intercom.preview.ListHelpCenterRedirectsRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listHelpCenterRedirects(request, requestOptions)); } - private async __retrieveCompany( - request: Intercom.unstable.RetrieveCompanyRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { name, company_id: companyId, tag_id: tagId, segment_id: segmentId, page, per_page: perPage } = request; + private async __listHelpCenterRedirects( + request: Intercom.preview.ListHelpCenterRedirectsRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { + const { help_center_id: helpCenterId, page, per_page: perPage } = request; const _queryParams: Record = {}; - if (name != null) { - _queryParams.name = name; - } - - if (companyId != null) { - _queryParams.company_id = companyId; - } - - if (tagId != null) { - _queryParams.tag_id = tagId; - } - - if (segmentId != null) { - _queryParams.segment_id = segmentId; - } - if (page != null) { _queryParams.page = page.toString(); } @@ -103,7 +78,7 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "companies", + `help_center/help_centers/${core.url.encodePathParam(helpCenterId)}/redirects`, ), method: "GET", headers: _headers, @@ -115,18 +90,21 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.CompanyList, rawResponse: _response.rawResponse }; + return { + data: _response.body as Intercom.preview.HelpCenterRedirectList, + rawResponse: _response.rawResponse, + }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -136,42 +114,49 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies"); + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/help_center/help_centers/{help_center_id}/redirects", + ); } /** - * You can create or update a company. + * You can create a new URL redirect by making a POST request to `https://api.intercom.io/help_center/help_centers/{help_center_id}/redirects`. * - * Companies will be only visible in Intercom when there is at least one associated user. + * Requires the `read_write_help_center_redirects_scope` OAuth scope. Set `Intercom-Version: Preview`. * - * Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. + * @param {Intercom.preview.CreateHelpCenterRedirectRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * {% admonition type="warning" name="Using `company_id`" %} - * You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. - * {% /admonition %} - * - * @param {unknown} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.ConflictError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.companies.createOrUpdateCompany({ - * "key": "value" + * await client.preview.helpCenter.createHelpCenterRedirect({ + * help_center_id: "123", + * from_url: "http://help-center.test/lovelyhelpcenter/old-page", + * locale: "en", + * target_type: "article", + * target_id: "11" * }) */ - public createOrUpdateCompany( - request?: unknown, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createOrUpdateCompany(request, requestOptions)); + public createHelpCenterRedirect( + request: Intercom.preview.CreateHelpCenterRedirectRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createHelpCenterRedirect(request, requestOptions)); } - private async __createOrUpdateCompany( - request?: unknown, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { + private async __createHelpCenterRedirect( + request: Intercom.preview.CreateHelpCenterRedirectRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { + const { help_center_id: helpCenterId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -184,14 +169,14 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "companies", + `help_center/help_centers/${core.url.encodePathParam(helpCenterId)}/redirects`, ), method: "POST", headers: _headers, contentType: "application/json", queryParameters: requestOptions?.queryParams, requestType: "json", - body: request, + body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -199,16 +184,28 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.HelpCenterRedirect, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Intercom.preview.ConflictError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, _response.rawResponse, ); default: @@ -220,35 +217,43 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies"); + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/help_center/help_centers/{help_center_id}/redirects", + ); } /** - * You can fetch a single company. + * You can fetch the details of a single redirect by making a GET request to `https://api.intercom.io/help_center/help_centers/{help_center_id}/redirects/{id}`. * - * @param {Intercom.unstable.RetrieveACompanyByIdRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * Requires the `read_help_center_redirects_scope` OAuth scope. Set `Intercom-Version: Preview`. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @param {Intercom.preview.RetrieveHelpCenterRedirectRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.companies.retrieveACompanyById({ - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * await client.preview.helpCenter.retrieveHelpCenterRedirect({ + * help_center_id: "123", + * id: "26" * }) */ - public retrieveACompanyById( - request: Intercom.unstable.RetrieveACompanyByIdRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveACompanyById(request, requestOptions)); + public retrieveHelpCenterRedirect( + request: Intercom.preview.RetrieveHelpCenterRedirectRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveHelpCenterRedirect(request, requestOptions)); } - private async __retrieveACompanyById( - request: Intercom.unstable.RetrieveACompanyByIdRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __retrieveHelpCenterRedirect( + request: Intercom.preview.RetrieveHelpCenterRedirectRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { + const { help_center_id: helpCenterId, id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -261,7 +266,7 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}`, + `help_center/help_centers/${core.url.encodePathParam(helpCenterId)}/redirects/${core.url.encodePathParam(id)}`, ), method: "GET", headers: _headers, @@ -273,18 +278,18 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.HelpCenterRedirect, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -294,39 +299,43 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}"); + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/help_center/help_centers/{help_center_id}/redirects/{id}", + ); } /** - * You can update a single company using the Intercom provisioned `id`. + * You can delete a single redirect by making a DELETE request to `https://api.intercom.io/help_center/help_centers/{help_center_id}/redirects/{id}`. * - * {% admonition type="warning" name="Using `company_id`" %} - * When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. - * {% /admonition %} + * Requires the `read_write_help_center_redirects_scope` OAuth scope. Set `Intercom-Version: Preview`. * - * @param {Intercom.unstable.UpdateCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.DeleteHelpCenterRedirectRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.companies.updateCompany({ - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * await client.preview.helpCenter.deleteHelpCenterRedirect({ + * help_center_id: "123", + * id: "26" * }) */ - public updateCompany( - request: Intercom.unstable.UpdateCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateCompany(request, requestOptions)); + public deleteHelpCenterRedirect( + request: Intercom.preview.DeleteHelpCenterRedirectRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteHelpCenterRedirect(request, requestOptions)); } - private async __updateCompany( - request: Intercom.unstable.UpdateCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __deleteHelpCenterRedirect( + request: Intercom.preview.DeleteHelpCenterRedirectRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { + const { help_center_id: helpCenterId, id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -339,9 +348,9 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}`, + `help_center/help_centers/${core.url.encodePathParam(helpCenterId)}/redirects/${core.url.encodePathParam(id)}`, ), - method: "PUT", + method: "DELETE", headers: _headers, queryParameters: requestOptions?.queryParams, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, @@ -351,18 +360,21 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + return { + data: _response.body as Intercom.preview.DeletedHelpCenterRedirectObject, + rawResponse: _response.rawResponse, + }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -372,35 +384,35 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/companies/{id}"); + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/help_center/help_centers/{help_center_id}/redirects/{id}", + ); } /** - * You can delete a single company. + * You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. + * + * Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first. * - * @param {Intercom.unstable.DeleteCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.companies.deleteCompany({ - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * }) + * await client.preview.helpCenter.listAllCollections() */ - public deleteCompany( - request: Intercom.unstable.DeleteCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteCompany(request, requestOptions)); + public listAllCollections( + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAllCollections(requestOptions)); } - private async __deleteCompany( - request: Intercom.unstable.DeleteCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __listAllCollections( + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -413,9 +425,9 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}`, + "help_center/collections", ), - method: "DELETE", + method: "GET", headers: _headers, queryParameters: requestOptions?.queryParams, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, @@ -425,21 +437,16 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.DeletedCompanyObject, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.CollectionList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -449,35 +456,40 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/companies/{id}"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/collections"); } /** - * You can fetch a list of all contacts that belong to a company. + * You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` * - * @param {Intercom.unstable.ListAttachedContactsRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.CreateCollectionRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.companies.listAttachedContacts({ - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * await client.preview.helpCenter.createCollection({ + * name: "Thanks for everything" + * }) + * + * @example + * await client.preview.helpCenter.createCollection({ + * name: "collection 51", + * description: "Missing required parameter" * }) */ - public listAttachedContacts( - request: Intercom.unstable.ListAttachedContactsRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedContacts(request, requestOptions)); + public createCollection( + request: Intercom.preview.CreateCollectionRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createCollection(request, requestOptions)); } - private async __listAttachedContacts( - request: Intercom.unstable.ListAttachedContactsRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __createCollection( + request: Intercom.preview.CreateCollectionRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -490,11 +502,14 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}/contacts`, + "help_center/collections", ), - method: "GET", + method: "POST", headers: _headers, + contentType: "application/json", queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -502,21 +517,18 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.CompanyAttachedContacts, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.Collection, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -526,34 +538,34 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}/contacts"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/help_center/collections"); } /** - * You can fetch a list of all segments that belong to a company. + * You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. * - * @param {Intercom.unstable.ListAttachedSegmentsForCompaniesRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.RetrieveCollectionRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.companies.listAttachedSegmentsForCompanies({ - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * await client.preview.helpCenter.retrieveCollection({ + * id: 1 * }) */ - public listAttachedSegmentsForCompanies( - request: Intercom.unstable.ListAttachedSegmentsForCompaniesRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedSegmentsForCompanies(request, requestOptions)); + public retrieveCollection( + request: Intercom.preview.RetrieveCollectionRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveCollection(request, requestOptions)); } - private async __listAttachedSegmentsForCompanies( - request: Intercom.unstable.ListAttachedSegmentsForCompaniesRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { + private async __retrieveCollection( + request: Intercom.preview.RetrieveCollectionRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -567,7 +579,7 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}/segments`, + `help_center/collections/${core.url.encodePathParam(id)}`, ), method: "GET", headers: _headers, @@ -579,21 +591,18 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.CompanyAttachedSegments, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.Collection, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -603,57 +612,36 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}/segments"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/collections/{id}"); } /** - * You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. - * - * Note that the API does not include companies who have no associated users in list responses. + * You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. * - * When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). - * {% admonition type="warning" name="Pagination" %} - * You can use pagination to limit the number of results returned. The default is `20` results per page. - * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. - * {% /admonition %} + * @param {Intercom.preview.UpdateCollectionRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * @param {Intercom.unstable.ListAllCompaniesRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.companies.listAllCompanies({ - * page: 1, - * per_page: 1, - * order: "desc" + * await client.preview.helpCenter.updateCollection({ + * id: 1, + * name: "Update collection name" * }) */ - public listAllCompanies( - request: Intercom.unstable.ListAllCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAllCompanies(request, requestOptions)); + public updateCollection( + request: Intercom.preview.UpdateCollectionRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateCollection(request, requestOptions)); } - private async __listAllCompanies( - request: Intercom.unstable.ListAllCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { page, per_page: perPage, order } = request; - const _queryParams: Record = {}; - if (page != null) { - _queryParams.page = page.toString(); - } - - if (perPage != null) { - _queryParams.per_page = perPage.toString(); - } - - if (order != null) { - _queryParams.order = order; - } - + private async __updateCollection( + request: Intercom.preview.UpdateCollectionRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -666,11 +654,14 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "companies/list", + `help_center/collections/${core.url.encodePathParam(id)}`, ), - method: "POST", + method: "PUT", headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -678,16 +669,18 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.CompanyList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Collection, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -697,53 +690,35 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies/list"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/help_center/collections/{id}"); } /** - * The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + * You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. * - * - Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. - * - If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail - * - If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire + * @param {Intercom.preview.DeleteCollectionRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * {% admonition type="info" name="Scroll Parameter" %} - * You can get the first page of companies by simply sending a GET request to the scroll endpoint. - * For subsequent requests you will need to use the scroll parameter from the response. - * {% /admonition %} - * {% admonition type="danger" name="Scroll network timeouts" %} - * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: - * "Request failed due to an internal network error. Please restart the scroll operation." - * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. - * {% /admonition %} - * - * @param {Intercom.unstable.ScrollOverAllCompaniesRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.companies.scrollOverAllCompanies({ - * scroll_param: "scroll_param" + * await client.preview.helpCenter.deleteCollection({ + * id: 1 * }) */ - public scrollOverAllCompanies( - request: Intercom.unstable.ScrollOverAllCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__scrollOverAllCompanies(request, requestOptions)); + public deleteCollection( + request: Intercom.preview.DeleteCollectionRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteCollection(request, requestOptions)); } - private async __scrollOverAllCompanies( - request: Intercom.unstable.ScrollOverAllCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { scroll_param: scrollParam } = request; - const _queryParams: Record = {}; - if (scrollParam != null) { - _queryParams.scroll_param = scrollParam; - } - + private async __deleteCollection( + request: Intercom.preview.DeleteCollectionRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { + const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -756,11 +731,11 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "companies/scroll", + `help_center/collections/${core.url.encodePathParam(id)}`, ), - method: "GET", + method: "DELETE", headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + queryParameters: requestOptions?.queryParams, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -769,7 +744,7 @@ export class CompaniesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.CompanyScroll | undefined, + data: _response.body as Intercom.preview.DeletedCollectionObject, rawResponse: _response.rawResponse, }; } @@ -777,10 +752,12 @@ export class CompaniesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -790,49 +767,40 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/scroll"); + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/help_center/collections/{id}", + ); } /** - * You can attach a company to a single contact. - * - * @param {Intercom.unstable.AttachContactToACompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @param {Intercom.preview.RetrieveHelpCenterRequest} request + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * @example - * await client.unstable.companies.attachContactToACompany({ - * id: "id", - * company_id: "6762f09a1bb69f9f2193bb34" - * }) - * - * @example - * await client.unstable.companies.attachContactToACompany({ - * id: "id", - * company_id: "58a430d35458202d41b1e65b" - * }) + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.companies.attachContactToACompany({ - * id: "id", - * company_id: "123" + * await client.preview.helpCenter.retrieveHelpCenter({ + * id: 1 * }) */ - public attachContactToACompany( - request: Intercom.unstable.AttachContactToACompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachContactToACompany(request, requestOptions)); + public retrieveHelpCenter( + request: Intercom.preview.RetrieveHelpCenterRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveHelpCenter(request, requestOptions)); } - private async __attachContactToACompany( - request: Intercom.unstable.AttachContactToACompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; + private async __retrieveHelpCenter( + request: Intercom.preview.RetrieveHelpCenterRequest, + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { + const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -845,14 +813,11 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/companies`, + `help_center/help_centers/${core.url.encodePathParam(id)}`, ), - method: "POST", + method: "GET", headers: _headers, - contentType: "application/json", queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -860,20 +825,18 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.HelpCenter, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { - case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -883,36 +846,33 @@ export class CompaniesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/companies"); + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/help_center/help_centers/{id}", + ); } /** - * You can detach a company from a single contact. + * You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. * - * @param {Intercom.unstable.DetachContactFromACompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.companies.detachContactFromACompany({ - * contact_id: "58a430d35458202d41b1e65b", - * id: "58a430d35458202d41b1e65b" - * }) + * await client.preview.helpCenter.listHelpCenters() */ - public detachContactFromACompany( - request: Intercom.unstable.DetachContactFromACompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachContactFromACompany(request, requestOptions)); + public listHelpCenters( + requestOptions?: HelpCenterClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listHelpCenters(requestOptions)); } - private async __detachContactFromACompany( - request: Intercom.unstable.DetachContactFromACompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, id } = request; + private async __listHelpCenters( + requestOptions?: HelpCenterClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -925,9 +885,9 @@ export class CompaniesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/companies/${core.url.encodePathParam(id)}`, + "help_center/help_centers", ), - method: "DELETE", + method: "GET", headers: _headers, queryParameters: requestOptions?.queryParams, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, @@ -937,18 +897,16 @@ export class CompaniesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.HelpCenterList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -958,11 +916,6 @@ export class CompaniesClient { } } - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/contacts/{contact_id}/companies/{id}", - ); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/help_centers"); } } diff --git a/src/api/resources/unstable/resources/tags/client/index.ts b/src/api/resources/preview/resources/helpCenter/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/index.ts rename to src/api/resources/preview/resources/helpCenter/client/index.ts diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/CreateCollectionRequest.ts similarity index 93% rename from src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts rename to src/api/resources/preview/resources/helpCenter/client/requests/CreateCollectionRequest.ts index 79a825bf..73a4feaf 100644 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts +++ b/src/api/resources/preview/resources/helpCenter/client/requests/CreateCollectionRequest.ts @@ -19,7 +19,7 @@ export interface CreateCollectionRequest { name: string; /** The description of the collection. For multilingual collections, this will be the description of the default language's content. */ description?: string; - translated_content?: Intercom.unstable.GroupTranslatedContent; + translated_content?: Intercom.preview.GroupTranslatedContent; /** The id of the parent collection. If `null` then it will be created as the first level collection. */ parent_id?: string; /** The id of the help center where the collection will be created. If `null` then it will be created in the default help center. */ diff --git a/src/api/resources/preview/resources/helpCenter/client/requests/CreateHelpCenterRedirectRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/CreateHelpCenterRedirectRequest.ts new file mode 100644 index 00000000..1a8590fd --- /dev/null +++ b/src/api/resources/preview/resources/helpCenter/client/requests/CreateHelpCenterRedirectRequest.ts @@ -0,0 +1,33 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * help_center_id: "123", + * from_url: "http://help-center.test/lovelyhelpcenter/old-page", + * locale: "en", + * target_type: "article", + * target_id: "11" + * } + */ +export interface CreateHelpCenterRedirectRequest { + /** The unique identifier for the help center. */ + help_center_id: string; + /** The source URL to redirect. Must be an absolute URL within the help center's URL space. */ + from_url: string; + /** The locale of the target translation (e.g. `en`, `fr`). For article targets this selects the ArticleContent variant. */ + locale: string; + /** The type of the redirect target. */ + target_type: CreateHelpCenterRedirectRequest.TargetType; + /** The unique identifier of the target article or collection. The target must be a member of the help center. */ + target_id: string; +} + +export namespace CreateHelpCenterRedirectRequest { + /** The type of the redirect target. */ + export const TargetType = { + Article: "article", + Collection: "collection", + } as const; + export type TargetType = (typeof TargetType)[keyof typeof TargetType]; +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/DeleteCollectionRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/DeleteCollectionRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/helpCenter/client/requests/DeleteCollectionRequest.ts rename to src/api/resources/preview/resources/helpCenter/client/requests/DeleteCollectionRequest.ts diff --git a/src/api/resources/preview/resources/helpCenter/client/requests/DeleteHelpCenterRedirectRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/DeleteHelpCenterRedirectRequest.ts new file mode 100644 index 00000000..3046d392 --- /dev/null +++ b/src/api/resources/preview/resources/helpCenter/client/requests/DeleteHelpCenterRedirectRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * help_center_id: "123", + * id: "26" + * } + */ +export interface DeleteHelpCenterRedirectRequest { + /** The unique identifier for the help center. */ + help_center_id: string; + /** The unique identifier for the redirect. */ + id: string; +} diff --git a/src/api/resources/preview/resources/helpCenter/client/requests/ListHelpCenterRedirectsRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/ListHelpCenterRedirectsRequest.ts new file mode 100644 index 00000000..c47077c1 --- /dev/null +++ b/src/api/resources/preview/resources/helpCenter/client/requests/ListHelpCenterRedirectsRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * help_center_id: "123", + * page: 1, + * per_page: 1 + * } + */ +export interface ListHelpCenterRedirectsRequest { + /** The unique identifier for the help center. */ + help_center_id: string; + /** The page of results to fetch. Defaults to the first page. */ + page?: number; + /** The number of results to return per page. Defaults to 50, maximum 250. */ + per_page?: number; +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts rename to src/api/resources/preview/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts diff --git a/src/api/resources/preview/resources/helpCenter/client/requests/RetrieveHelpCenterRedirectRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/RetrieveHelpCenterRedirectRequest.ts new file mode 100644 index 00000000..9d870622 --- /dev/null +++ b/src/api/resources/preview/resources/helpCenter/client/requests/RetrieveHelpCenterRedirectRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * help_center_id: "123", + * id: "26" + * } + */ +export interface RetrieveHelpCenterRedirectRequest { + /** The unique identifier for the help center. */ + help_center_id: string; + /** The unique identifier for the redirect. */ + id: string; +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts rename to src/api/resources/preview/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/UpdateCollectionRequest.ts b/src/api/resources/preview/resources/helpCenter/client/requests/UpdateCollectionRequest.ts similarity index 93% rename from src/api/resources/unstable/resources/helpCenter/client/requests/UpdateCollectionRequest.ts rename to src/api/resources/preview/resources/helpCenter/client/requests/UpdateCollectionRequest.ts index 9caeacc0..7e99c731 100644 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/UpdateCollectionRequest.ts +++ b/src/api/resources/preview/resources/helpCenter/client/requests/UpdateCollectionRequest.ts @@ -22,7 +22,7 @@ export interface UpdateCollectionRequest { name?: string; /** The description of the collection. For multilingual collections, this will be the description of the default language's content. */ description?: string; - translated_content?: Intercom.unstable.GroupTranslatedContent; + translated_content?: Intercom.preview.GroupTranslatedContent; /** The id of the parent collection. If `null` then it will be updated as the first level collection. */ parent_id?: string; } diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/index.ts b/src/api/resources/preview/resources/helpCenter/client/requests/index.ts similarity index 51% rename from src/api/resources/unstable/resources/helpCenter/client/requests/index.ts rename to src/api/resources/preview/resources/helpCenter/client/requests/index.ts index d2d1c0aa..2643d49f 100644 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/index.ts +++ b/src/api/resources/preview/resources/helpCenter/client/requests/index.ts @@ -1,5 +1,9 @@ export type { CreateCollectionRequest } from "./CreateCollectionRequest.js"; +export type { CreateHelpCenterRedirectRequest } from "./CreateHelpCenterRedirectRequest.js"; export type { DeleteCollectionRequest } from "./DeleteCollectionRequest.js"; +export type { DeleteHelpCenterRedirectRequest } from "./DeleteHelpCenterRedirectRequest.js"; +export type { ListHelpCenterRedirectsRequest } from "./ListHelpCenterRedirectsRequest.js"; export type { RetrieveCollectionRequest } from "./RetrieveCollectionRequest.js"; +export type { RetrieveHelpCenterRedirectRequest } from "./RetrieveHelpCenterRedirectRequest.js"; export type { RetrieveHelpCenterRequest } from "./RetrieveHelpCenterRequest.js"; export type { UpdateCollectionRequest } from "./UpdateCollectionRequest.js"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/index.ts b/src/api/resources/preview/resources/helpCenter/index.ts similarity index 100% rename from src/api/resources/unstable/resources/subscriptionTypes/index.ts rename to src/api/resources/preview/resources/helpCenter/index.ts diff --git a/src/api/resources/preview/resources/helpCenter/types/index.ts b/src/api/resources/preview/resources/helpCenter/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/helpCenter/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/helpCenter/types/types.ts b/src/api/resources/preview/resources/helpCenter/types/types.ts new file mode 100644 index 00000000..b0550cb8 --- /dev/null +++ b/src/api/resources/preview/resources/helpCenter/types/types.ts @@ -0,0 +1,106 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * Collections are top level containers for Articles within the Help Center. + */ +export interface Collection { + /** The unique identifier for the collection which is given by Intercom. */ + id?: string; + /** The id of the workspace which the collection belongs to. */ + workspace_id?: string; + /** The name of the collection. For multilingual collections, this will be the name of the default language's content. */ + name?: string; + /** The description of the collection. For multilingual help centers, this will be the description of the collection for the default language. */ + description?: string; + /** The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content. */ + created_at?: number; + /** The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content. */ + updated_at?: number; + /** The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language. */ + url?: string; + /** The icon of the collection. */ + icon?: string; + /** The order of the section in relation to others sections within a collection. Values go from `0` upwards. `0` is the default if there's no order. */ + order?: number; + /** The default locale of the help center. This field is only returned for multilingual help centers. */ + default_locale?: string; + translated_content?: Intercom.preview.GroupTranslatedContent; + /** The id of the parent collection. If `null` then it is the first level collection. */ + parent_id?: string; + /** The id of the help center the collection is in. */ + help_center_id?: number; +} + +/** + * A redirect maps a source URL (`from_url`) to an article or collection within a + * help center, so that links to old or external URLs resolve to live content. + */ +export interface HelpCenterRedirect { + /** The unique identifier for the redirect. */ + id?: string; + /** The type of the object - `help_center_redirect`. */ + type?: "help_center_redirect"; + /** The source URL that is redirected. An absolute URL within the help center's URL space. */ + from_url?: string; + /** The locale of the redirect's target. For article targets this is the bound translation's locale, which may differ from the requested locale if no translation exists in that locale. */ + locale?: string; + /** The unique identifier for the help center the redirect belongs to. */ + help_center_id?: string; + /** The type of the redirect target. */ + target_type?: HelpCenterRedirect.TargetType; + /** The unique identifier of the target article or collection. For article targets this is the Article ID. */ + target_id?: string; + /** The time the redirect was created as a UTC Unix timestamp. */ + created_at?: number; + /** The time the redirect was last updated as a UTC Unix timestamp. */ + updated_at?: number; +} + +export namespace HelpCenterRedirect { + /** The type of the redirect target. */ + export const TargetType = { + Article: "article", + Collection: "collection", + } as const; + export type TargetType = (typeof TargetType)[keyof typeof TargetType]; +} + +/** + * Help Centers contain collections + */ +export interface HelpCenter { + /** The unique identifier for the Help Center which is given by Intercom. */ + id?: string; + /** The id of the workspace which the Help Center belongs to. */ + workspace_id?: string; + /** The time when the Help Center was created. */ + created_at?: number; + /** The time when the Help Center was last updated. */ + updated_at?: number; + /** The identifier of the Help Center. This is used in the URL of the Help Center. */ + identifier?: string; + /** Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ + website_turned_on?: boolean; + /** The display name of the Help Center only seen by teammates. */ + display_name?: string; + /** The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. */ + url?: string; + /** Custom domain configured for the help center */ + custom_domain?: string; + /** Whether this help center is the default for the workspace. */ + default?: boolean; + /** The locales in which the help center is available. */ + locales?: string[]; +} + +/** + * A list of Help Centers belonging to the App + */ +export interface HelpCenterList { + /** The type of the object - `list`. */ + type?: "list"; + /** An array of Help Center objects */ + data?: Intercom.preview.HelpCenter[]; +} diff --git a/src/api/resources/preview/resources/identityVerificationSecrets/client/Client.ts b/src/api/resources/preview/resources/identityVerificationSecrets/client/Client.ts new file mode 100644 index 00000000..6fff5fc9 --- /dev/null +++ b/src/api/resources/preview/resources/identityVerificationSecrets/client/Client.ts @@ -0,0 +1,266 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace IdentityVerificationSecretsClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Manage HMAC signing secrets for Messenger identity verification — list, create, and rotate out. Signing material is returned only once, at creation time. + */ +export class IdentityVerificationSecretsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: IdentityVerificationSecretsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Returns the identity verification secrets configured for your workspace. + * + * Each entry includes metadata only — the HMAC signing material itself is **never** returned by this endpoint. The raw secret is only available once, in the response to `POST /secure_mode_secrets`. Persist it at that moment. + * + * @param {IdentityVerificationSecretsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.identityVerificationSecrets.listIdentityVerificationSecrets() + */ + public listIdentityVerificationSecrets( + requestOptions?: IdentityVerificationSecretsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listIdentityVerificationSecrets(requestOptions)); + } + + private async __listIdentityVerificationSecrets( + requestOptions?: IdentityVerificationSecretsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "secure_mode_secrets", + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.IdentityVerificationSecretList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/secure_mode_secrets"); + } + + /** + * Creates a new identity verification secret for your workspace. Intercom generates a 256-bit, cryptographically random value server-side and returns it once in the response. + * + * **This is the only opportunity to capture the secret.** Store it in your secure configuration immediately. The `secret` field is omitted from all subsequent responses (including `GET /secure_mode_secrets`) — if you lose it, you must rotate a new secret in and delete this one. + * + * You must enable the secret for at least one platform (`supports_android`, `supports_ios`, or `supports_web`). Rotation flow: create the new secret, roll it out to every client signing `user_hash` values, then delete the old secret with `DELETE /secure_mode_secrets/{id}` once traffic has cut over. + * + * @param {Intercom.preview.CreateIdentityVerificationSecretRequest} request + * @param {IdentityVerificationSecretsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.identityVerificationSecrets.createIdentityVerificationSecret({ + * name: "Production Web", + * supports_web: true + * }) + * + * @example + * await client.preview.identityVerificationSecrets.createIdentityVerificationSecret({ + * name: "Production all-platform", + * supports_android: true, + * supports_ios: true, + * supports_web: true + * }) + */ + public createIdentityVerificationSecret( + request: Intercom.preview.CreateIdentityVerificationSecretRequest, + requestOptions?: IdentityVerificationSecretsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createIdentityVerificationSecret(request, requestOptions)); + } + + private async __createIdentityVerificationSecret( + request: Intercom.preview.CreateIdentityVerificationSecretRequest, + requestOptions?: IdentityVerificationSecretsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "secure_mode_secrets", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.IdentityVerificationSecretWithMaterial, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/secure_mode_secrets"); + } + + /** + * Soft-deletes an identity verification secret. After deletion, any `user_hash` values signed with that secret will no longer verify — Messenger sessions depending on it will be rejected on their next request. Use this to complete a rotation: create a new secret, roll it out, then delete the old one. + * + * @param {Intercom.preview.DeleteIdentityVerificationSecretRequest} request + * @param {IdentityVerificationSecretsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.identityVerificationSecrets.deleteIdentityVerificationSecret({ + * id: "102" + * }) + */ + public deleteIdentityVerificationSecret( + request: Intercom.preview.DeleteIdentityVerificationSecretRequest, + requestOptions?: IdentityVerificationSecretsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteIdentityVerificationSecret(request, requestOptions)); + } + + private async __deleteIdentityVerificationSecret( + request: Intercom.preview.DeleteIdentityVerificationSecretRequest, + requestOptions?: IdentityVerificationSecretsClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `secure_mode_secrets/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/secure_mode_secrets/{id}"); + } +} diff --git a/src/api/resources/unstable/resources/teams/client/index.ts b/src/api/resources/preview/resources/identityVerificationSecrets/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/teams/client/index.ts rename to src/api/resources/preview/resources/identityVerificationSecrets/client/index.ts diff --git a/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/CreateIdentityVerificationSecretRequest.ts b/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/CreateIdentityVerificationSecretRequest.ts new file mode 100644 index 00000000..d979960c --- /dev/null +++ b/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/CreateIdentityVerificationSecretRequest.ts @@ -0,0 +1,27 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * name: "Production Web", + * supports_web: true + * } + * + * @example + * { + * name: "Production all-platform", + * supports_android: true, + * supports_ios: true, + * supports_web: true + * } + */ +export interface CreateIdentityVerificationSecretRequest { + /** Human-readable name for the secret. */ + name: string; + /** Enable this secret for the Android SDK. */ + supports_android?: boolean; + /** Enable this secret for the iOS SDK. */ + supports_ios?: boolean; + /** Enable this secret for the Messenger on web. */ + supports_web?: boolean; +} diff --git a/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/DeleteIdentityVerificationSecretRequest.ts b/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/DeleteIdentityVerificationSecretRequest.ts new file mode 100644 index 00000000..88173771 --- /dev/null +++ b/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/DeleteIdentityVerificationSecretRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "102" + * } + */ +export interface DeleteIdentityVerificationSecretRequest { + /** The unique identifier of the identity verification secret */ + id: string; +} diff --git a/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/index.ts b/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/index.ts new file mode 100644 index 00000000..a31fefe6 --- /dev/null +++ b/src/api/resources/preview/resources/identityVerificationSecrets/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { CreateIdentityVerificationSecretRequest } from "./CreateIdentityVerificationSecretRequest.js"; +export type { DeleteIdentityVerificationSecretRequest } from "./DeleteIdentityVerificationSecretRequest.js"; diff --git a/src/api/resources/unstable/resources/tags/index.ts b/src/api/resources/preview/resources/identityVerificationSecrets/index.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/index.ts rename to src/api/resources/preview/resources/identityVerificationSecrets/index.ts diff --git a/src/api/resources/preview/resources/identityVerificationSecrets/types/index.ts b/src/api/resources/preview/resources/identityVerificationSecrets/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/identityVerificationSecrets/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/identityVerificationSecrets/types/types.ts b/src/api/resources/preview/resources/identityVerificationSecrets/types/types.ts new file mode 100644 index 00000000..b925cede --- /dev/null +++ b/src/api/resources/preview/resources/identityVerificationSecrets/types/types.ts @@ -0,0 +1,31 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * Metadata for an HMAC secret used to sign `user_hash` values for Messenger identity verification. The `secret` field is intentionally omitted — it is only returned once, in the response to `POST /secure_mode_secrets`. + */ +export interface IdentityVerificationSecret { + /** value is "identity_verification_secret" */ + type?: string; + /** The id of the secret */ + id?: string; + /** Human-readable name for the secret, used to identify it in rotation flows */ + name?: string; + /** Whether the secret is enabled for the Android SDK */ + supports_android?: boolean; + /** Whether the secret is enabled for the iOS SDK */ + supports_ios?: boolean; + /** Whether the secret is enabled for the Messenger on web */ + supports_web?: boolean; + /** The time the secret was created, as a Unix timestamp */ + created_at?: number; +} + +/** + * Returned once, at creation time, from `POST /secure_mode_secrets`. Includes the raw `secret` field. Persist the secret immediately — it is never retrievable again. + */ +export interface IdentityVerificationSecretWithMaterial extends Intercom.preview.IdentityVerificationSecret { + /** The 256-bit HMAC signing key, base64url-encoded. Returned ONCE at creation time and never surfaced again. */ + secret?: string; +} diff --git a/src/api/resources/unstable/resources/index.ts b/src/api/resources/preview/resources/index.ts similarity index 60% rename from src/api/resources/unstable/resources/index.ts rename to src/api/resources/preview/resources/index.ts index e821213e..db26d893 100644 --- a/src/api/resources/unstable/resources/index.ts +++ b/src/api/resources/preview/resources/index.ts @@ -8,10 +8,21 @@ export * as aiContent from "./aiContent/index.js"; export * from "./aiContent/types/index.js"; export * as aiContentSource from "./aiContentSource/index.js"; export * from "./aiContentSource/types/index.js"; +export * as aiTopics from "./aiTopics/index.js"; +export * from "./aiTopics/types/index.js"; export * from "./articles/client/requests/index.js"; export * as articles from "./articles/index.js"; export * from "./articles/types/index.js"; +export * from "./audiences/client/requests/index.js"; +export * as audiences from "./audiences/index.js"; +export * from "./audiences/types/index.js"; +export * from "./authTokens/client/requests/index.js"; +export * as authTokens from "./authTokens/index.js"; +export * from "./authTokens/types/index.js"; export * as awayStatusReasons from "./awayStatusReasons/index.js"; +export * from "./banners/client/requests/index.js"; +export * as banners from "./banners/index.js"; +export * from "./banners/types/index.js"; export * from "./brands/client/requests/index.js"; export * as brands from "./brands/index.js"; export * from "./brands/types/index.js"; @@ -24,32 +35,56 @@ export * from "./companies/types/index.js"; export * from "./contacts/client/requests/index.js"; export * as contacts from "./contacts/index.js"; export * from "./contacts/types/index.js"; +export * from "./content/client/requests/index.js"; +export * as content from "./content/index.js"; +export * from "./content/types/index.js"; +export * from "./contentSnippets/client/requests/index.js"; +export * as contentSnippets from "./contentSnippets/index.js"; +export * from "./contentSnippets/types/index.js"; +export * as conversation from "./conversation/index.js"; +export * from "./conversation/types/index.js"; +export * from "./conversationParticipants/client/requests/index.js"; +export * as conversationParticipants from "./conversationParticipants/index.js"; +export * from "./conversationParts/client/requests/index.js"; +export * as conversationParts from "./conversationParts/index.js"; export * from "./conversations/client/requests/index.js"; export * as conversations from "./conversations/index.js"; export * from "./conversations/types/index.js"; -export * from "./customChannelEvents/client/requests/index.js"; -export * as customChannelEvents from "./customChannelEvents/index.js"; +export * from "./conversationsAttributes/client/requests/index.js"; +export * as conversationsAttributes from "./conversationsAttributes/index.js"; +export * from "./conversationsAttributes/types/index.js"; export * from "./customObjectInstances/client/requests/index.js"; export * as customObjectInstances from "./customObjectInstances/index.js"; export * from "./customObjectInstances/types/index.js"; export * from "./dataAttributes/client/requests/index.js"; export * as dataAttributes from "./dataAttributes/index.js"; export * from "./dataAttributes/types/index.js"; +export * from "./dataConnectors/client/requests/index.js"; +export * as dataConnectors from "./dataConnectors/index.js"; +export * from "./dataConnectors/types/index.js"; export * from "./dataEvents/client/requests/index.js"; export * as dataEvents from "./dataEvents/index.js"; export * from "./dataEvents/types/index.js"; export * from "./dataExport/client/requests/index.js"; export * as dataExport from "./dataExport/index.js"; export * from "./dataExport/types/index.js"; +export * from "./ecommerceConnectors/client/requests/index.js"; +export * as ecommerceConnectors from "./ecommerceConnectors/index.js"; export * from "./emails/client/requests/index.js"; export * as emails from "./emails/index.js"; export * from "./emails/types/index.js"; -export * from "./export/client/requests/index.js"; -export * as export_ from "./export/index.js"; -export * from "./export/types/index.js"; +export * from "./finAgent/client/requests/index.js"; +export * as finAgent from "./finAgent/index.js"; +export * from "./finAgent/types/index.js"; +export * from "./folders/client/requests/index.js"; +export * as folders from "./folders/index.js"; +export * from "./folders/types/index.js"; export * from "./helpCenter/client/requests/index.js"; export * as helpCenter from "./helpCenter/index.js"; export * from "./helpCenter/types/index.js"; +export * from "./identityVerificationSecrets/client/requests/index.js"; +export * as identityVerificationSecrets from "./identityVerificationSecrets/index.js"; +export * from "./identityVerificationSecrets/types/index.js"; export * from "./internalArticles/client/requests/index.js"; export * as internalArticles from "./internalArticles/index.js"; export * from "./internalArticles/types/index.js"; @@ -68,6 +103,19 @@ export * from "./news/types/index.js"; export * from "./notes/client/requests/index.js"; export * as notes from "./notes/index.js"; export * from "./notes/types/index.js"; +export * from "./officeHours/client/requests/index.js"; +export * as officeHours from "./officeHours/index.js"; +export * from "./officeHours/types/index.js"; +export * from "./procedures/client/requests/index.js"; +export * as procedures from "./procedures/index.js"; +export * from "./reportingDataExport/client/requests/index.js"; +export * as reportingDataExport from "./reportingDataExport/index.js"; +export * from "./reportingDataExport/types/index.js"; +export * from "./roles/client/requests/index.js"; +export * as roles from "./roles/index.js"; +export * from "./roles/types/index.js"; +export * as salesAgent from "./salesAgent/index.js"; +export * from "./salesAgent/types/index.js"; export * from "./segments/client/requests/index.js"; export * as segments from "./segments/index.js"; export * from "./segments/types/index.js"; diff --git a/src/api/resources/unstable/resources/internalArticles/client/Client.ts b/src/api/resources/preview/resources/internalArticles/client/Client.ts similarity index 55% rename from src/api/resources/unstable/resources/internalArticles/client/Client.ts rename to src/api/resources/preview/resources/internalArticles/client/Client.ts index bcfe5c32..a6b80a91 100644 --- a/src/api/resources/unstable/resources/internalArticles/client/Client.ts +++ b/src/api/resources/preview/resources/internalArticles/client/Client.ts @@ -30,20 +30,20 @@ export class InternalArticlesClient { * * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.internalArticles.listInternalArticles() + * await client.preview.internalArticles.listInternalArticles() */ public listInternalArticles( requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listInternalArticles(requestOptions)); } private async __listInternalArticles( requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -68,17 +68,14 @@ export class InternalArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.InternalArticleList, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.InternalArticleList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -96,22 +93,24 @@ export class InternalArticlesClient { /** * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. * - * @param {Intercom.unstable.CreateInternalArticleRequest} request + * @param {Intercom.preview.CreateInternalArticleRequest} request * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.internalArticles.createInternalArticle({ + * await client.preview.internalArticles.createInternalArticle({ * title: "Thanks for everything", * body: "Body of the Article", * author_id: 991266252, - * owner_id: 991266252 + * owner_id: 991266252, + * audience_ids: [1, 2] * }) * * @example - * await client.unstable.internalArticles.createInternalArticle({ + * await client.preview.internalArticles.createInternalArticle({ * title: "Thanks for everything", * body: "Body of the Internal Article", * author_id: 1295, @@ -119,16 +118,16 @@ export class InternalArticlesClient { * }) */ public createInternalArticle( - request?: Intercom.unstable.CreateInternalArticleRequest, + request?: Intercom.preview.CreateInternalArticleRequest, requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createInternalArticle(request, requestOptions)); } private async __createInternalArticle( - request?: Intercom.unstable.CreateInternalArticleRequest, + request?: Intercom.preview.CreateInternalArticleRequest, requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -156,18 +155,20 @@ export class InternalArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.InternalArticle, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.InternalArticle, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -183,28 +184,28 @@ export class InternalArticlesClient { /** * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. * - * @param {Intercom.unstable.RetrieveInternalArticleRequest} request + * @param {Intercom.preview.RetrieveInternalArticleRequest} request * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.internalArticles.retrieveInternalArticle({ + * await client.preview.internalArticles.retrieveInternalArticle({ * id: 1 * }) */ public retrieveInternalArticle( - request: Intercom.unstable.RetrieveInternalArticleRequest, + request: Intercom.preview.RetrieveInternalArticleRequest, requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__retrieveInternalArticle(request, requestOptions)); } private async __retrieveInternalArticle( - request: Intercom.unstable.RetrieveInternalArticleRequest, + request: Intercom.preview.RetrieveInternalArticleRequest, requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -230,18 +231,18 @@ export class InternalArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.InternalArticle, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.InternalArticle, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -257,30 +258,38 @@ export class InternalArticlesClient { /** * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. * - * @param {Intercom.unstable.UpdateInternalArticleRequestBody} request + * @param {Intercom.preview.UpdateInternalArticleRequestBody} request * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.internalArticles.updateInternalArticle({ + * id: 1, + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

", + * audience_ids: [1, 2] + * }) * * @example - * await client.unstable.internalArticles.updateInternalArticle({ + * await client.preview.internalArticles.updateInternalArticle({ * id: 1, * title: "Christmas is here!", * body: "

New gifts in store for the jolly season

" * }) */ public updateInternalArticle( - request: Intercom.unstable.UpdateInternalArticleRequestBody, + request: Intercom.preview.UpdateInternalArticleRequestBody, requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateInternalArticle(request, requestOptions)); } private async __updateInternalArticle( - request: Intercom.unstable.UpdateInternalArticleRequestBody, + request: Intercom.preview.UpdateInternalArticleRequestBody, requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -309,18 +318,18 @@ export class InternalArticlesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.InternalArticle, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.InternalArticle, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -336,28 +345,28 @@ export class InternalArticlesClient { /** * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. * - * @param {Intercom.unstable.DeleteInternalArticleRequest} request + * @param {Intercom.preview.DeleteInternalArticleRequest} request * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.internalArticles.deleteInternalArticle({ + * await client.preview.internalArticles.deleteInternalArticle({ * id: 1 * }) */ public deleteInternalArticle( - request: Intercom.unstable.DeleteInternalArticleRequest, + request: Intercom.preview.DeleteInternalArticleRequest, requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteInternalArticle(request, requestOptions)); } private async __deleteInternalArticle( - request: Intercom.unstable.DeleteInternalArticleRequest, + request: Intercom.preview.DeleteInternalArticleRequest, requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -384,7 +393,7 @@ export class InternalArticlesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.DeletedInternalArticleObject, + data: _response.body as Intercom.preview.DeletedInternalArticleObject, rawResponse: _response.rawResponse, }; } @@ -392,12 +401,12 @@ export class InternalArticlesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -410,34 +419,221 @@ export class InternalArticlesClient { return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/internal_articles/{id}"); } + /** + * Apply an existing tag to an internal article. Returns the tag that was applied. + * + * The tag must already exist in the workspace (create tags with the Tags API), + * and the authenticating teammate must have the `manage_knowledge_base_content` + * permission. + * + * Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.AttachTagToInternalArticleRequest} request + * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.internalArticles.attachTagToInternalArticle({ + * internal_article_id: 1, + * id: "7522907" + * }) + */ + public attachTagToInternalArticle( + request: Intercom.preview.AttachTagToInternalArticleRequest, + requestOptions?: InternalArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachTagToInternalArticle(request, requestOptions)); + } + + private async __attachTagToInternalArticle( + request: Intercom.preview.AttachTagToInternalArticleRequest, + requestOptions?: InternalArticlesClient.RequestOptions, + ): Promise> { + const { internal_article_id: internalArticleId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `internal_articles/${core.url.encodePathParam(internalArticleId)}/tags`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/internal_articles/{internal_article_id}/tags", + ); + } + + /** + * Remove a tag from an internal article. Returns the tag that was removed, with + * null `applied_at` and `applied_by`. + * + * The authenticating teammate must have the `manage_knowledge_base_content` + * permission. + * + * Requires the `read_write_articles_scope` OAuth scope. Set `Intercom-Version: Preview`. + * + * @param {Intercom.preview.DetachTagFromInternalArticleRequest} request + * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.internalArticles.detachTagFromInternalArticle({ + * internal_article_id: 1, + * id: "7522907" + * }) + */ + public detachTagFromInternalArticle( + request: Intercom.preview.DetachTagFromInternalArticleRequest, + requestOptions?: InternalArticlesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachTagFromInternalArticle(request, requestOptions)); + } + + private async __detachTagFromInternalArticle( + request: Intercom.preview.DetachTagFromInternalArticleRequest, + requestOptions?: InternalArticlesClient.RequestOptions, + ): Promise> { + const { internal_article_id: internalArticleId, id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `internal_articles/${core.url.encodePathParam(internalArticleId)}/tags/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/internal_articles/{internal_article_id}/tags/{id}", + ); + } + /** * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. * - * @param {Intercom.unstable.SearchInternalArticlesRequest} request + * @param {Intercom.preview.SearchInternalArticlesRequest} request * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.internalArticles.searchInternalArticles({ - * folder_id: "folder_id" + * await client.preview.internalArticles.searchInternalArticles({ + * folder_id: 1 * }) */ public searchInternalArticles( - request: Intercom.unstable.SearchInternalArticlesRequest = {}, + request: Intercom.preview.SearchInternalArticlesRequest = {}, requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__searchInternalArticles(request, requestOptions)); } private async __searchInternalArticles( - request: Intercom.unstable.SearchInternalArticlesRequest = {}, + request: Intercom.preview.SearchInternalArticlesRequest = {}, requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { + ): Promise> { const { folder_id: folderId } = request; const _queryParams: Record = {}; if (folderId != null) { - _queryParams.folder_id = folderId; + _queryParams.folder_id = folderId.toString(); } const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); @@ -465,7 +661,7 @@ export class InternalArticlesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.InternalArticleSearchResponse, + data: _response.body as Intercom.preview.InternalArticleSearchResponse, rawResponse: _response.rawResponse, }; } @@ -473,8 +669,8 @@ export class InternalArticlesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/index.ts b/src/api/resources/preview/resources/internalArticles/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypeAttributes/client/index.ts rename to src/api/resources/preview/resources/internalArticles/client/index.ts diff --git a/src/api/resources/preview/resources/internalArticles/client/requests/AttachTagToInternalArticleRequest.ts b/src/api/resources/preview/resources/internalArticles/client/requests/AttachTagToInternalArticleRequest.ts new file mode 100644 index 00000000..00f76c34 --- /dev/null +++ b/src/api/resources/preview/resources/internalArticles/client/requests/AttachTagToInternalArticleRequest.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * internal_article_id: 1, + * id: "7522907" + * } + */ +export interface AttachTagToInternalArticleRequest { + /** The unique identifier for the internal article which is given by Intercom. */ + internal_article_id: number; + /** The unique identifier of the tag to apply, as given by Intercom. */ + id: string; + /** Optional id of the teammate to attribute the tagging to. Defaults to the authenticating teammate. Does not affect authorization. */ + admin_id?: string; +} diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts b/src/api/resources/preview/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts rename to src/api/resources/preview/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts diff --git a/src/api/resources/preview/resources/internalArticles/client/requests/DetachTagFromInternalArticleRequest.ts b/src/api/resources/preview/resources/internalArticles/client/requests/DetachTagFromInternalArticleRequest.ts new file mode 100644 index 00000000..9998741c --- /dev/null +++ b/src/api/resources/preview/resources/internalArticles/client/requests/DetachTagFromInternalArticleRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * internal_article_id: 1, + * id: "7522907" + * } + */ +export interface DetachTagFromInternalArticleRequest { + /** The unique identifier for the internal article which is given by Intercom. */ + internal_article_id: number; + /** The unique identifier of the tag to remove, as given by Intercom. */ + id: string; +} diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts b/src/api/resources/preview/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts rename to src/api/resources/preview/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts diff --git a/src/api/resources/preview/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts b/src/api/resources/preview/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts new file mode 100644 index 00000000..d733902f --- /dev/null +++ b/src/api/resources/preview/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * folder_id: 1 + * } + */ +export interface SearchInternalArticlesRequest { + /** The ID of the folder to search in. Results will include articles from this folder and all its descendant folders. */ + folder_id?: number; +} diff --git a/src/api/resources/preview/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts b/src/api/resources/preview/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts new file mode 100644 index 00000000..ee5087f5 --- /dev/null +++ b/src/api/resources/preview/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts @@ -0,0 +1,42 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: 1, + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

", + * audience_ids: [1, 2] + * } + * + * @example + * { + * id: 1, + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

" + * } + */ +export interface UpdateInternalArticleRequestBody { + /** The unique identifier for the internal article which is given by Intercom. */ + id: number; + /** The title of the article. */ + title?: string; + /** The content of the article in HTML. Mutually exclusive with `body_markdown`. */ + body?: string; + /** The content of the article in markdown. An alternative to `body` — you can provide content as markdown instead of HTML. Mutually exclusive with `body`. */ + body_markdown?: string; + /** The id of the author of the article. */ + author_id?: number; + /** The id of the owner of the article. */ + owner_id?: number; + /** The ID of the folder to place this article in, or null to remove it from its folder. */ + folder_id?: number; + /** The list of audience IDs to target this internal article to for Fin AI Agent. Omitting the field leaves existing audience memberships unchanged (PATCH semantics). Pass `[]` to clear all audience memberships. Unknown audience IDs return a `404` error with no partial commit. */ + audience_ids?: number[]; + /** Whether the internal article should be available for AI Chatbot (Fin). */ + ai_chatbot_availability?: boolean; + /** Whether the internal article should be available for AI Copilot. */ + ai_copilot_availability?: boolean; + /** Whether the internal article should be available for AI Sales Agent. */ + ai_sales_agent_availability?: boolean; +} diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/index.ts b/src/api/resources/preview/resources/internalArticles/client/requests/index.ts similarity index 64% rename from src/api/resources/unstable/resources/internalArticles/client/requests/index.ts rename to src/api/resources/preview/resources/internalArticles/client/requests/index.ts index 677bd9fa..8ab300a4 100644 --- a/src/api/resources/unstable/resources/internalArticles/client/requests/index.ts +++ b/src/api/resources/preview/resources/internalArticles/client/requests/index.ts @@ -1,4 +1,6 @@ +export type { AttachTagToInternalArticleRequest } from "./AttachTagToInternalArticleRequest.js"; export type { DeleteInternalArticleRequest } from "./DeleteInternalArticleRequest.js"; +export type { DetachTagFromInternalArticleRequest } from "./DetachTagFromInternalArticleRequest.js"; export type { RetrieveInternalArticleRequest } from "./RetrieveInternalArticleRequest.js"; export type { SearchInternalArticlesRequest } from "./SearchInternalArticlesRequest.js"; export type { UpdateInternalArticleRequestBody } from "./UpdateInternalArticleRequestBody.js"; diff --git a/src/api/resources/unstable/resources/teams/index.ts b/src/api/resources/preview/resources/internalArticles/index.ts similarity index 100% rename from src/api/resources/unstable/resources/teams/index.ts rename to src/api/resources/preview/resources/internalArticles/index.ts diff --git a/src/api/resources/preview/resources/internalArticles/types/index.ts b/src/api/resources/preview/resources/internalArticles/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/internalArticles/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/internalArticles/types/types.ts b/src/api/resources/preview/resources/internalArticles/types/types.ts new file mode 100644 index 00000000..8b9a0078 --- /dev/null +++ b/src/api/resources/preview/resources/internalArticles/types/types.ts @@ -0,0 +1,63 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * The data returned about your internal articles when you list them. + */ +export interface InternalArticleListItem { + /** The type of object - `internal_article`. */ + type?: "internal_article"; + /** The unique identifier for the article which is given by Intercom. */ + id?: string; + /** The title of the article. */ + title?: string; + /** The body of the article in HTML. */ + body?: string; + /** The body of the article in markdown. */ + body_markdown?: string; + /** The id of the owner of the article. */ + owner_id?: number; + /** The id of the author of the article. */ + author_id?: number; + /** The time when the article was created. */ + created_at?: number; + /** The time when the article was last updated. */ + updated_at?: number; + /** The default locale of the article. */ + locale?: string; + /** The ID of the folder this article belongs to, or null if not in a folder. */ + folder_id?: number; + /** The list of audience IDs this internal article is targeted to for Fin AI Agent. Empty array means no audience targeting is set. */ + audience_ids?: number[]; + /** Whether the internal article is available for AI Chatbot (Fin). */ + ai_chatbot_availability?: boolean; + /** Whether the internal article is available for AI Copilot. */ + ai_copilot_availability?: boolean; + /** Whether the internal article is available for AI Sales Agent. */ + ai_sales_agent_availability?: boolean; + tags?: Intercom.preview.Tags; +} + +/** + * The results of an Internal Article search + */ +export interface InternalArticleSearchResponse { + /** The type of the object - `list`. */ + type?: "list"; + /** The total number of Internal Articles matching the search query */ + total_count?: number; + /** An object containing the results of the search. */ + data?: InternalArticleSearchResponse.Data; + pages?: Intercom.preview.CursorPages; +} + +export namespace InternalArticleSearchResponse { + /** + * An object containing the results of the search. + */ + export interface Data { + /** An array of Internal Article objects */ + internal_articles?: Intercom.preview.InternalArticle[]; + } +} diff --git a/src/api/resources/unstable/resources/jobs/client/Client.ts b/src/api/resources/preview/resources/jobs/client/Client.ts similarity index 81% rename from src/api/resources/unstable/resources/jobs/client/Client.ts rename to src/api/resources/preview/resources/jobs/client/Client.ts index 232af1bd..58b850bd 100644 --- a/src/api/resources/unstable/resources/jobs/client/Client.ts +++ b/src/api/resources/preview/resources/jobs/client/Client.ts @@ -28,28 +28,28 @@ export class JobsClient { /** * Retrieve the status of job execution. * - * @param {Intercom.unstable.JobsStatusRequest} request + * @param {Intercom.preview.JobsStatusRequest} request * @param {JobsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.jobs.status({ + * await client.preview.jobs.status({ * id: "id" * }) */ public status( - request: Intercom.unstable.JobsStatusRequest, + request: Intercom.preview.JobsStatusRequest, requestOptions?: JobsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__status(request, requestOptions)); } private async __status( - request: Intercom.unstable.JobsStatusRequest, + request: Intercom.preview.JobsStatusRequest, requestOptions?: JobsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -75,18 +75,18 @@ export class JobsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Jobs, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Jobs, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/unstable/resources/ticketTypes/client/index.ts b/src/api/resources/preview/resources/jobs/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypes/client/index.ts rename to src/api/resources/preview/resources/jobs/client/index.ts diff --git a/src/api/resources/unstable/resources/jobs/client/requests/JobsStatusRequest.ts b/src/api/resources/preview/resources/jobs/client/requests/JobsStatusRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/jobs/client/requests/JobsStatusRequest.ts rename to src/api/resources/preview/resources/jobs/client/requests/JobsStatusRequest.ts diff --git a/src/api/resources/unstable/resources/jobs/client/requests/index.ts b/src/api/resources/preview/resources/jobs/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/jobs/client/requests/index.ts rename to src/api/resources/preview/resources/jobs/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/tickets/index.ts b/src/api/resources/preview/resources/jobs/index.ts similarity index 100% rename from src/api/resources/unstable/resources/tickets/index.ts rename to src/api/resources/preview/resources/jobs/index.ts diff --git a/src/api/resources/preview/resources/jobs/types/index.ts b/src/api/resources/preview/resources/jobs/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/jobs/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/jobs/types/Jobs.ts b/src/api/resources/preview/resources/jobs/types/types.ts similarity index 100% rename from src/api/resources/unstable/resources/jobs/types/Jobs.ts rename to src/api/resources/preview/resources/jobs/types/types.ts diff --git a/src/api/resources/unstable/resources/macros/client/Client.ts b/src/api/resources/preview/resources/macros/client/Client.ts similarity index 79% rename from src/api/resources/unstable/resources/macros/client/Client.ts rename to src/api/resources/preview/resources/macros/client/Client.ts index 60a0a207..2ee5e312 100644 --- a/src/api/resources/unstable/resources/macros/client/Client.ts +++ b/src/api/resources/preview/resources/macros/client/Client.ts @@ -40,31 +40,31 @@ export class MacrosClient { * - From: `{{user.name | fallback: 'there'}}` * - To: `` * - * @param {Intercom.unstable.ListMacrosRequest} request + * @param {Intercom.preview.ListMacrosRequest} request * @param {MacrosClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} * * @example - * await client.unstable.macros.listMacros({ + * await client.preview.macros.listMacros({ * per_page: 1, * starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", * updated_since: 1000000 * }) */ public listMacros( - request: Intercom.unstable.ListMacrosRequest = {}, + request: Intercom.preview.ListMacrosRequest = {}, requestOptions?: MacrosClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listMacros(request, requestOptions)); } private async __listMacros( - request: Intercom.unstable.ListMacrosRequest = {}, + request: Intercom.preview.ListMacrosRequest = {}, requestOptions?: MacrosClient.RequestOptions, - ): Promise> { + ): Promise> { const { per_page: perPage, starting_after: startingAfter, updated_since: updatedSince } = request; const _queryParams: Record = {}; if (perPage != null) { @@ -103,21 +103,21 @@ export class MacrosClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.MacroList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.MacroList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -151,29 +151,29 @@ export class MacrosClient { * * Default values in placeholders are HTML-escaped for security. * - * @param {Intercom.unstable.GetMacroRequest} request + * @param {Intercom.preview.GetMacroRequest} request * @param {MacrosClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.macros.getMacro({ + * await client.preview.macros.getMacro({ * id: "123" * }) */ public getMacro( - request: Intercom.unstable.GetMacroRequest, + request: Intercom.preview.GetMacroRequest, requestOptions?: MacrosClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getMacro(request, requestOptions)); } private async __getMacro( - request: Intercom.unstable.GetMacroRequest, + request: Intercom.preview.GetMacroRequest, requestOptions?: MacrosClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -199,23 +199,23 @@ export class MacrosClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Macro | undefined, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Macro | undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/unstable/resources/tickets/client/index.ts b/src/api/resources/preview/resources/macros/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/tickets/client/index.ts rename to src/api/resources/preview/resources/macros/client/index.ts diff --git a/src/api/resources/unstable/resources/macros/client/requests/GetMacroRequest.ts b/src/api/resources/preview/resources/macros/client/requests/GetMacroRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/macros/client/requests/GetMacroRequest.ts rename to src/api/resources/preview/resources/macros/client/requests/GetMacroRequest.ts diff --git a/src/api/resources/unstable/resources/macros/client/requests/ListMacrosRequest.ts b/src/api/resources/preview/resources/macros/client/requests/ListMacrosRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/macros/client/requests/ListMacrosRequest.ts rename to src/api/resources/preview/resources/macros/client/requests/ListMacrosRequest.ts diff --git a/src/api/resources/unstable/resources/macros/client/requests/index.ts b/src/api/resources/preview/resources/macros/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/macros/client/requests/index.ts rename to src/api/resources/preview/resources/macros/client/requests/index.ts diff --git a/src/api/resources/preview/resources/macros/index.ts b/src/api/resources/preview/resources/macros/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/macros/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/macros/types/index.ts b/src/api/resources/preview/resources/macros/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/macros/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/macros/types/Macro.ts b/src/api/resources/preview/resources/macros/types/types.ts similarity index 64% rename from src/api/resources/unstable/resources/macros/types/Macro.ts rename to src/api/resources/preview/resources/macros/types/types.ts index b7941f1a..33d6607e 100644 --- a/src/api/resources/unstable/resources/macros/types/Macro.ts +++ b/src/api/resources/preview/resources/macros/types/types.ts @@ -1,5 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Intercom from "../../../../../index.js"; + /** * A macro is a pre-defined response template (saved reply) that can be used to quickly reply to conversations. */ @@ -43,3 +45,39 @@ export namespace Macro { export type Item = (typeof Item)[keyof typeof Item]; } } + +/** + * A paginated list of macros (saved replies) in the workspace. + */ +export interface MacroList { + /** Always list */ + type?: "list"; + /** The list of macro objects */ + data?: (Intercom.preview.Macro | undefined)[]; + /** Pagination information */ + pages?: MacroList.Pages; +} + +export namespace MacroList { + /** + * Pagination information + */ + export interface Pages { + /** The type of pagination */ + type?: "pages"; + /** Number of results per page */ + per_page?: number; + /** Cursor for the next page */ + next?: Pages.Next; + } + + export namespace Pages { + /** + * Cursor for the next page + */ + export interface Next { + /** Base64-encoded cursor containing [updated_at, id] for pagination */ + starting_after?: string; + } + } +} diff --git a/src/api/resources/unstable/resources/messages/client/Client.ts b/src/api/resources/preview/resources/messages/client/Client.ts similarity index 63% rename from src/api/resources/unstable/resources/messages/client/Client.ts rename to src/api/resources/preview/resources/messages/client/Client.ts index 95d1513f..bed48aea 100644 --- a/src/api/resources/unstable/resources/messages/client/Client.ts +++ b/src/api/resources/preview/resources/messages/client/Client.ts @@ -38,16 +38,16 @@ export class MessagesClient { * > * > As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message. * - * @param {Intercom.unstable.CreateMessageRequest | undefined} request + * @param {Intercom.preview.CreateMessageRequest | undefined} request * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.UnprocessableEntityError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "user", * "id": "6762f2341bb69f9f2193bc17" @@ -57,7 +57,7 @@ export class MessagesClient { * }) * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "lead", * "id": "6762f2371bb69f9f2193bc18" @@ -67,7 +67,7 @@ export class MessagesClient { * }) * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "admin", * "id": "991267816" @@ -107,7 +107,7 @@ export class MessagesClient { * }) * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "admin", * "id": "991267817" @@ -121,7 +121,7 @@ export class MessagesClient { * }) * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "admin", * "id": "991267817" @@ -147,7 +147,7 @@ export class MessagesClient { * }) * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "admin", * "id": "991267818" @@ -161,7 +161,7 @@ export class MessagesClient { * }) * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "admin", * "id": "991267819" @@ -175,7 +175,7 @@ export class MessagesClient { * }) * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "admin", * "id": "991267820" @@ -189,7 +189,7 @@ export class MessagesClient { * }) * * @example - * await client.unstable.messages.createMessage({ + * await client.preview.messages.createMessage({ * "from": { * "type": "admin", * "id": "991267821" @@ -203,16 +203,16 @@ export class MessagesClient { * }) */ public createMessage( - request?: Intercom.unstable.CreateMessageRequest | undefined, + request?: Intercom.preview.CreateMessageRequest | undefined, requestOptions?: MessagesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createMessage(request, requestOptions)); } private async __createMessage( - request?: Intercom.unstable.CreateMessageRequest | undefined, + request?: Intercom.preview.CreateMessageRequest | undefined, requestOptions?: MessagesClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -240,25 +240,25 @@ export class MessagesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Message, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Message, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 422: - throw new Intercom.unstable.UnprocessableEntityError( + throw new Intercom.preview.UnprocessableEntityError( _response.error.body as unknown, _response.rawResponse, ); @@ -281,32 +281,32 @@ export class MessagesClient { * This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing * information about delivery state and related message details. * - * @param {Intercom.unstable.GetWhatsAppMessageStatusRequest} request + * @param {Intercom.preview.GetWhatsAppMessageStatusRequest} request * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.InternalServerError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.InternalServerError} * * @example - * await client.unstable.messages.getWhatsAppMessageStatus({ + * await client.preview.messages.getWhatsAppMessageStatus({ * ruleset_id: "ruleset_id", * per_page: 1, * starting_after: "starting_after" * }) */ public getWhatsAppMessageStatus( - request: Intercom.unstable.GetWhatsAppMessageStatusRequest, + request: Intercom.preview.GetWhatsAppMessageStatusRequest, requestOptions?: MessagesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getWhatsAppMessageStatus(request, requestOptions)); } private async __getWhatsAppMessageStatus( - request: Intercom.unstable.GetWhatsAppMessageStatusRequest, + request: Intercom.preview.GetWhatsAppMessageStatusRequest, requestOptions?: MessagesClient.RequestOptions, - ): Promise> { + ): Promise> { const { ruleset_id: rulesetId, per_page: perPage, starting_after: startingAfter } = request; const _queryParams: Record = {}; _queryParams.ruleset_id = rulesetId; @@ -343,7 +343,7 @@ export class MessagesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.WhatsappMessageStatusList, + data: _response.body as Intercom.preview.WhatsappMessageStatusList, rawResponse: _response.rawResponse, }; } @@ -351,20 +351,20 @@ export class MessagesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 500: - throw new Intercom.unstable.InternalServerError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.InternalServerError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -378,4 +378,89 @@ export class MessagesClient { return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/messages/status"); } + + /** + * Retrieves the delivery status of a specific WhatsApp message by its message ID. + * + * + * Returns the current status, conversation details, and any error information if the message failed to deliver. + * + * @param {Intercom.preview.RetrieveWhatsAppMessageStatusRequest} request + * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.messages.retrieveWhatsAppMessageStatus({ + * message_id: "message_id" + * }) + */ + public retrieveWhatsAppMessageStatus( + request: Intercom.preview.RetrieveWhatsAppMessageStatusRequest, + requestOptions?: MessagesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveWhatsAppMessageStatus(request, requestOptions)); + } + + private async __retrieveWhatsAppMessageStatus( + request: Intercom.preview.RetrieveWhatsAppMessageStatusRequest, + requestOptions?: MessagesClient.RequestOptions, + ): Promise> { + const { message_id: messageId } = request; + const _queryParams: Record = {}; + _queryParams.message_id = messageId; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "messages/whatsapp/status", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.WhatsappMessageStatus, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/messages/whatsapp/status"); + } } diff --git a/src/api/resources/unstable/resources/visitors/client/index.ts b/src/api/resources/preview/resources/messages/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/visitors/client/index.ts rename to src/api/resources/preview/resources/messages/client/index.ts diff --git a/src/api/resources/unstable/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts b/src/api/resources/preview/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts rename to src/api/resources/preview/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts diff --git a/src/api/resources/preview/resources/messages/client/requests/RetrieveWhatsAppMessageStatusRequest.ts b/src/api/resources/preview/resources/messages/client/requests/RetrieveWhatsAppMessageStatusRequest.ts new file mode 100644 index 00000000..bf9eaf49 --- /dev/null +++ b/src/api/resources/preview/resources/messages/client/requests/RetrieveWhatsAppMessageStatusRequest.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * message_id: "message_id" + * } + * + * @example + * { + * message_id: "message_id" + * } + */ +export interface RetrieveWhatsAppMessageStatusRequest { + /** The WhatsApp message ID to check status for */ + message_id: string; +} diff --git a/src/api/resources/preview/resources/messages/client/requests/index.ts b/src/api/resources/preview/resources/messages/client/requests/index.ts new file mode 100644 index 00000000..afc2cd3c --- /dev/null +++ b/src/api/resources/preview/resources/messages/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { GetWhatsAppMessageStatusRequest } from "./GetWhatsAppMessageStatusRequest.js"; +export type { RetrieveWhatsAppMessageStatusRequest } from "./RetrieveWhatsAppMessageStatusRequest.js"; diff --git a/src/api/resources/preview/resources/messages/index.ts b/src/api/resources/preview/resources/messages/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/messages/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/messages/types/index.ts b/src/api/resources/preview/resources/messages/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/messages/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/messages/types/Message.ts b/src/api/resources/preview/resources/messages/types/types.ts similarity index 100% rename from src/api/resources/unstable/resources/messages/types/Message.ts rename to src/api/resources/preview/resources/messages/types/types.ts diff --git a/src/api/resources/unstable/resources/news/client/Client.ts b/src/api/resources/preview/resources/news/client/Client.ts similarity index 79% rename from src/api/resources/unstable/resources/news/client/Client.ts rename to src/api/resources/preview/resources/news/client/Client.ts index a0463196..a9865674 100644 --- a/src/api/resources/unstable/resources/news/client/Client.ts +++ b/src/api/resources/preview/resources/news/client/Client.ts @@ -30,20 +30,20 @@ export class NewsClient { * * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.news.listNewsItems() + * await client.preview.news.listNewsItems() */ public listNewsItems( requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listNewsItems(requestOptions)); } private async __listNewsItems( requestOptions?: NewsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -68,14 +68,14 @@ export class NewsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.PaginatedResponse, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.PaginatedResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -93,13 +93,13 @@ export class NewsClient { /** * You can create a news item * - * @param {Intercom.unstable.NewsItemRequest} request + * @param {Intercom.preview.NewsItemRequest} request * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.news.createNewsItem({ + * await client.preview.news.createNewsItem({ * title: "Halloween is here!", * body: "

New costumes in store for this spooky season

", * sender_id: 991267834, @@ -114,16 +114,16 @@ export class NewsClient { * }) */ public createNewsItem( - request: Intercom.unstable.NewsItemRequest, + request: Intercom.preview.NewsItemRequest, requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createNewsItem(request, requestOptions)); } private async __createNewsItem( - request: Intercom.unstable.NewsItemRequest, + request: Intercom.preview.NewsItemRequest, requestOptions?: NewsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -151,14 +151,14 @@ export class NewsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.NewsItem, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.NewsItem, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -176,28 +176,28 @@ export class NewsClient { /** * You can fetch the details of a single news item. * - * @param {Intercom.unstable.RetrieveNewsItemRequest} request + * @param {Intercom.preview.RetrieveNewsItemRequest} request * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.news.retrieveNewsItem({ + * await client.preview.news.retrieveNewsItem({ * id: 1 * }) */ public retrieveNewsItem( - request: Intercom.unstable.RetrieveNewsItemRequest, + request: Intercom.preview.RetrieveNewsItemRequest, requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__retrieveNewsItem(request, requestOptions)); } private async __retrieveNewsItem( - request: Intercom.unstable.RetrieveNewsItemRequest, + request: Intercom.preview.RetrieveNewsItemRequest, requestOptions?: NewsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -223,18 +223,18 @@ export class NewsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.NewsItem, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.NewsItem, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -248,14 +248,14 @@ export class NewsClient { } /** - * @param {Intercom.unstable.UpdateNewsItemRequest} request + * @param {Intercom.preview.UpdateNewsItemRequest} request * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.news.updateNewsItem({ + * await client.preview.news.updateNewsItem({ * id: 1, * body: { * title: "Christmas is here!", @@ -266,7 +266,7 @@ export class NewsClient { * }) * * @example - * await client.unstable.news.updateNewsItem({ + * await client.preview.news.updateNewsItem({ * id: 1, * body: { * title: "Christmas is here!", @@ -277,16 +277,16 @@ export class NewsClient { * }) */ public updateNewsItem( - request: Intercom.unstable.UpdateNewsItemRequest, + request: Intercom.preview.UpdateNewsItemRequest, requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateNewsItem(request, requestOptions)); } private async __updateNewsItem( - request: Intercom.unstable.UpdateNewsItemRequest, + request: Intercom.preview.UpdateNewsItemRequest, requestOptions?: NewsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, body: _body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -315,18 +315,18 @@ export class NewsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.NewsItem, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.NewsItem, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -342,28 +342,28 @@ export class NewsClient { /** * You can delete a single news item. * - * @param {Intercom.unstable.DeleteNewsItemRequest} request + * @param {Intercom.preview.DeleteNewsItemRequest} request * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.news.deleteNewsItem({ + * await client.preview.news.deleteNewsItem({ * id: 1 * }) */ public deleteNewsItem( - request: Intercom.unstable.DeleteNewsItemRequest, + request: Intercom.preview.DeleteNewsItemRequest, requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteNewsItem(request, requestOptions)); } private async __deleteNewsItem( - request: Intercom.unstable.DeleteNewsItemRequest, + request: Intercom.preview.DeleteNewsItemRequest, requestOptions?: NewsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -389,18 +389,18 @@ export class NewsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.DeletedObject, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.DeletedObject, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -416,27 +416,27 @@ export class NewsClient { /** * You can fetch a list of all news items that are live on a given newsfeed * - * @param {Intercom.unstable.ListLiveNewsfeedItemsRequest} request + * @param {Intercom.preview.ListLiveNewsfeedItemsRequest} request * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.news.listLiveNewsfeedItems({ + * await client.preview.news.listLiveNewsfeedItems({ * id: "123" * }) */ public listLiveNewsfeedItems( - request: Intercom.unstable.ListLiveNewsfeedItemsRequest, + request: Intercom.preview.ListLiveNewsfeedItemsRequest, requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listLiveNewsfeedItems(request, requestOptions)); } private async __listLiveNewsfeedItems( - request: Intercom.unstable.ListLiveNewsfeedItemsRequest, + request: Intercom.preview.ListLiveNewsfeedItemsRequest, requestOptions?: NewsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -462,14 +462,14 @@ export class NewsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.PaginatedResponse, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.PaginatedResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -489,20 +489,20 @@ export class NewsClient { * * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.news.listNewsfeeds() + * await client.preview.news.listNewsfeeds() */ public listNewsfeeds( requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listNewsfeeds(requestOptions)); } private async __listNewsfeeds( requestOptions?: NewsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -527,14 +527,14 @@ export class NewsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.PaginatedResponse, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.PaginatedResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -552,27 +552,27 @@ export class NewsClient { /** * You can fetch the details of a single newsfeed * - * @param {Intercom.unstable.RetrieveNewsfeedRequest} request + * @param {Intercom.preview.RetrieveNewsfeedRequest} request * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.news.retrieveNewsfeed({ + * await client.preview.news.retrieveNewsfeed({ * id: "123" * }) */ public retrieveNewsfeed( - request: Intercom.unstable.RetrieveNewsfeedRequest, + request: Intercom.preview.RetrieveNewsfeedRequest, requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__retrieveNewsfeed(request, requestOptions)); } private async __retrieveNewsfeed( - request: Intercom.unstable.RetrieveNewsfeedRequest, + request: Intercom.preview.RetrieveNewsfeedRequest, requestOptions?: NewsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -598,14 +598,14 @@ export class NewsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Newsfeed, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Newsfeed, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/unstable/resources/workflows/client/index.ts b/src/api/resources/preview/resources/news/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/workflows/client/index.ts rename to src/api/resources/preview/resources/news/client/index.ts diff --git a/src/api/resources/unstable/resources/news/client/requests/DeleteNewsItemRequest.ts b/src/api/resources/preview/resources/news/client/requests/DeleteNewsItemRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/news/client/requests/DeleteNewsItemRequest.ts rename to src/api/resources/preview/resources/news/client/requests/DeleteNewsItemRequest.ts diff --git a/src/api/resources/unstable/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts b/src/api/resources/preview/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts rename to src/api/resources/preview/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts diff --git a/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsItemRequest.ts b/src/api/resources/preview/resources/news/client/requests/RetrieveNewsItemRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/news/client/requests/RetrieveNewsItemRequest.ts rename to src/api/resources/preview/resources/news/client/requests/RetrieveNewsItemRequest.ts diff --git a/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsfeedRequest.ts b/src/api/resources/preview/resources/news/client/requests/RetrieveNewsfeedRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/news/client/requests/RetrieveNewsfeedRequest.ts rename to src/api/resources/preview/resources/news/client/requests/RetrieveNewsfeedRequest.ts diff --git a/src/api/resources/unstable/resources/news/client/requests/UpdateNewsItemRequest.ts b/src/api/resources/preview/resources/news/client/requests/UpdateNewsItemRequest.ts similarity index 95% rename from src/api/resources/unstable/resources/news/client/requests/UpdateNewsItemRequest.ts rename to src/api/resources/preview/resources/news/client/requests/UpdateNewsItemRequest.ts index 8c96cdfa..c9abc3a3 100644 --- a/src/api/resources/unstable/resources/news/client/requests/UpdateNewsItemRequest.ts +++ b/src/api/resources/preview/resources/news/client/requests/UpdateNewsItemRequest.ts @@ -28,5 +28,5 @@ import type * as Intercom from "../../../../../../index.js"; export interface UpdateNewsItemRequest { /** The unique identifier for the news item which is given by Intercom. */ id: number; - body: Intercom.unstable.NewsItemRequest; + body: Intercom.preview.NewsItemRequest; } diff --git a/src/api/resources/unstable/resources/news/client/requests/index.ts b/src/api/resources/preview/resources/news/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/news/client/requests/index.ts rename to src/api/resources/preview/resources/news/client/requests/index.ts diff --git a/src/api/resources/preview/resources/news/index.ts b/src/api/resources/preview/resources/news/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/news/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/news/types/index.ts b/src/api/resources/preview/resources/news/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/news/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/news/types/NewsItem.ts b/src/api/resources/preview/resources/news/types/types.ts similarity index 58% rename from src/api/resources/unstable/resources/news/types/NewsItem.ts rename to src/api/resources/preview/resources/news/types/types.ts index a5ecc130..eca49e07 100644 --- a/src/api/resources/unstable/resources/news/types/NewsItem.ts +++ b/src/api/resources/preview/resources/news/types/types.ts @@ -21,7 +21,7 @@ export interface NewsItem { /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ state?: NewsItem.State; /** A list of newsfeed_assignments to assign to the specified newsfeed. */ - newsfeed_assignments?: Intercom.unstable.NewsfeedAssignment[]; + newsfeed_assignments?: Intercom.preview.NewsfeedAssignment[]; /** Label names displayed to users to categorize the news item. */ labels?: (string | undefined)[]; /** URL of the image used as cover. Must have .jpg or .png extension. */ @@ -44,3 +44,31 @@ export namespace NewsItem { } as const; export type State = (typeof State)[keyof typeof State]; } + +/** + * A newsfeed is a collection of news items, targeted to a specific audience. + * + * Newsfeeds currently cannot be edited through the API, please refer to [this article](https://www.intercom.com/help/en/articles/6362267-getting-started-with-news) to set up your newsfeeds in Intercom. + */ +export interface Newsfeed { + /** The unique identifier for the newsfeed which is given by Intercom. */ + id?: string; + /** The type of object. */ + type?: "newsfeed"; + /** The name of the newsfeed. This name will never be visible to your users. */ + name?: string; + /** Timestamp for when the newsfeed was created. */ + created_at?: number; + /** Timestamp for when the newsfeed was last updated. */ + updated_at?: number; +} + +/** + * Assigns a news item to a newsfeed. + */ +export interface NewsfeedAssignment { + /** The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). */ + newsfeed_id?: number; + /** Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". */ + published_at?: number; +} diff --git a/src/api/resources/preview/resources/notes/client/Client.ts b/src/api/resources/preview/resources/notes/client/Client.ts new file mode 100644 index 00000000..90f2ea23 --- /dev/null +++ b/src/api/resources/preview/resources/notes/client/Client.ts @@ -0,0 +1,501 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace NotesClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Everything about your Notes + */ +export class NotesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: NotesClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * You can fetch a list of notes that are associated to a company. + * + * @param {Intercom.preview.ListCompanyNotesRequest} request + * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.notes.listCompanyNotes({ + * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public listCompanyNotes( + request: Intercom.preview.ListCompanyNotesRequest, + requestOptions?: NotesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listCompanyNotes(request, requestOptions)); + } + + private async __listCompanyNotes( + request: Intercom.preview.ListCompanyNotesRequest, + requestOptions?: NotesClient.RequestOptions, + ): Promise> { + const { company_id: companyId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${core.url.encodePathParam(companyId)}/notes`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.NoteList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{company_id}/notes"); + } + + /** + * You can add a note to a single company. + * + * @param {Intercom.preview.CreateCompanyNoteRequest} request + * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.notes.createCompanyNote({ + * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + * body: "Hello", + * admin_id: "991267583" + * }) + * + * @example + * await client.preview.notes.createCompanyNote({ + * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + * body: "Hello", + * admin_id: "123" + * }) + * + * @example + * await client.preview.notes.createCompanyNote({ + * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + * body: "Hello" + * }) + */ + public createCompanyNote( + request: Intercom.preview.CreateCompanyNoteRequest, + requestOptions?: NotesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createCompanyNote(request, requestOptions)); + } + + private async __createCompanyNote( + request: Intercom.preview.CreateCompanyNoteRequest, + requestOptions?: NotesClient.RequestOptions, + ): Promise> { + const { company_id: companyId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${core.url.encodePathParam(companyId)}/notes`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Note, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/companies/{company_id}/notes", + ); + } + + /** + * You can fetch a list of notes that are associated to a contact. + * + * @param {Intercom.preview.ListNotesRequest} request + * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.notes.listNotes({ + * id: 1 + * }) + */ + public listNotes( + request: Intercom.preview.ListNotesRequest, + requestOptions?: NotesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listNotes(request, requestOptions)); + } + + private async __listNotes( + request: Intercom.preview.ListNotesRequest, + requestOptions?: NotesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/notes`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.NoteList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}/notes"); + } + + /** + * You can add a note to a single contact. + * + * @param {Intercom.preview.CreateNoteRequest} request + * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.notes.createNote({ + * id: 1, + * body: "Hello", + * contact_id: "6762f0ad1bb69f9f2193bb62", + * admin_id: "123" + * }) + * + * @example + * await client.preview.notes.createNote({ + * id: 1, + * body: "Hello", + * contact_id: "6762f0af1bb69f9f2193bb63", + * admin_id: "123" + * }) + * + * @example + * await client.preview.notes.createNote({ + * id: 1, + * body: "Hello", + * contact_id: "123", + * admin_id: "123" + * }) + */ + public createNote( + request: Intercom.preview.CreateNoteRequest, + requestOptions?: NotesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createNote(request, requestOptions)); + } + + private async __createNote( + request: Intercom.preview.CreateNoteRequest, + requestOptions?: NotesClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${core.url.encodePathParam(id)}/notes`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Note, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/notes"); + } + + /** + * You can fetch the details of a single note. + * + * @param {Intercom.preview.RetrieveNoteRequest} request + * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.notes.retrieveNote({ + * id: 1 + * }) + */ + public retrieveNote( + request: Intercom.preview.RetrieveNoteRequest, + requestOptions?: NotesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveNote(request, requestOptions)); + } + + private async __retrieveNote( + request: Intercom.preview.RetrieveNoteRequest, + requestOptions?: NotesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `notes/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Note, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/notes/{id}"); + } + + /** + * You can delete a single contact or company note. Notes of other kinds cannot be deleted through the API. + * + * @param {Intercom.preview.DeleteNoteRequest} request + * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.notes.deleteNote({ + * id: 1 + * }) + */ + public deleteNote( + request: Intercom.preview.DeleteNoteRequest, + requestOptions?: NotesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteNote(request, requestOptions)); + } + + private async __deleteNote( + request: Intercom.preview.DeleteNoteRequest, + requestOptions?: NotesClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `notes/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.DeletedNoteObject, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/notes/{id}"); + } +} diff --git a/src/api/resources/preview/resources/notes/client/index.ts b/src/api/resources/preview/resources/notes/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/notes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/preview/resources/notes/client/requests/CreateCompanyNoteRequest.ts b/src/api/resources/preview/resources/notes/client/requests/CreateCompanyNoteRequest.ts new file mode 100644 index 00000000..7015015f --- /dev/null +++ b/src/api/resources/preview/resources/notes/client/requests/CreateCompanyNoteRequest.ts @@ -0,0 +1,31 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + * body: "Hello", + * admin_id: "991267583" + * } + * + * @example + * { + * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + * body: "Hello", + * admin_id: "123" + * } + * + * @example + * { + * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + * body: "Hello" + * } + */ +export interface CreateCompanyNoteRequest { + /** The unique identifier for the company which is given by Intercom */ + company_id: string; + /** The text of the note. */ + body: string; + /** The unique identifier of the admin creating the note. If not provided, defaults to the admin associated with the access token. */ + admin_id?: string; +} diff --git a/src/api/resources/unstable/resources/notes/client/requests/CreateNoteRequest.ts b/src/api/resources/preview/resources/notes/client/requests/CreateNoteRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/notes/client/requests/CreateNoteRequest.ts rename to src/api/resources/preview/resources/notes/client/requests/CreateNoteRequest.ts diff --git a/src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts b/src/api/resources/preview/resources/notes/client/requests/DeleteNoteRequest.ts similarity index 61% rename from src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts rename to src/api/resources/preview/resources/notes/client/requests/DeleteNoteRequest.ts index 1a07b952..f90fd685 100644 --- a/src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts +++ b/src/api/resources/preview/resources/notes/client/requests/DeleteNoteRequest.ts @@ -6,7 +6,7 @@ * id: 1 * } */ -export interface DeleteConversationRequest { - /** id */ +export interface DeleteNoteRequest { + /** The unique identifier of a given note */ id: number; } diff --git a/src/api/resources/unstable/resources/notes/client/requests/ListCompanyNotesRequest.ts b/src/api/resources/preview/resources/notes/client/requests/ListCompanyNotesRequest.ts similarity index 72% rename from src/api/resources/unstable/resources/notes/client/requests/ListCompanyNotesRequest.ts rename to src/api/resources/preview/resources/notes/client/requests/ListCompanyNotesRequest.ts index 5e97337d..445d57bd 100644 --- a/src/api/resources/unstable/resources/notes/client/requests/ListCompanyNotesRequest.ts +++ b/src/api/resources/preview/resources/notes/client/requests/ListCompanyNotesRequest.ts @@ -3,10 +3,10 @@ /** * @example * { - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * } */ export interface ListCompanyNotesRequest { /** The unique identifier for the company which is given by Intercom */ - id: string; + company_id: string; } diff --git a/src/api/resources/unstable/resources/notes/client/requests/ListNotesRequest.ts b/src/api/resources/preview/resources/notes/client/requests/ListNotesRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/notes/client/requests/ListNotesRequest.ts rename to src/api/resources/preview/resources/notes/client/requests/ListNotesRequest.ts diff --git a/src/api/resources/unstable/resources/notes/client/requests/RetrieveNoteRequest.ts b/src/api/resources/preview/resources/notes/client/requests/RetrieveNoteRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/notes/client/requests/RetrieveNoteRequest.ts rename to src/api/resources/preview/resources/notes/client/requests/RetrieveNoteRequest.ts diff --git a/src/api/resources/unstable/resources/notes/client/requests/index.ts b/src/api/resources/preview/resources/notes/client/requests/index.ts similarity index 65% rename from src/api/resources/unstable/resources/notes/client/requests/index.ts rename to src/api/resources/preview/resources/notes/client/requests/index.ts index ed230370..62645767 100644 --- a/src/api/resources/unstable/resources/notes/client/requests/index.ts +++ b/src/api/resources/preview/resources/notes/client/requests/index.ts @@ -1,4 +1,6 @@ +export type { CreateCompanyNoteRequest } from "./CreateCompanyNoteRequest.js"; export type { CreateNoteRequest } from "./CreateNoteRequest.js"; +export type { DeleteNoteRequest } from "./DeleteNoteRequest.js"; export type { ListCompanyNotesRequest } from "./ListCompanyNotesRequest.js"; export type { ListNotesRequest } from "./ListNotesRequest.js"; export type { RetrieveNoteRequest } from "./RetrieveNoteRequest.js"; diff --git a/src/api/resources/preview/resources/notes/index.ts b/src/api/resources/preview/resources/notes/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/notes/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/notes/types/index.ts b/src/api/resources/preview/resources/notes/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/notes/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/notes/types/types.ts b/src/api/resources/preview/resources/notes/types/types.ts new file mode 100644 index 00000000..74eeab2d --- /dev/null +++ b/src/api/resources/preview/resources/notes/types/types.ts @@ -0,0 +1,75 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * Notes allow you to annotate and comment on your contacts and companies. A note is attached to either a contact or a company, never both. + */ +export interface Note { + /** String representing the object's type. Always has the value `note`. */ + type?: string; + /** The id of the note. */ + id?: string; + /** The time the note was created. */ + created_at?: number; + /** Represents the contact that the note was created about. */ + contact?: Note.Contact; + /** Represents the company that the note was created about. */ + company?: Note.Company; + /** Optional. Represents the Admin that created the note. */ + author?: Intercom.preview.Admin; + /** The body text of the note. */ + body?: string; +} + +export namespace Note { + /** + * Represents the contact that the note was created about. + */ + export interface Contact { + /** String representing the object's type. Always has the value `contact`. */ + type?: string; + /** The id of the contact. */ + id?: string; + } + + /** + * Represents the company that the note was created about. + */ + export interface Company { + /** String representing the object's type. Always has the value `company`. */ + type?: string; + /** The id of the company. */ + id?: string; + } +} + +/** + * Notes allow you to annotate and comment on companies. + */ +export interface CompanyNote { + /** String representing the object's type. Always has the value `note`. */ + type?: string; + /** The id of the note. */ + id?: string; + /** The time the note was created. */ + created_at?: number; + /** Represents the company that the note was created about. */ + company?: CompanyNote.Company; + /** Optional. Represents the Admin that created the note. */ + author?: Intercom.preview.Admin; + /** The body text of the note. */ + body?: string; +} + +export namespace CompanyNote { + /** + * Represents the company that the note was created about. + */ + export interface Company { + /** String representing the object's type. Always has the value `company`. */ + type?: string; + /** The id of the company. */ + id?: string; + } +} diff --git a/src/api/resources/preview/resources/officeHours/client/Client.ts b/src/api/resources/preview/resources/officeHours/client/Client.ts new file mode 100644 index 00000000..d28f47e7 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/Client.ts @@ -0,0 +1,866 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace OfficeHoursClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Manage office hours schedules and their exceptions. These endpoints require an + * OAuth token with the `read_write_office_hours` scope. + */ +export class OfficeHoursClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: OfficeHoursClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * You can fetch a list of all office hours schedules for the workspace. + * + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * + * @example + * await client.preview.officeHours.listOfficeHoursSchedules() + */ + public listOfficeHoursSchedules( + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listOfficeHoursSchedules(requestOptions)); + } + + private async __listOfficeHoursSchedules( + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "office_hours_schedules", + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.OfficeHoursScheduleList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/office_hours_schedules"); + } + + /** + * You can create a new office hours schedule for the workspace. + * + * @param {Intercom.preview.CreateOfficeHoursScheduleRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.officeHours.createOfficeHoursSchedule({ + * name: "Standard Support Hours", + * time_zone_name: "America/New_York", + * time_intervals: [{ + * start_minute: 540, + * end_minute: 1020 + * }] + * }) + */ + public createOfficeHoursSchedule( + request: Intercom.preview.CreateOfficeHoursScheduleRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createOfficeHoursSchedule(request, requestOptions)); + } + + private async __createOfficeHoursSchedule( + request: Intercom.preview.CreateOfficeHoursScheduleRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "office_hours_schedules", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.OfficeHoursSchedule, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/office_hours_schedules"); + } + + /** + * You can fetch the details of a single office hours schedule. + * + * @param {Intercom.preview.GetOfficeHoursScheduleRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.officeHours.getOfficeHoursSchedule({ + * id: "123" + * }) + */ + public getOfficeHoursSchedule( + request: Intercom.preview.GetOfficeHoursScheduleRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getOfficeHoursSchedule(request, requestOptions)); + } + + private async __getOfficeHoursSchedule( + request: Intercom.preview.GetOfficeHoursScheduleRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `office_hours_schedules/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.OfficeHoursSchedule, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/office_hours_schedules/{id}"); + } + + /** + * You can update an existing office hours schedule. + * + * @param {Intercom.preview.UpdateOfficeHoursScheduleRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.officeHours.updateOfficeHoursSchedule({ + * id: "123", + * name: "Extended Support Hours", + * time_intervals: [{ + * start_minute: 480, + * end_minute: 1080 + * }] + * }) + */ + public updateOfficeHoursSchedule( + request: Intercom.preview.UpdateOfficeHoursScheduleRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateOfficeHoursSchedule(request, requestOptions)); + } + + private async __updateOfficeHoursSchedule( + request: Intercom.preview.UpdateOfficeHoursScheduleRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `office_hours_schedules/${core.url.encodePathParam(id)}`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.OfficeHoursSchedule, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/office_hours_schedules/{id}"); + } + + /** + * You can delete a single office hours schedule. + * + * @param {Intercom.preview.DeleteOfficeHoursScheduleRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.officeHours.deleteOfficeHoursSchedule({ + * id: "123" + * }) + */ + public deleteOfficeHoursSchedule( + request: Intercom.preview.DeleteOfficeHoursScheduleRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteOfficeHoursSchedule(request, requestOptions)); + } + + private async __deleteOfficeHoursSchedule( + request: Intercom.preview.DeleteOfficeHoursScheduleRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const { id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `office_hours_schedules/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.DeleteOfficeHoursScheduleResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/office_hours_schedules/{id}", + ); + } + + /** + * You can fetch a list of all exceptions for an office hours schedule. + * + * @param {Intercom.preview.ListOfficeHoursExceptionsRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.officeHours.listOfficeHoursExceptions({ + * office_hours_schedule_id: "123" + * }) + */ + public listOfficeHoursExceptions( + request: Intercom.preview.ListOfficeHoursExceptionsRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listOfficeHoursExceptions(request, requestOptions)); + } + + private async __listOfficeHoursExceptions( + request: Intercom.preview.ListOfficeHoursExceptionsRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const { office_hours_schedule_id: officeHoursScheduleId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `office_hours_schedules/${core.url.encodePathParam(officeHoursScheduleId)}/office_hours_exceptions`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.OfficeHoursExceptionList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/office_hours_schedules/{office_hours_schedule_id}/office_hours_exceptions", + ); + } + + /** + * You can create an exception for an office hours schedule. Use `closed` to mark the day closed (omit `time_intervals`) or `custom_hours` to supply replacement intervals. + * + * @param {Intercom.preview.CreateOfficeHoursExceptionRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.officeHours.createOfficeHoursException({ + * office_hours_schedule_id: "123", + * exception_date: "2026-12-25", + * exception_type: "closed", + * name: "Christmas Day", + * recurring_annually: true + * }) + */ + public createOfficeHoursException( + request: Intercom.preview.CreateOfficeHoursExceptionRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createOfficeHoursException(request, requestOptions)); + } + + private async __createOfficeHoursException( + request: Intercom.preview.CreateOfficeHoursExceptionRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const { office_hours_schedule_id: officeHoursScheduleId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `office_hours_schedules/${core.url.encodePathParam(officeHoursScheduleId)}/office_hours_exceptions`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.OfficeHoursException, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/office_hours_schedules/{office_hours_schedule_id}/office_hours_exceptions", + ); + } + + /** + * You can fetch the details of a single office hours exception. + * + * @param {Intercom.preview.GetOfficeHoursExceptionRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.officeHours.getOfficeHoursException({ + * office_hours_schedule_id: "123", + * id: "456" + * }) + */ + public getOfficeHoursException( + request: Intercom.preview.GetOfficeHoursExceptionRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getOfficeHoursException(request, requestOptions)); + } + + private async __getOfficeHoursException( + request: Intercom.preview.GetOfficeHoursExceptionRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const { office_hours_schedule_id: officeHoursScheduleId, id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `office_hours_schedules/${core.url.encodePathParam(officeHoursScheduleId)}/office_hours_exceptions/${core.url.encodePathParam(id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.OfficeHoursException, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/office_hours_schedules/{office_hours_schedule_id}/office_hours_exceptions/{id}", + ); + } + + /** + * You can update an existing office hours exception. + * + * @param {Intercom.preview.UpdateOfficeHoursExceptionRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} + * + * @example + * await client.preview.officeHours.updateOfficeHoursException({ + * office_hours_schedule_id: "123", + * id: "456", + * exception_type: "custom_hours", + * name: "Christmas Day (reduced hours)", + * time_intervals: [{ + * start_minute: 540, + * end_minute: 780 + * }], + * recurring_annually: true + * }) + */ + public updateOfficeHoursException( + request: Intercom.preview.UpdateOfficeHoursExceptionRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateOfficeHoursException(request, requestOptions)); + } + + private async __updateOfficeHoursException( + request: Intercom.preview.UpdateOfficeHoursExceptionRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const { office_hours_schedule_id: officeHoursScheduleId, id, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `office_hours_schedules/${core.url.encodePathParam(officeHoursScheduleId)}/office_hours_exceptions/${core.url.encodePathParam(id)}`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.OfficeHoursException, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PUT", + "/office_hours_schedules/{office_hours_schedule_id}/office_hours_exceptions/{id}", + ); + } + + /** + * You can delete a single office hours exception. + * + * @param {Intercom.preview.DeleteOfficeHoursExceptionRequest} request + * @param {OfficeHoursClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.officeHours.deleteOfficeHoursException({ + * office_hours_schedule_id: "123", + * id: "456" + * }) + */ + public deleteOfficeHoursException( + request: Intercom.preview.DeleteOfficeHoursExceptionRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteOfficeHoursException(request, requestOptions)); + } + + private async __deleteOfficeHoursException( + request: Intercom.preview.DeleteOfficeHoursExceptionRequest, + requestOptions?: OfficeHoursClient.RequestOptions, + ): Promise> { + const { office_hours_schedule_id: officeHoursScheduleId, id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `office_hours_schedules/${core.url.encodePathParam(officeHoursScheduleId)}/office_hours_exceptions/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.preview.DeleteOfficeHoursExceptionResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/office_hours_schedules/{office_hours_schedule_id}/office_hours_exceptions/{id}", + ); + } +} diff --git a/src/api/resources/preview/resources/officeHours/client/index.ts b/src/api/resources/preview/resources/officeHours/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/preview/resources/officeHours/client/requests/CreateOfficeHoursExceptionRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/CreateOfficeHoursExceptionRequest.ts new file mode 100644 index 00000000..6a584f82 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/CreateOfficeHoursExceptionRequest.ts @@ -0,0 +1,37 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * office_hours_schedule_id: "123", + * exception_date: "2026-12-25", + * exception_type: "closed", + * name: "Christmas Day", + * recurring_annually: true + * } + */ +export interface CreateOfficeHoursExceptionRequest { + /** The unique identifier for the office hours schedule. */ + office_hours_schedule_id: string; + /** The date the exception applies to, in `YYYY-MM-DD` format. */ + exception_date: string; + /** The type of exception. */ + exception_type: CreateOfficeHoursExceptionRequest.ExceptionType; + /** An optional name for the exception. */ + name?: string; + /** The open intervals for the exception date. Required for `custom_hours`; omit for `closed`. */ + time_intervals?: Intercom.preview.OfficeHoursTimeInterval[]; + /** Whether the exception repeats every year on the same date. */ + recurring_annually?: boolean; +} + +export namespace CreateOfficeHoursExceptionRequest { + /** The type of exception. */ + export const ExceptionType = { + Closed: "closed", + CustomHours: "custom_hours", + } as const; + export type ExceptionType = (typeof ExceptionType)[keyof typeof ExceptionType]; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/CreateOfficeHoursScheduleRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/CreateOfficeHoursScheduleRequest.ts new file mode 100644 index 00000000..8d261e68 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/CreateOfficeHoursScheduleRequest.ts @@ -0,0 +1,23 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * name: "Standard Support Hours", + * time_zone_name: "America/New_York", + * time_intervals: [{ + * start_minute: 540, + * end_minute: 1020 + * }] + * } + */ +export interface CreateOfficeHoursScheduleRequest { + /** The name of the office hours schedule. */ + name: string; + /** The IANA time zone the schedule's hours are evaluated in. */ + time_zone_name: string; + /** The open intervals for the schedule. `start_minute` and `end_minute` must be on a 15-minute boundary. */ + time_intervals: Intercom.preview.OfficeHoursTimeInterval[]; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/DeleteOfficeHoursExceptionRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/DeleteOfficeHoursExceptionRequest.ts new file mode 100644 index 00000000..bacd3879 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/DeleteOfficeHoursExceptionRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * office_hours_schedule_id: "123", + * id: "456" + * } + */ +export interface DeleteOfficeHoursExceptionRequest { + /** The unique identifier for the office hours schedule. */ + office_hours_schedule_id: string; + /** The unique identifier for the office hours exception. */ + id: string; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/DeleteOfficeHoursScheduleRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/DeleteOfficeHoursScheduleRequest.ts new file mode 100644 index 00000000..b75cf685 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/DeleteOfficeHoursScheduleRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123" + * } + */ +export interface DeleteOfficeHoursScheduleRequest { + /** The unique identifier for the office hours schedule. */ + id: string; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/GetOfficeHoursExceptionRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/GetOfficeHoursExceptionRequest.ts new file mode 100644 index 00000000..c748f05f --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/GetOfficeHoursExceptionRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * office_hours_schedule_id: "123", + * id: "456" + * } + */ +export interface GetOfficeHoursExceptionRequest { + /** The unique identifier for the office hours schedule. */ + office_hours_schedule_id: string; + /** The unique identifier for the office hours exception. */ + id: string; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/GetOfficeHoursScheduleRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/GetOfficeHoursScheduleRequest.ts new file mode 100644 index 00000000..37aa3860 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/GetOfficeHoursScheduleRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "123" + * } + */ +export interface GetOfficeHoursScheduleRequest { + /** The unique identifier for the office hours schedule. */ + id: string; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/ListOfficeHoursExceptionsRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/ListOfficeHoursExceptionsRequest.ts new file mode 100644 index 00000000..8fa6eb36 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/ListOfficeHoursExceptionsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * office_hours_schedule_id: "123" + * } + */ +export interface ListOfficeHoursExceptionsRequest { + /** The unique identifier for the office hours schedule. */ + office_hours_schedule_id: string; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/UpdateOfficeHoursExceptionRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/UpdateOfficeHoursExceptionRequest.ts new file mode 100644 index 00000000..85181bdd --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/UpdateOfficeHoursExceptionRequest.ts @@ -0,0 +1,43 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * office_hours_schedule_id: "123", + * id: "456", + * exception_type: "custom_hours", + * name: "Christmas Day (reduced hours)", + * time_intervals: [{ + * start_minute: 540, + * end_minute: 780 + * }], + * recurring_annually: true + * } + */ +export interface UpdateOfficeHoursExceptionRequest { + /** The unique identifier for the office hours schedule. */ + office_hours_schedule_id: string; + /** The unique identifier for the office hours exception. */ + id: string; + /** The date the exception applies to, in `YYYY-MM-DD` format. */ + exception_date?: string; + /** The type of exception. */ + exception_type?: UpdateOfficeHoursExceptionRequest.ExceptionType; + /** An optional name for the exception. */ + name?: string; + /** The open intervals for the exception date. Required for `custom_hours`; omit for `closed`. */ + time_intervals?: Intercom.preview.OfficeHoursTimeInterval[]; + /** Whether the exception repeats every year on the same date. */ + recurring_annually?: boolean; +} + +export namespace UpdateOfficeHoursExceptionRequest { + /** The type of exception. */ + export const ExceptionType = { + Closed: "closed", + CustomHours: "custom_hours", + } as const; + export type ExceptionType = (typeof ExceptionType)[keyof typeof ExceptionType]; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/UpdateOfficeHoursScheduleRequest.ts b/src/api/resources/preview/resources/officeHours/client/requests/UpdateOfficeHoursScheduleRequest.ts new file mode 100644 index 00000000..fe7204ae --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/UpdateOfficeHoursScheduleRequest.ts @@ -0,0 +1,25 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * id: "123", + * name: "Extended Support Hours", + * time_intervals: [{ + * start_minute: 480, + * end_minute: 1080 + * }] + * } + */ +export interface UpdateOfficeHoursScheduleRequest { + /** The unique identifier for the office hours schedule. */ + id: string; + /** The name of the office hours schedule. */ + name?: string; + /** The IANA time zone the schedule's hours are evaluated in. */ + time_zone_name?: string; + /** The open intervals for the schedule. `start_minute` and `end_minute` must be on a 15-minute boundary. */ + time_intervals?: Intercom.preview.OfficeHoursTimeInterval[]; +} diff --git a/src/api/resources/preview/resources/officeHours/client/requests/index.ts b/src/api/resources/preview/resources/officeHours/client/requests/index.ts new file mode 100644 index 00000000..facfa706 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/client/requests/index.ts @@ -0,0 +1,9 @@ +export type { CreateOfficeHoursExceptionRequest } from "./CreateOfficeHoursExceptionRequest.js"; +export type { CreateOfficeHoursScheduleRequest } from "./CreateOfficeHoursScheduleRequest.js"; +export type { DeleteOfficeHoursExceptionRequest } from "./DeleteOfficeHoursExceptionRequest.js"; +export type { DeleteOfficeHoursScheduleRequest } from "./DeleteOfficeHoursScheduleRequest.js"; +export type { GetOfficeHoursExceptionRequest } from "./GetOfficeHoursExceptionRequest.js"; +export type { GetOfficeHoursScheduleRequest } from "./GetOfficeHoursScheduleRequest.js"; +export type { ListOfficeHoursExceptionsRequest } from "./ListOfficeHoursExceptionsRequest.js"; +export type { UpdateOfficeHoursExceptionRequest } from "./UpdateOfficeHoursExceptionRequest.js"; +export type { UpdateOfficeHoursScheduleRequest } from "./UpdateOfficeHoursScheduleRequest.js"; diff --git a/src/api/resources/preview/resources/officeHours/index.ts b/src/api/resources/preview/resources/officeHours/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/officeHours/types/index.ts b/src/api/resources/preview/resources/officeHours/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/officeHours/types/types.ts b/src/api/resources/preview/resources/officeHours/types/types.ts new file mode 100644 index 00000000..f3ace04a --- /dev/null +++ b/src/api/resources/preview/resources/officeHours/types/types.ts @@ -0,0 +1,84 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +export interface DeleteOfficeHoursScheduleResponse { + id?: string; + object?: string; + deleted?: boolean; +} + +export interface DeleteOfficeHoursExceptionResponse { + id?: string; + object?: string; + deleted?: boolean; +} + +/** + * A single open interval. For schedules, `start_minute` and `end_minute` are minute offsets from the start of the week (Monday 00:00 = 0), in the range 0 to 10080. For exceptions, they are minute offsets from midnight on `exception_date`, in the range 0 to 1440. + */ +export interface OfficeHoursTimeInterval { + /** Minute the interval starts. For schedules, offset from the start of the week (Monday 00:00 = 0); for exceptions, offset from midnight on `exception_date`. */ + start_minute?: number; + /** Minute the interval ends. For schedules, offset from the start of the week (Monday 00:00 = 0); for exceptions, offset from midnight on `exception_date`. */ + end_minute?: number; + /** Derived day of the week the interval falls on (0 = Monday … 6 = Sunday). For exceptions, this is derived from `exception_date`. */ + day_of_week?: number; +} + +/** + * An office hours schedule defines the recurring weekly hours during which the workspace is open. + */ +export interface OfficeHoursSchedule { + /** The type of the object - always `office_hours_schedule`. */ + type?: string; + /** The unique identifier for the office hours schedule. */ + id?: string; + /** The name of the office hours schedule. */ + name?: string; + /** The IANA time zone the schedule's hours are evaluated in. */ + time_zone_name?: string; + /** The open intervals that make up the weekly schedule. */ + time_intervals?: Intercom.preview.OfficeHoursTimeInterval[]; + /** Whether the schedule is open 24/7. */ + twenty_four_seven?: boolean; + /** The time the schedule was created as a Unix timestamp. */ + created_at?: number; + /** The time the schedule was last updated as a Unix timestamp. */ + updated_at?: number; +} + +/** + * An exception overrides a schedule's regular hours on a specific date, such as a public holiday. + */ +export interface OfficeHoursException { + /** The type of the object - always `office_hours_exception`. */ + type?: string; + /** The unique identifier for the office hours exception. */ + id?: string; + /** The unique identifier for the schedule this exception belongs to. */ + office_hours_schedule_id?: string; + /** The date the exception applies to, in `YYYY-MM-DD` format. */ + exception_date?: string; + /** `closed` means the workspace is closed all day; `custom_hours` replaces the regular hours with `time_intervals`. */ + exception_type?: OfficeHoursException.ExceptionType; + /** An optional name for the exception. */ + name?: string; + /** The open intervals for the exception date. `null` when `exception_type` is `closed`. */ + time_intervals?: Intercom.preview.OfficeHoursTimeInterval[]; + /** Whether the exception repeats every year on the same date. */ + recurring_annually?: boolean; + /** The time the exception was created as a Unix timestamp. */ + created_at?: number; + /** The time the exception was last updated as a Unix timestamp. */ + updated_at?: number; +} + +export namespace OfficeHoursException { + /** `closed` means the workspace is closed all day; `custom_hours` replaces the regular hours with `time_intervals`. */ + export const ExceptionType = { + Closed: "closed", + CustomHours: "custom_hours", + } as const; + export type ExceptionType = (typeof ExceptionType)[keyof typeof ExceptionType]; +} diff --git a/src/api/resources/preview/resources/procedures/client/Client.ts b/src/api/resources/preview/resources/procedures/client/Client.ts new file mode 100644 index 00000000..c90a97ff --- /dev/null +++ b/src/api/resources/preview/resources/procedures/client/Client.ts @@ -0,0 +1,161 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Intercom from "../../../../../index.js"; + +export declare namespace ProceduresClient { + export interface Options extends BaseClientOptions {} + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Submit human-collected input to Fin Procedures via the HITL (Human in the Loop) API. + * + *   + * + * When a Fin Procedure reaches a HITL step with the API channel enabled, Intercom sends a `procedure.hitl_notification.created` webhook to your system. Your system collects the required input and responds via the callback endpoint documented here. + * + *   + * + * {% admonition type="warning" %} + * This API requires the Procedures HITL API feature to be enabled for your workspace and an OAuth token with the `write_conversations` scope. + * {% /admonition %} + */ +export class ProceduresClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ProceduresClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Submit human-collected input to a Fin Procedure that is paused at a Human in the Loop (HITL) step. + * + * When a procedure reaches a HITL step with the API channel enabled, Intercom sends a `procedure.hitl_notification.created` webhook. Use the `callback_url` from that webhook payload to call this endpoint with the collected attribute values. + * + * The `step_id` must match the one from the webhook payload, and `attribute_values` must include a value for every attribute listed in `attributes_to_collect`. + * + * {% admonition type="info" name="Authentication" %} + * This endpoint requires an OAuth token with the `write_conversations` scope. The admin associated with the token must have access to the conversation. + * {% /admonition %} + * + * {% admonition type="warning" name="Feature access" %} + * This endpoint requires the Procedures HITL API feature to be enabled for your workspace. + * {% /admonition %} + * + * @param {Intercom.preview.CollectAgentInputRequest} request + * @param {ProceduresClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.ConflictError} + * + * @example + * await client.preview.procedures.collectProcedureAgentInput({ + * conversation_id: "215473853299345", + * step_id: "d5b81f72-adb9-4317-b973-75b3c3624c09", + * attribute_values: [{ + * identifier: "workflow_local_variables.72c5a6b3-3cce-41d8-8e30-14da40791958", + * value: true + * }, { + * identifier: "workflow_local_variables.5adb55fb-f549-44a0-8ee9-7e652ad77c25", + * value: "85f00ba7-558c-4b02-a397-6f5c3659941c" + * }] + * }) + * + * @example + * await client.preview.procedures.collectProcedureAgentInput({ + * conversation_id: "215473853299345", + * step_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + * attribute_values: [{ + * identifier: "workflow_local_variables.11111111-2222-3333-4444-555555555555", + * value: "Approved by manager" + * }] + * }) + */ + public collectProcedureAgentInput( + request: Intercom.preview.CollectAgentInputRequest, + requestOptions?: ProceduresClient.RequestOptions, + ): core.HttpResponsePromise> { + return core.HttpResponsePromise.fromPromise(this.__collectProcedureAgentInput(request, requestOptions)); + } + + private async __collectProcedureAgentInput( + request: Intercom.preview.CollectAgentInputRequest, + requestOptions?: ProceduresClient.RequestOptions, + ): Promise>> { + const { conversation_id: conversationId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `procedures/${core.url.encodePathParam(conversationId)}/collect_agent_input`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Record, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Intercom.preview.ConflictError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/procedures/{conversation_id}/collect_agent_input", + ); + } +} diff --git a/src/api/resources/preview/resources/procedures/client/index.ts b/src/api/resources/preview/resources/procedures/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/procedures/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/preview/resources/procedures/client/requests/CollectAgentInputRequest.ts b/src/api/resources/preview/resources/procedures/client/requests/CollectAgentInputRequest.ts new file mode 100644 index 00000000..10d85025 --- /dev/null +++ b/src/api/resources/preview/resources/procedures/client/requests/CollectAgentInputRequest.ts @@ -0,0 +1,46 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * conversation_id: "215473853299345", + * step_id: "d5b81f72-adb9-4317-b973-75b3c3624c09", + * attribute_values: [{ + * identifier: "workflow_local_variables.72c5a6b3-3cce-41d8-8e30-14da40791958", + * value: true + * }, { + * identifier: "workflow_local_variables.5adb55fb-f549-44a0-8ee9-7e652ad77c25", + * value: "85f00ba7-558c-4b02-a397-6f5c3659941c" + * }] + * } + * + * @example + * { + * conversation_id: "215473853299345", + * step_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + * attribute_values: [{ + * identifier: "workflow_local_variables.11111111-2222-3333-4444-555555555555", + * value: "Approved by manager" + * }] + * } + */ +export interface CollectAgentInputRequest { + /** The ID of the conversation where the HITL step was triggered. */ + conversation_id: string; + /** The step_id from the webhook payload, identifying which HITL step this response is for. */ + step_id: string; + /** Array of attribute values matching the attributes_to_collect from the webhook payload. Must include a value for every attribute listed. */ + attribute_values: CollectAgentInputRequest.AttributeValues.Item[]; +} + +export namespace CollectAgentInputRequest { + export type AttributeValues = AttributeValues.Item[]; + + export namespace AttributeValues { + export interface Item { + /** Must exactly match an identifier from the webhook's attributes_to_collect array. */ + identifier: string; + value?: unknown; + } + } +} diff --git a/src/api/resources/preview/resources/procedures/client/requests/index.ts b/src/api/resources/preview/resources/procedures/client/requests/index.ts new file mode 100644 index 00000000..9558ce39 --- /dev/null +++ b/src/api/resources/preview/resources/procedures/client/requests/index.ts @@ -0,0 +1 @@ +export type { CollectAgentInputRequest } from "./CollectAgentInputRequest.js"; diff --git a/src/api/resources/unstable/resources/ticketStates/index.ts b/src/api/resources/preview/resources/procedures/index.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketStates/index.ts rename to src/api/resources/preview/resources/procedures/index.ts diff --git a/src/api/resources/unstable/resources/export/client/Client.ts b/src/api/resources/preview/resources/reportingDataExport/client/Client.ts similarity index 69% rename from src/api/resources/unstable/resources/export/client/Client.ts rename to src/api/resources/preview/resources/reportingDataExport/client/Client.ts index af0ecc87..eaa74b61 100644 --- a/src/api/resources/unstable/resources/export/client/Client.ts +++ b/src/api/resources/preview/resources/reportingDataExport/client/Client.ts @@ -9,29 +9,31 @@ import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStat import * as errors from "../../../../../../errors/index.js"; import * as Intercom from "../../../../../index.js"; -export declare namespace ExportClient { +export declare namespace ReportingDataExportClient { export interface Options extends BaseClientOptions {} export interface RequestOptions extends BaseRequestOptions {} } -export class ExportClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class ReportingDataExportClient { + protected readonly _options: NormalizedClientOptionsWithAuth; - constructor(options: ExportClient.Options = {}) { + constructor(options: ReportingDataExportClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } /** - * @param {Intercom.unstable.PostExportReportingDataEnqueueRequest} request - * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration. + * For the **conversation** dataset, from the Preview version this export returns all conversations, including those that never received a user reply. Earlier versions return only conversations that received at least one user reply. Other datasets are unaffected. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.TooManyRequestsError} + * @param {Intercom.preview.PostExportReportingDataEnqueueRequest} request + * @param {ReportingDataExportClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.TooManyRequestsError} * * @example - * await client.unstable.export.enqueueANewReportingDataExportJob({ + * await client.preview.reportingDataExport.enqueueANewReportingDataExportJob({ * dataset_id: "conversation", * attribute_ids: ["conversation_id", "conversation_started_at"], * start_time: 1717490000, @@ -39,16 +41,16 @@ export class ExportClient { * }) */ public enqueueANewReportingDataExportJob( - request: Intercom.unstable.PostExportReportingDataEnqueueRequest, - requestOptions?: ExportClient.RequestOptions, - ): core.HttpResponsePromise { + request: Intercom.preview.PostExportReportingDataEnqueueRequest, + requestOptions?: ReportingDataExportClient.RequestOptions, + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__enqueueANewReportingDataExportJob(request, requestOptions)); } private async __enqueueANewReportingDataExportJob( - request: Intercom.unstable.PostExportReportingDataEnqueueRequest, - requestOptions?: ExportClient.RequestOptions, - ): Promise> { + request: Intercom.preview.PostExportReportingDataEnqueueRequest, + requestOptions?: ReportingDataExportClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -77,7 +79,7 @@ export class ExportClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.PostExportReportingDataEnqueueResponse, + data: _response.body as Intercom.preview.PostExportReportingDataEnqueueResponse, rawResponse: _response.rawResponse, }; } @@ -85,15 +87,15 @@ export class ExportClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 429: - throw new Intercom.unstable.TooManyRequestsError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.TooManyRequestsError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -114,20 +116,20 @@ export class ExportClient { } /** - * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {ReportingDataExportClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.unstable.export.listAvailableDatasetsAndAttributes() + * await client.preview.reportingDataExport.listAvailableDatasetsAndAttributes() */ public listAvailableDatasetsAndAttributes( - requestOptions?: ExportClient.RequestOptions, - ): core.HttpResponsePromise { + requestOptions?: ReportingDataExportClient.RequestOptions, + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listAvailableDatasetsAndAttributes(requestOptions)); } private async __listAvailableDatasetsAndAttributes( - requestOptions?: ExportClient.RequestOptions, - ): Promise> { + requestOptions?: ReportingDataExportClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -153,7 +155,7 @@ export class ExportClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.GetExportReportingDataGetDatasetsResponse, + data: _response.body as Intercom.preview.GetExportReportingDataGetDatasetsResponse, rawResponse: _response.rawResponse, }; } diff --git a/src/api/resources/preview/resources/reportingDataExport/client/index.ts b/src/api/resources/preview/resources/reportingDataExport/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/reportingDataExport/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts b/src/api/resources/preview/resources/reportingDataExport/client/requests/PostExportReportingDataEnqueueRequest.ts similarity index 67% rename from src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts rename to src/api/resources/preview/resources/reportingDataExport/client/requests/PostExportReportingDataEnqueueRequest.ts index 57767a44..2b805586 100644 --- a/src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts +++ b/src/api/resources/preview/resources/reportingDataExport/client/requests/PostExportReportingDataEnqueueRequest.ts @@ -11,6 +11,7 @@ */ export interface PostExportReportingDataEnqueueRequest { dataset_id: string; + /** List of attribute identifiers to include in the export. Requires qualified_id format (e.g., "people.Brand", "standard.conversation_id"). Use the qualified_id returned from the get_datasets response. */ attribute_ids: string[]; start_time: number; end_time: number; diff --git a/src/api/resources/export/client/requests/index.ts b/src/api/resources/preview/resources/reportingDataExport/client/requests/index.ts similarity index 100% rename from src/api/resources/export/client/requests/index.ts rename to src/api/resources/preview/resources/reportingDataExport/client/requests/index.ts diff --git a/src/api/resources/preview/resources/reportingDataExport/index.ts b/src/api/resources/preview/resources/reportingDataExport/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/reportingDataExport/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/reportingDataExport/types/index.ts b/src/api/resources/preview/resources/reportingDataExport/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/reportingDataExport/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts b/src/api/resources/preview/resources/reportingDataExport/types/types.ts similarity index 57% rename from src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts rename to src/api/resources/preview/resources/reportingDataExport/types/types.ts index 725ac29a..2a49d534 100644 --- a/src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts +++ b/src/api/resources/preview/resources/reportingDataExport/types/types.ts @@ -1,5 +1,12 @@ // This file was auto-generated by Fern from our API Definition. +export interface PostExportReportingDataEnqueueResponse { + job_identifier?: string; + status?: string; + download_url?: string; + download_expires_at?: string; +} + export interface GetExportReportingDataGetDatasetsResponse { type?: string; data?: GetExportReportingDataGetDatasetsResponse.Data.Item[]; @@ -22,7 +29,10 @@ export namespace GetExportReportingDataGetDatasetsResponse { export namespace Attributes { export interface Item { + /** The simple attribute identifier. Note that this may be ambiguous if the same name exists across different attribute types. Use qualified_id when calling the enqueue endpoint. */ id?: string; + /** A namespaced identifier that uniquely identifies the attribute across all types. Format is "prefix.name" (e.g., "people.Brand", "conversation.Brand"). Required when calling the enqueue endpoint. */ + qualified_id?: string; name?: string; } } diff --git a/src/api/resources/unstable/resources/teams/client/Client.ts b/src/api/resources/preview/resources/roles/client/Client.ts similarity index 64% rename from src/api/resources/unstable/resources/teams/client/Client.ts rename to src/api/resources/preview/resources/roles/client/Client.ts index c83adaf9..0af4ee4c 100644 --- a/src/api/resources/unstable/resources/teams/client/Client.ts +++ b/src/api/resources/preview/resources/roles/client/Client.ts @@ -9,41 +9,44 @@ import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStat import * as errors from "../../../../../../errors/index.js"; import * as Intercom from "../../../../../index.js"; -export declare namespace TeamsClient { +export declare namespace RolesClient { export interface Options extends BaseClientOptions {} export interface RequestOptions extends BaseRequestOptions {} } /** - * Everything about your Teams + * Everything about your Roles */ -export class TeamsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class RolesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; - constructor(options: TeamsClient.Options = {}) { + constructor(options: RolesClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } /** - * This will return a list of team objects for the App. + * You can fetch a list of all roles in the workspace. * - * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. + * Roles define what a teammate can do in a workspace. The teammates endpoint + * returns the role a teammate holds, but only the roles that are currently + * assigned, and only their id and name. This endpoint lists every role in the + * workspace, each with its description. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @param {RolesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.teams.listTeams() + * await client.preview.roles.listRoles() */ - public listTeams( - requestOptions?: TeamsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listTeams(requestOptions)); + public listRoles(requestOptions?: RolesClient.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listRoles(requestOptions)); } - private async __listTeams( - requestOptions?: TeamsClient.RequestOptions, - ): Promise> { + private async __listRoles( + requestOptions?: RolesClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -56,7 +59,7 @@ export class TeamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "teams", + "roles", ), method: "GET", headers: _headers, @@ -68,14 +71,14 @@ export class TeamsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.TeamList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.RoleList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -87,34 +90,35 @@ export class TeamsClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/roles"); } /** - * You can fetch the details of a single team, containing an array of admins that belong to this team. + * You can fetch the details of a single role by its id, including its + * description, which the teammates endpoint does not return. * - * @param {Intercom.unstable.RetrieveTeamRequest} request - * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.RetrieveRoleRequest} request + * @param {RolesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.teams.retrieveTeam({ - * id: "123" + * await client.preview.roles.retrieveRole({ + * id: "991267902" * }) */ - public retrieveTeam( - request: Intercom.unstable.RetrieveTeamRequest, - requestOptions?: TeamsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveTeam(request, requestOptions)); + public retrieveRole( + request: Intercom.preview.RetrieveRoleRequest, + requestOptions?: RolesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveRole(request, requestOptions)); } - private async __retrieveTeam( - request: Intercom.unstable.RetrieveTeamRequest, - requestOptions?: TeamsClient.RequestOptions, - ): Promise> { + private async __retrieveRole( + request: Intercom.preview.RetrieveRoleRequest, + requestOptions?: RolesClient.RequestOptions, + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -128,7 +132,7 @@ export class TeamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `teams/${core.url.encodePathParam(id)}`, + `roles/${core.url.encodePathParam(id)}`, ), method: "GET", headers: _headers, @@ -140,18 +144,18 @@ export class TeamsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Team, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Role, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -161,6 +165,6 @@ export class TeamsClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams/{id}"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/roles/{id}"); } } diff --git a/src/api/resources/preview/resources/roles/client/index.ts b/src/api/resources/preview/resources/roles/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/roles/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/preview/resources/roles/client/requests/RetrieveRoleRequest.ts b/src/api/resources/preview/resources/roles/client/requests/RetrieveRoleRequest.ts new file mode 100644 index 00000000..9f7c6435 --- /dev/null +++ b/src/api/resources/preview/resources/roles/client/requests/RetrieveRoleRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "991267902" + * } + */ +export interface RetrieveRoleRequest { + /** The unique identifier of a given role. */ + id: string; +} diff --git a/src/api/resources/preview/resources/roles/client/requests/index.ts b/src/api/resources/preview/resources/roles/client/requests/index.ts new file mode 100644 index 00000000..406368c1 --- /dev/null +++ b/src/api/resources/preview/resources/roles/client/requests/index.ts @@ -0,0 +1 @@ +export type { RetrieveRoleRequest } from "./RetrieveRoleRequest.js"; diff --git a/src/api/resources/preview/resources/roles/index.ts b/src/api/resources/preview/resources/roles/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/roles/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/roles/types/index.ts b/src/api/resources/preview/resources/roles/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/roles/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/roles/types/types.ts b/src/api/resources/preview/resources/roles/types/types.ts new file mode 100644 index 00000000..af64b135 --- /dev/null +++ b/src/api/resources/preview/resources/roles/types/types.ts @@ -0,0 +1,27 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +/** + * A role defines what a teammate can do in a workspace. The teammates endpoint returns the id and name of the role a teammate holds; this schema adds the role's description. + */ +export interface Role { + /** Value is always "role" */ + type?: string; + /** The id of the role */ + id?: string; + /** The name of the role */ + name?: string; + /** The description of the role */ + description?: string; +} + +/** + * A list of role objects in the workspace. + */ +export interface RoleList { + /** The type of the object */ + type?: "list"; + /** A list of role objects */ + data?: Intercom.preview.Role[]; +} diff --git a/src/api/resources/preview/resources/salesAgent/index.ts b/src/api/resources/preview/resources/salesAgent/index.ts new file mode 100644 index 00000000..2f88e301 --- /dev/null +++ b/src/api/resources/preview/resources/salesAgent/index.ts @@ -0,0 +1 @@ +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/salesAgent/types/index.ts b/src/api/resources/preview/resources/salesAgent/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/salesAgent/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/salesAgent/types/types.ts b/src/api/resources/preview/resources/salesAgent/types/types.ts new file mode 100644 index 00000000..80a5ee10 --- /dev/null +++ b/src/api/resources/preview/resources/salesAgent/types/types.ts @@ -0,0 +1,25 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Data related to Sales Agent involvement in the conversation. + */ +export interface SalesAgent { + /** The fixed outcome of the sales agent interaction, used for billing and tracking. */ + outcome?: SalesAgent.Outcome; + /** The identifier of the user-defined routing outcome selected by the sales agent. */ + routing_outcome?: string; + /** A flat key-value map of memory fields collected by the sales agent during the conversation. */ + collected_data?: Record; +} + +export namespace SalesAgent { + /** The fixed outcome of the sales agent interaction, used for billing and tracking. */ + export const Outcome = { + Qualified: "qualified", + Disqualified: "disqualified", + ProductDiscovery: "product_discovery", + EscalatedToSupport: "escalated_to_support", + Spam: "spam", + } as const; + export type Outcome = (typeof Outcome)[keyof typeof Outcome]; +} diff --git a/src/api/resources/unstable/resources/segments/client/Client.ts b/src/api/resources/preview/resources/segments/client/Client.ts similarity index 80% rename from src/api/resources/unstable/resources/segments/client/Client.ts rename to src/api/resources/preview/resources/segments/client/Client.ts index 64d7c4fb..e1d67a1a 100644 --- a/src/api/resources/unstable/resources/segments/client/Client.ts +++ b/src/api/resources/preview/resources/segments/client/Client.ts @@ -28,27 +28,27 @@ export class SegmentsClient { /** * You can fetch a list of all segments. * - * @param {Intercom.unstable.ListSegmentsRequest} request + * @param {Intercom.preview.ListSegmentsRequest} request * @param {SegmentsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.segments.listSegments({ + * await client.preview.segments.listSegments({ * include_count: true * }) */ public listSegments( - request: Intercom.unstable.ListSegmentsRequest = {}, + request: Intercom.preview.ListSegmentsRequest = {}, requestOptions?: SegmentsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listSegments(request, requestOptions)); } private async __listSegments( - request: Intercom.unstable.ListSegmentsRequest = {}, + request: Intercom.preview.ListSegmentsRequest = {}, requestOptions?: SegmentsClient.RequestOptions, - ): Promise> { + ): Promise> { const { include_count: includeCount } = request; const _queryParams: Record = {}; if (includeCount != null) { @@ -79,14 +79,14 @@ export class SegmentsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.SegmentList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.SegmentList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -104,28 +104,28 @@ export class SegmentsClient { /** * You can fetch the details of a single segment. * - * @param {Intercom.unstable.RetrieveSegmentRequest} request + * @param {Intercom.preview.RetrieveSegmentRequest} request * @param {SegmentsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.segments.retrieveSegment({ + * await client.preview.segments.retrieveSegment({ * id: "123" * }) */ public retrieveSegment( - request: Intercom.unstable.RetrieveSegmentRequest, + request: Intercom.preview.RetrieveSegmentRequest, requestOptions?: SegmentsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__retrieveSegment(request, requestOptions)); } private async __retrieveSegment( - request: Intercom.unstable.RetrieveSegmentRequest, + request: Intercom.preview.RetrieveSegmentRequest, requestOptions?: SegmentsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -151,18 +151,18 @@ export class SegmentsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Segment, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Segment, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/preview/resources/segments/client/index.ts b/src/api/resources/preview/resources/segments/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/segments/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/segments/client/requests/ListSegmentsRequest.ts b/src/api/resources/preview/resources/segments/client/requests/ListSegmentsRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/segments/client/requests/ListSegmentsRequest.ts rename to src/api/resources/preview/resources/segments/client/requests/ListSegmentsRequest.ts diff --git a/src/api/resources/unstable/resources/segments/client/requests/RetrieveSegmentRequest.ts b/src/api/resources/preview/resources/segments/client/requests/RetrieveSegmentRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/segments/client/requests/RetrieveSegmentRequest.ts rename to src/api/resources/preview/resources/segments/client/requests/RetrieveSegmentRequest.ts diff --git a/src/api/resources/unstable/resources/segments/client/requests/index.ts b/src/api/resources/preview/resources/segments/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/segments/client/requests/index.ts rename to src/api/resources/preview/resources/segments/client/requests/index.ts diff --git a/src/api/resources/preview/resources/segments/index.ts b/src/api/resources/preview/resources/segments/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/segments/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/segments/types/index.ts b/src/api/resources/preview/resources/segments/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/segments/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/segments/types/Segment.ts b/src/api/resources/preview/resources/segments/types/types.ts similarity index 100% rename from src/api/resources/segments/types/Segment.ts rename to src/api/resources/preview/resources/segments/types/types.ts diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts b/src/api/resources/preview/resources/subscriptionTypes/client/Client.ts similarity index 80% rename from src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts rename to src/api/resources/preview/resources/subscriptionTypes/client/Client.ts index b43baf9e..31fabeda 100644 --- a/src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts +++ b/src/api/resources/preview/resources/subscriptionTypes/client/Client.ts @@ -34,37 +34,37 @@ export class SubscriptionTypesClient { * * This will return a subscription type model for the subscription type that was added to the contact. * - * @param {Intercom.unstable.AttachSubscriptionTypeToContactRequest} request + * @param {Intercom.preview.AttachSubscriptionTypeToContactRequest} request * @param {SubscriptionTypesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + * await client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ * contact_id: "63a07ddf05a32042dffac965", * id: "37846", * consent_type: "opt_in" * }) * * @example - * await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + * await client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ * contact_id: "63a07ddf05a32042dffac965", * id: "invalid_id", * consent_type: "opt_in" * }) */ public attachSubscriptionTypeToContact( - request: Intercom.unstable.AttachSubscriptionTypeToContactRequest, + request: Intercom.preview.AttachSubscriptionTypeToContactRequest, requestOptions?: SubscriptionTypesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__attachSubscriptionTypeToContact(request, requestOptions)); } private async __attachSubscriptionTypeToContact( - request: Intercom.unstable.AttachSubscriptionTypeToContactRequest, + request: Intercom.preview.AttachSubscriptionTypeToContactRequest, requestOptions?: SubscriptionTypesClient.RequestOptions, - ): Promise> { + ): Promise> { const { contact_id: contactId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -93,18 +93,18 @@ export class SubscriptionTypesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.SubscriptionType, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.SubscriptionType, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -125,29 +125,29 @@ export class SubscriptionTypesClient { /** * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. * - * @param {Intercom.unstable.DetachSubscriptionTypeToContactRequest} request + * @param {Intercom.preview.DetachSubscriptionTypeToContactRequest} request * @param {SubscriptionTypesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ + * await client.preview.subscriptionTypes.detachSubscriptionTypeToContact({ * contact_id: "63a07ddf05a32042dffac965", * id: "37846" * }) */ public detachSubscriptionTypeToContact( - request: Intercom.unstable.DetachSubscriptionTypeToContactRequest, + request: Intercom.preview.DetachSubscriptionTypeToContactRequest, requestOptions?: SubscriptionTypesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__detachSubscriptionTypeToContact(request, requestOptions)); } private async __detachSubscriptionTypeToContact( - request: Intercom.unstable.DetachSubscriptionTypeToContactRequest, + request: Intercom.preview.DetachSubscriptionTypeToContactRequest, requestOptions?: SubscriptionTypesClient.RequestOptions, - ): Promise> { + ): Promise> { const { contact_id: contactId, id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -173,18 +173,18 @@ export class SubscriptionTypesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.SubscriptionType, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.SubscriptionType, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -207,20 +207,20 @@ export class SubscriptionTypesClient { * * @param {SubscriptionTypesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.subscriptionTypes.listSubscriptionTypes() + * await client.preview.subscriptionTypes.listSubscriptionTypes() */ public listSubscriptionTypes( requestOptions?: SubscriptionTypesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listSubscriptionTypes(requestOptions)); } private async __listSubscriptionTypes( requestOptions?: SubscriptionTypesClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -246,7 +246,7 @@ export class SubscriptionTypesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.SubscriptionTypeList, + data: _response.body as Intercom.preview.SubscriptionTypeList, rawResponse: _response.rawResponse, }; } @@ -254,8 +254,8 @@ export class SubscriptionTypesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/preview/resources/subscriptionTypes/client/index.ts b/src/api/resources/preview/resources/subscriptionTypes/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/subscriptionTypes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts b/src/api/resources/preview/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts rename to src/api/resources/preview/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts b/src/api/resources/preview/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts rename to src/api/resources/preview/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/index.ts b/src/api/resources/preview/resources/subscriptionTypes/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/subscriptionTypes/client/requests/index.ts rename to src/api/resources/preview/resources/subscriptionTypes/client/requests/index.ts diff --git a/src/api/resources/preview/resources/subscriptionTypes/index.ts b/src/api/resources/preview/resources/subscriptionTypes/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/subscriptionTypes/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/subscriptionTypes/types/index.ts b/src/api/resources/preview/resources/subscriptionTypes/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/subscriptionTypes/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts b/src/api/resources/preview/resources/subscriptionTypes/types/types.ts similarity index 93% rename from src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts rename to src/api/resources/preview/resources/subscriptionTypes/types/types.ts index 3867aa94..0d2705ec 100644 --- a/src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts +++ b/src/api/resources/preview/resources/subscriptionTypes/types/types.ts @@ -12,9 +12,9 @@ export interface SubscriptionType { id?: string; /** The state of the subscription type. */ state?: SubscriptionType.State; - default_translation?: Intercom.unstable.Translation; + default_translation?: Intercom.preview.Translation; /** An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. */ - translations?: Intercom.unstable.Translation[]; + translations?: Intercom.preview.Translation[]; /** Describes the type of consent. */ consent_type?: SubscriptionType.ConsentType; /** The message types that this subscription supports - can contain `email` or `sms_message`. */ diff --git a/src/api/resources/unstable/resources/switch/client/Client.ts b/src/api/resources/preview/resources/switch/client/Client.ts similarity index 83% rename from src/api/resources/unstable/resources/switch/client/Client.ts rename to src/api/resources/preview/resources/switch/client/Client.ts index 0c95ab0e..4f3f7782 100644 --- a/src/api/resources/unstable/resources/switch/client/Client.ts +++ b/src/api/resources/preview/resources/switch/client/Client.ts @@ -34,26 +34,26 @@ export class SwitchClient { * @param {unknown} request * @param {SwitchClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.UnprocessableEntityError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.switch.createPhoneSwitch({ + * await client.preview.switch.createPhoneSwitch({ * "key": "value" * }) */ public createPhoneSwitch( request?: unknown, requestOptions?: SwitchClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createPhoneSwitch(request, requestOptions)); } private async __createPhoneSwitch( request?: unknown, requestOptions?: SwitchClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -82,7 +82,7 @@ export class SwitchClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.PhoneSwitch | undefined, + data: _response.body as Intercom.preview.PhoneSwitch | undefined, rawResponse: _response.rawResponse, }; } @@ -90,14 +90,14 @@ export class SwitchClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 422: - throw new Intercom.unstable.UnprocessableEntityError( + throw new Intercom.preview.UnprocessableEntityError( _response.error.body as unknown, _response.rawResponse, ); diff --git a/src/api/resources/unstable/resources/switch/client/index.ts b/src/api/resources/preview/resources/switch/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/switch/client/index.ts rename to src/api/resources/preview/resources/switch/client/index.ts diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/index.ts b/src/api/resources/preview/resources/switch/index.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypeAttributes/index.ts rename to src/api/resources/preview/resources/switch/index.ts diff --git a/src/api/resources/unstable/resources/tags/client/Client.ts b/src/api/resources/preview/resources/tags/client/Client.ts similarity index 77% rename from src/api/resources/unstable/resources/tags/client/Client.ts rename to src/api/resources/preview/resources/tags/client/Client.ts index 681b40df..c2c9905d 100644 --- a/src/api/resources/unstable/resources/tags/client/Client.ts +++ b/src/api/resources/preview/resources/tags/client/Client.ts @@ -28,35 +28,35 @@ export class TagsClient { /** * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. * - * @param {Intercom.unstable.AttachTagToContactRequest} request + * @param {Intercom.preview.AttachTagToContactRequest} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tags.attachTagToContact({ + * await client.preview.tags.attachTagToContact({ * contact_id: "63a07ddf05a32042dffac965", * id: "7522907" * }) * * @example - * await client.unstable.tags.attachTagToContact({ + * await client.preview.tags.attachTagToContact({ * contact_id: "63a07ddf05a32042dffac965", * id: "123" * }) */ public attachTagToContact( - request: Intercom.unstable.AttachTagToContactRequest, + request: Intercom.preview.AttachTagToContactRequest, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__attachTagToContact(request, requestOptions)); } private async __attachTagToContact( - request: Intercom.unstable.AttachTagToContactRequest, + request: Intercom.preview.AttachTagToContactRequest, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const { contact_id: contactId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -85,18 +85,18 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -112,29 +112,29 @@ export class TagsClient { /** * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. * - * @param {Intercom.unstable.DetachTagFromContactRequest} request + * @param {Intercom.preview.DetachTagFromContactRequest} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tags.detachTagFromContact({ + * await client.preview.tags.detachTagFromContact({ * contact_id: "63a07ddf05a32042dffac965", * id: "7522907" * }) */ public detachTagFromContact( - request: Intercom.unstable.DetachTagFromContactRequest, + request: Intercom.preview.DetachTagFromContactRequest, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__detachTagFromContact(request, requestOptions)); } private async __detachTagFromContact( - request: Intercom.unstable.DetachTagFromContactRequest, + request: Intercom.preview.DetachTagFromContactRequest, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const { contact_id: contactId, id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -160,18 +160,18 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -192,30 +192,30 @@ export class TagsClient { /** * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. * - * @param {Intercom.unstable.AttachTagToConversationRequest} request + * @param {Intercom.preview.AttachTagToConversationRequest} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tags.attachTagToConversation({ + * await client.preview.tags.attachTagToConversation({ * conversation_id: "64619700005694", * id: "7522907", * admin_id: "780" * }) */ public attachTagToConversation( - request: Intercom.unstable.AttachTagToConversationRequest, + request: Intercom.preview.AttachTagToConversationRequest, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__attachTagToConversation(request, requestOptions)); } private async __attachTagToConversation( - request: Intercom.unstable.AttachTagToConversationRequest, + request: Intercom.preview.AttachTagToConversationRequest, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const { conversation_id: conversationId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -244,18 +244,18 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -276,30 +276,30 @@ export class TagsClient { /** * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. * - * @param {Intercom.unstable.DetachTagFromConversationRequest} request + * @param {Intercom.preview.DetachTagFromConversationRequest} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tags.detachTagFromConversation({ + * await client.preview.tags.detachTagFromConversation({ * conversation_id: "64619700005694", * id: "7522907", * admin_id: "123" * }) */ public detachTagFromConversation( - request: Intercom.unstable.DetachTagFromConversationRequest, + request: Intercom.preview.DetachTagFromConversationRequest, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__detachTagFromConversation(request, requestOptions)); } private async __detachTagFromConversation( - request: Intercom.unstable.DetachTagFromConversationRequest, + request: Intercom.preview.DetachTagFromConversationRequest, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const { conversation_id: conversationId, id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -328,18 +328,18 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -363,18 +363,18 @@ export class TagsClient { * * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.tags.listTags() + * await client.preview.tags.listTags() */ - public listTags(requestOptions?: TagsClient.RequestOptions): core.HttpResponsePromise { + public listTags(requestOptions?: TagsClient.RequestOptions): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listTags(requestOptions)); } private async __listTags( requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -399,14 +399,14 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.TagList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TagList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -436,50 +436,33 @@ export class TagsClient { * * Each operation will return a tag object. * - * @param {Intercom.unstable.CreateTagRequestBody} request + * @param {Intercom.preview.CreateTagRequestBody} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.tags.createTag({ + * await client.preview.tags.createTag({ * name: "test" * }) * * @example - * await client.unstable.tags.createTag({ + * await client.preview.tags.createTag({ * name: "Independent" * }) - * - * @example - * await client.unstable.tags.createTag({ - * name: "test", - * companies: [{ - * company_id: "123" - * }] - * }) - * - * @example - * await client.unstable.tags.createTag({ - * name: "test", - * users: [{ - * id: "123" - * }] - * }) */ public createTag( - request: Intercom.unstable.CreateTagRequestBody, + request: Intercom.preview.CreateTagRequestBody, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createTag(request, requestOptions)); } private async __createTag( - request: Intercom.unstable.CreateTagRequestBody, + request: Intercom.preview.CreateTagRequestBody, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -507,20 +490,18 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TagCreateResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -537,28 +518,28 @@ export class TagsClient { * You can fetch the details of tags that are on the workspace by their id. * This will return a tag object. * - * @param {Intercom.unstable.FindTagRequest} request + * @param {Intercom.preview.FindTagRequest} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tags.findTag({ + * await client.preview.tags.findTag({ * id: "123" * }) */ public findTag( - request: Intercom.unstable.FindTagRequest, + request: Intercom.preview.FindTagRequest, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__findTag(request, requestOptions)); } private async __findTag( - request: Intercom.unstable.FindTagRequest, + request: Intercom.preview.FindTagRequest, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -584,18 +565,18 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TagBasic, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -611,27 +592,27 @@ export class TagsClient { /** * You can delete the details of tags that are on the workspace by passing in the id. * - * @param {Intercom.unstable.DeleteTagRequest} request + * @param {Intercom.preview.DeleteTagRequest} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tags.deleteTag({ + * await client.preview.tags.deleteTag({ * id: "123" * }) */ public deleteTag( - request: Intercom.unstable.DeleteTagRequest, + request: Intercom.preview.DeleteTagRequest, requestOptions?: TagsClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteTag(request, requestOptions)); } private async __deleteTag( - request: Intercom.unstable.DeleteTagRequest, + request: Intercom.preview.DeleteTagRequest, requestOptions?: TagsClient.RequestOptions, ): Promise> { const { id } = request; @@ -665,14 +646,14 @@ export class TagsClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -688,30 +669,30 @@ export class TagsClient { /** * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. * - * @param {Intercom.unstable.AttachTagToTicketRequest} request + * @param {Intercom.preview.AttachTagToTicketRequest} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tags.attachTagToTicket({ + * await client.preview.tags.attachTagToTicket({ * ticket_id: "64619700005694", * id: "7522907", * admin_id: "780" * }) */ public attachTagToTicket( - request: Intercom.unstable.AttachTagToTicketRequest, + request: Intercom.preview.AttachTagToTicketRequest, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__attachTagToTicket(request, requestOptions)); } private async __attachTagToTicket( - request: Intercom.unstable.AttachTagToTicketRequest, + request: Intercom.preview.AttachTagToTicketRequest, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const { ticket_id: ticketId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -740,18 +721,18 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -767,30 +748,30 @@ export class TagsClient { /** * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. * - * @param {Intercom.unstable.DetachTagFromTicketRequest} request + * @param {Intercom.preview.DetachTagFromTicketRequest} request * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tags.detachTagFromTicket({ + * await client.preview.tags.detachTagFromTicket({ * ticket_id: "64619700005694", * id: "7522907", * admin_id: "123" * }) */ public detachTagFromTicket( - request: Intercom.unstable.DetachTagFromTicketRequest, + request: Intercom.preview.DetachTagFromTicketRequest, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__detachTagFromTicket(request, requestOptions)); } private async __detachTagFromTicket( - request: Intercom.unstable.DetachTagFromTicketRequest, + request: Intercom.preview.DetachTagFromTicketRequest, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const { ticket_id: ticketId, id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -819,18 +800,18 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/preview/resources/tags/client/index.ts b/src/api/resources/preview/resources/tags/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/tags/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToContactRequest.ts b/src/api/resources/preview/resources/tags/client/requests/AttachTagToContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/AttachTagToContactRequest.ts rename to src/api/resources/preview/resources/tags/client/requests/AttachTagToContactRequest.ts diff --git a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToConversationRequest.ts b/src/api/resources/preview/resources/tags/client/requests/AttachTagToConversationRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/AttachTagToConversationRequest.ts rename to src/api/resources/preview/resources/tags/client/requests/AttachTagToConversationRequest.ts diff --git a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToTicketRequest.ts b/src/api/resources/preview/resources/tags/client/requests/AttachTagToTicketRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/AttachTagToTicketRequest.ts rename to src/api/resources/preview/resources/tags/client/requests/AttachTagToTicketRequest.ts diff --git a/src/api/resources/unstable/resources/tags/client/requests/DeleteTagRequest.ts b/src/api/resources/preview/resources/tags/client/requests/DeleteTagRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/DeleteTagRequest.ts rename to src/api/resources/preview/resources/tags/client/requests/DeleteTagRequest.ts diff --git a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromContactRequest.ts b/src/api/resources/preview/resources/tags/client/requests/DetachTagFromContactRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/DetachTagFromContactRequest.ts rename to src/api/resources/preview/resources/tags/client/requests/DetachTagFromContactRequest.ts diff --git a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromConversationRequest.ts b/src/api/resources/preview/resources/tags/client/requests/DetachTagFromConversationRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/DetachTagFromConversationRequest.ts rename to src/api/resources/preview/resources/tags/client/requests/DetachTagFromConversationRequest.ts diff --git a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromTicketRequest.ts b/src/api/resources/preview/resources/tags/client/requests/DetachTagFromTicketRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/DetachTagFromTicketRequest.ts rename to src/api/resources/preview/resources/tags/client/requests/DetachTagFromTicketRequest.ts diff --git a/src/api/resources/unstable/resources/tags/client/requests/FindTagRequest.ts b/src/api/resources/preview/resources/tags/client/requests/FindTagRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/FindTagRequest.ts rename to src/api/resources/preview/resources/tags/client/requests/FindTagRequest.ts diff --git a/src/api/resources/unstable/resources/tags/client/requests/index.ts b/src/api/resources/preview/resources/tags/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/tags/client/requests/index.ts rename to src/api/resources/preview/resources/tags/client/requests/index.ts diff --git a/src/api/resources/preview/resources/tags/index.ts b/src/api/resources/preview/resources/tags/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/tags/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/tags/types/index.ts b/src/api/resources/preview/resources/tags/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/tags/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/tags/types/types.ts b/src/api/resources/preview/resources/tags/types/types.ts new file mode 100644 index 00000000..1d35a10a --- /dev/null +++ b/src/api/resources/preview/resources/tags/types/types.ts @@ -0,0 +1,37 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +export type CreateTagRequestBody = + | Intercom.preview.CreateOrUpdateTagRequest + | Intercom.preview.TagCompanyRequest + | Intercom.preview.UntagCompanyRequest + | Intercom.preview.TagMultipleUsersRequest; + +/** + * A tag allows you to label your contacts, companies, and conversations and list them using that tag. + */ +export interface Tag { + /** value is "tag" */ + type?: string; + /** The id of the tag */ + id?: string; + /** The name of the tag */ + name?: string; + /** The time when the tag was applied to the object. Only present when the tag is returned as part of a tagging operation on a contact, conversation, ticket, article, internal article, or content snippet. */ + applied_at?: number; + /** The admin who applied the tag. Only present when the tag is returned as part of a tagging operation on a contact, conversation, ticket, article, internal article, or content snippet. */ + applied_by?: Intercom.preview.Reference; +} + +/** + * A tag allows you to label your contacts, companies, and conversations and list them using that tag. + */ +export interface TagBasic { + /** value is "tag" */ + type?: string; + /** The id of the tag */ + id?: string; + /** The name of the tag */ + name?: string; +} diff --git a/src/api/resources/unstable/resources/notes/client/Client.ts b/src/api/resources/preview/resources/teams/client/Client.ts similarity index 51% rename from src/api/resources/unstable/resources/notes/client/Client.ts rename to src/api/resources/preview/resources/teams/client/Client.ts index 6daafede..be1a6d10 100644 --- a/src/api/resources/unstable/resources/notes/client/Client.ts +++ b/src/api/resources/preview/resources/teams/client/Client.ts @@ -9,47 +9,57 @@ import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStat import * as errors from "../../../../../../errors/index.js"; import * as Intercom from "../../../../../index.js"; -export declare namespace NotesClient { +export declare namespace TeamsClient { export interface Options extends BaseClientOptions {} export interface RequestOptions extends BaseRequestOptions {} } /** - * Everything about your Notes + * Everything about your Teams */ -export class NotesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class TeamsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; - constructor(options: NotesClient.Options = {}) { + constructor(options: TeamsClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } /** - * You can fetch a list of notes that are associated to a company. + * Returns real-time activity metrics for admins in the specified team. For each admin, the response includes counts of open, idle, and snoozed conversations. * - * @param {Intercom.unstable.ListCompanyNotesRequest} request - * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * This endpoint requires the `realtime_monitoring` feature to be enabled for your workspace. * - * @throws {@link Intercom.unstable.NotFoundError} + * @param {Intercom.preview.GetTeamMetricsRequest} request + * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.notes.listCompanyNotes({ - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * await client.preview.teams.getTeamMetrics({ + * team_id: "42", + * idle_threshold: 1800 * }) */ - public listCompanyNotes( - request: Intercom.unstable.ListCompanyNotesRequest, - requestOptions?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listCompanyNotes(request, requestOptions)); + public getTeamMetrics( + request: Intercom.preview.GetTeamMetricsRequest, + requestOptions?: TeamsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getTeamMetrics(request, requestOptions)); } - private async __listCompanyNotes( - request: Intercom.unstable.ListCompanyNotesRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __getTeamMetrics( + request: Intercom.preview.GetTeamMetricsRequest, + requestOptions?: TeamsClient.RequestOptions, + ): Promise> { + const { team_id: teamId, idle_threshold: idleThreshold } = request; + const _queryParams: Record = {}; + if (idleThreshold != null) { + _queryParams.idle_threshold = idleThreshold.toString(); + } + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -62,11 +72,11 @@ export class NotesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}/notes`, + `teams/${core.url.encodePathParam(teamId)}/metrics`, ), method: "GET", headers: _headers, - queryParameters: requestOptions?.queryParams, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -74,13 +84,23 @@ export class NotesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.NoteList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TeamMetricList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -90,34 +110,26 @@ export class NotesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}/notes"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams/{team_id}/metrics"); } /** - * You can fetch a list of notes that are associated to a contact. + * This will return a list of team objects for the App. * - * @param {Intercom.unstable.ListNotesRequest} request - * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.notes.listNotes({ - * id: 1 - * }) + * await client.preview.teams.listTeams() */ - public listNotes( - request: Intercom.unstable.ListNotesRequest, - requestOptions?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listNotes(request, requestOptions)); + public listTeams(requestOptions?: TeamsClient.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listTeams(requestOptions)); } - private async __listNotes( - request: Intercom.unstable.ListNotesRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __listTeams( + requestOptions?: TeamsClient.RequestOptions, + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -130,7 +142,7 @@ export class NotesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/notes`, + "teams", ), method: "GET", headers: _headers, @@ -142,13 +154,16 @@ export class NotesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.NoteList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TeamList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -158,53 +173,35 @@ export class NotesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}/notes"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams"); } /** - * You can add a note to a single contact. + * You can fetch the details of a single team, containing an array of admins that belong to this team. * - * @param {Intercom.unstable.CreateNoteRequest} request - * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.RetrieveTeamRequest} request + * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.notes.createNote({ - * id: 1, - * body: "Hello", - * contact_id: "6762f0ad1bb69f9f2193bb62", - * admin_id: "123" - * }) - * - * @example - * await client.unstable.notes.createNote({ - * id: 1, - * body: "Hello", - * contact_id: "6762f0af1bb69f9f2193bb63", - * admin_id: "123" - * }) + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.notes.createNote({ - * id: 1, - * body: "Hello", - * contact_id: "123", - * admin_id: "123" + * await client.preview.teams.retrieveTeam({ + * id: "123" * }) */ - public createNote( - request: Intercom.unstable.CreateNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createNote(request, requestOptions)); + public retrieveTeam( + request: Intercom.preview.RetrieveTeamRequest, + requestOptions?: TeamsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveTeam(request, requestOptions)); } - private async __createNote( - request: Intercom.unstable.CreateNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; + private async __retrieveTeam( + request: Intercom.preview.RetrieveTeamRequest, + requestOptions?: TeamsClient.RequestOptions, + ): Promise> { + const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -217,14 +214,11 @@ export class NotesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/notes`, + `teams/${core.url.encodePathParam(id)}`, ), - method: "POST", + method: "GET", headers: _headers, - contentType: "application/json", queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -232,13 +226,18 @@ export class NotesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Note, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Team, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -248,35 +247,51 @@ export class NotesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/notes"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams/{id}"); } /** - * You can fetch the details of a single note. + * You can replace the set of teammates who belong to a team. Send the full list of + * teammates the team should end up with — any teammate currently on the team and + * missing from the list is removed. This makes the endpoint safe to call on a + * schedule to keep Intercom in step with an external rota or workforce management + * system, since sending an unchanged list makes no changes at all. + * + * A token that acts on behalf of a teammate carries that teammate's permissions: + * they must be able to manage teams, and any team or teammate their access is + * restricted from remains out of reach here. * - * @param {Intercom.unstable.RetrieveNoteRequest} request - * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {Intercom.preview.UpdateTeamMembersRequest} request + * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.ConflictError} * * @example - * await client.unstable.notes.retrieveNote({ - * id: 1 + * await client.preview.teams.updateTeamMembers({ + * id: "123", + * admin_ids: [493881, 493882], + * admin_priority_level: { + * primary_admin_ids: [493881], + * secondary_admin_ids: [493882] + * } * }) */ - public retrieveNote( - request: Intercom.unstable.RetrieveNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveNote(request, requestOptions)); + public updateTeamMembers( + request: Intercom.preview.UpdateTeamMembersRequest, + requestOptions?: TeamsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateTeamMembers(request, requestOptions)); } - private async __retrieveNote( - request: Intercom.unstable.RetrieveNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { id } = request; + private async __updateTeamMembers( + request: Intercom.preview.UpdateTeamMembersRequest, + requestOptions?: TeamsClient.RequestOptions, + ): Promise> { + const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -289,11 +304,14 @@ export class NotesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - `notes/${core.url.encodePathParam(id)}`, + `teams/${core.url.encodePathParam(id)}`, ), - method: "GET", + method: "PUT", headers: _headers, + contentType: "application/json", queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -301,18 +319,30 @@ export class NotesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Note, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Team, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Intercom.preview.ConflictError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -322,6 +352,6 @@ export class NotesClient { } } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/notes/{id}"); + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/teams/{id}"); } } diff --git a/src/api/resources/preview/resources/teams/client/index.ts b/src/api/resources/preview/resources/teams/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/teams/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/preview/resources/teams/client/requests/GetTeamMetricsRequest.ts b/src/api/resources/preview/resources/teams/client/requests/GetTeamMetricsRequest.ts new file mode 100644 index 00000000..039d9dde --- /dev/null +++ b/src/api/resources/preview/resources/teams/client/requests/GetTeamMetricsRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * team_id: "42", + * idle_threshold: 1800 + * } + */ +export interface GetTeamMetricsRequest { + /** The unique identifier of the team to retrieve metrics for. Use `GET /teams` to list available team IDs. */ + team_id: string; + /** The number of seconds after which an open conversation is considered idle. Clamped to the range 1–86400. Defaults to 1800 (30 minutes). */ + idle_threshold?: number; +} diff --git a/src/api/resources/unstable/resources/teams/client/requests/RetrieveTeamRequest.ts b/src/api/resources/preview/resources/teams/client/requests/RetrieveTeamRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/teams/client/requests/RetrieveTeamRequest.ts rename to src/api/resources/preview/resources/teams/client/requests/RetrieveTeamRequest.ts diff --git a/src/api/resources/preview/resources/teams/client/requests/UpdateTeamMembersRequest.ts b/src/api/resources/preview/resources/teams/client/requests/UpdateTeamMembersRequest.ts new file mode 100644 index 00000000..824623e0 --- /dev/null +++ b/src/api/resources/preview/resources/teams/client/requests/UpdateTeamMembersRequest.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../../index.js"; + +/** + * @example + * { + * id: "123", + * admin_ids: [493881, 493882], + * admin_priority_level: { + * primary_admin_ids: [493881], + * secondary_admin_ids: [493882] + * } + * } + */ +export interface UpdateTeamMembersRequest { + /** The unique identifier of a given team. */ + id: string; + /** The ids of every teammate who should be a member of the team. Must contain at least one id, and no more than 1000. */ + admin_ids: number[]; + admin_priority_level?: Intercom.preview.AdminPriorityLevelRequest; +} diff --git a/src/api/resources/preview/resources/teams/client/requests/index.ts b/src/api/resources/preview/resources/teams/client/requests/index.ts new file mode 100644 index 00000000..96fa3736 --- /dev/null +++ b/src/api/resources/preview/resources/teams/client/requests/index.ts @@ -0,0 +1,3 @@ +export type { GetTeamMetricsRequest } from "./GetTeamMetricsRequest.js"; +export type { RetrieveTeamRequest } from "./RetrieveTeamRequest.js"; +export type { UpdateTeamMembersRequest } from "./UpdateTeamMembersRequest.js"; diff --git a/src/api/resources/preview/resources/teams/index.ts b/src/api/resources/preview/resources/teams/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/teams/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/teams/types/index.ts b/src/api/resources/preview/resources/teams/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/teams/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/teams/types/Team.ts b/src/api/resources/preview/resources/teams/types/types.ts similarity index 57% rename from src/api/resources/unstable/resources/teams/types/Team.ts rename to src/api/resources/preview/resources/teams/types/types.ts index 412cc0d0..ce850415 100644 --- a/src/api/resources/unstable/resources/teams/types/Team.ts +++ b/src/api/resources/preview/resources/teams/types/types.ts @@ -14,5 +14,9 @@ export interface Team { name?: string; /** The list of admin IDs that are a part of the team. */ admin_ids?: number[]; - admin_priority_level?: Intercom.unstable.AdminPriorityLevel; + admin_priority_level?: Intercom.preview.AdminPriorityLevel; + /** The assignment limit for the team. This field is only present when the team's distribution type is load balanced. */ + assignment_limit?: number; + /** Describes how assignments are distributed among the team members */ + distribution_method?: string; } diff --git a/src/api/resources/unstable/resources/ticketStates/client/Client.ts b/src/api/resources/preview/resources/ticketStates/client/Client.ts similarity index 87% rename from src/api/resources/unstable/resources/ticketStates/client/Client.ts rename to src/api/resources/preview/resources/ticketStates/client/Client.ts index 84960f00..49f35e29 100644 --- a/src/api/resources/unstable/resources/ticketStates/client/Client.ts +++ b/src/api/resources/preview/resources/ticketStates/client/Client.ts @@ -30,20 +30,20 @@ export class TicketStatesClient { * * @param {TicketStatesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.ticketStates.listTicketStates() + * await client.preview.ticketStates.listTicketStates() */ public listTicketStates( requestOptions?: TicketStatesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listTicketStates(requestOptions)); } private async __listTicketStates( requestOptions?: TicketStatesClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -68,14 +68,14 @@ export class TicketStatesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.TicketStateList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TicketStateList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/unstable/resources/ticketStates/client/index.ts b/src/api/resources/preview/resources/ticketStates/client/index.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketStates/client/index.ts rename to src/api/resources/preview/resources/ticketStates/client/index.ts diff --git a/src/api/resources/unstable/resources/ticketTypes/index.ts b/src/api/resources/preview/resources/ticketStates/index.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypes/index.ts rename to src/api/resources/preview/resources/ticketStates/index.ts diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts b/src/api/resources/preview/resources/ticketTypeAttributes/client/Client.ts similarity index 82% rename from src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts rename to src/api/resources/preview/resources/ticketTypeAttributes/client/Client.ts index fe5a1095..8c3ec521 100644 --- a/src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts +++ b/src/api/resources/preview/resources/ticketTypeAttributes/client/Client.ts @@ -28,13 +28,13 @@ export class TicketTypeAttributesClient { /** * You can create a new attribute for a ticket type. * - * @param {Intercom.unstable.CreateTicketTypeAttributeRequest} request + * @param {Intercom.preview.CreateTicketTypeAttributeRequest} request * @param {TicketTypeAttributesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ + * await client.preview.ticketTypeAttributes.createTicketTypeAttribute({ * ticket_type_id: "ticket_type_id", * name: "Attribute Title", * description: "Attribute Description", @@ -43,16 +43,16 @@ export class TicketTypeAttributesClient { * }) */ public createTicketTypeAttribute( - request: Intercom.unstable.CreateTicketTypeAttributeRequest, + request: Intercom.preview.CreateTicketTypeAttributeRequest, requestOptions?: TicketTypeAttributesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createTicketTypeAttribute(request, requestOptions)); } private async __createTicketTypeAttribute( - request: Intercom.unstable.CreateTicketTypeAttributeRequest, + request: Intercom.preview.CreateTicketTypeAttributeRequest, requestOptions?: TicketTypeAttributesClient.RequestOptions, - ): Promise> { + ): Promise> { const { ticket_type_id: ticketTypeId, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -82,7 +82,7 @@ export class TicketTypeAttributesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.TicketTypeAttribute | undefined, + data: _response.body as Intercom.preview.TicketTypeAttribute | undefined, rawResponse: _response.rawResponse, }; } @@ -90,8 +90,8 @@ export class TicketTypeAttributesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -114,29 +114,29 @@ export class TicketTypeAttributesClient { /** * You can update an existing attribute for a ticket type. * - * @param {Intercom.unstable.UpdateTicketTypeAttributeRequest} request + * @param {Intercom.preview.UpdateTicketTypeAttributeRequest} request * @param {TicketTypeAttributesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ + * await client.preview.ticketTypeAttributes.updateTicketTypeAttribute({ * ticket_type_id: "ticket_type_id", * id: "id", * description: "New Attribute Description" * }) */ public updateTicketTypeAttribute( - request: Intercom.unstable.UpdateTicketTypeAttributeRequest, + request: Intercom.preview.UpdateTicketTypeAttributeRequest, requestOptions?: TicketTypeAttributesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateTicketTypeAttribute(request, requestOptions)); } private async __updateTicketTypeAttribute( - request: Intercom.unstable.UpdateTicketTypeAttributeRequest, + request: Intercom.preview.UpdateTicketTypeAttributeRequest, requestOptions?: TicketTypeAttributesClient.RequestOptions, - ): Promise> { + ): Promise> { const { ticket_type_id: ticketTypeId, id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -166,7 +166,7 @@ export class TicketTypeAttributesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.TicketTypeAttribute | undefined, + data: _response.body as Intercom.preview.TicketTypeAttribute | undefined, rawResponse: _response.rawResponse, }; } @@ -174,8 +174,8 @@ export class TicketTypeAttributesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/preview/resources/ticketTypeAttributes/client/index.ts b/src/api/resources/preview/resources/ticketTypeAttributes/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/ticketTypeAttributes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts b/src/api/resources/preview/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts rename to src/api/resources/preview/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts b/src/api/resources/preview/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts rename to src/api/resources/preview/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/index.ts b/src/api/resources/preview/resources/ticketTypeAttributes/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/index.ts rename to src/api/resources/preview/resources/ticketTypeAttributes/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/visitors/index.ts b/src/api/resources/preview/resources/ticketTypeAttributes/index.ts similarity index 100% rename from src/api/resources/unstable/resources/visitors/index.ts rename to src/api/resources/preview/resources/ticketTypeAttributes/index.ts diff --git a/src/api/resources/unstable/resources/ticketTypes/client/Client.ts b/src/api/resources/preview/resources/ticketTypes/client/Client.ts similarity index 84% rename from src/api/resources/unstable/resources/ticketTypes/client/Client.ts rename to src/api/resources/preview/resources/ticketTypes/client/Client.ts index 1d1adfed..08d89818 100644 --- a/src/api/resources/unstable/resources/ticketTypes/client/Client.ts +++ b/src/api/resources/preview/resources/ticketTypes/client/Client.ts @@ -30,20 +30,20 @@ export class TicketTypesClient { * * @param {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.ticketTypes.listTicketTypes() + * await client.preview.ticketTypes.listTicketTypes() */ public listTicketTypes( requestOptions?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listTicketTypes(requestOptions)); } private async __listTicketTypes( requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -68,14 +68,14 @@ export class TicketTypesClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.TicketTypeList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TicketTypeList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -100,24 +100,24 @@ export class TicketTypesClient { * @param {unknown} request * @param {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.ticketTypes.createTicketType({ + * await client.preview.ticketTypes.createTicketType({ * "key": "value" * }) */ public createTicketType( request?: unknown, requestOptions?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createTicketType(request, requestOptions)); } private async __createTicketType( request?: unknown, requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -146,7 +146,7 @@ export class TicketTypesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.TicketType | undefined, + data: _response.body as Intercom.preview.TicketType | undefined, rawResponse: _response.rawResponse, }; } @@ -154,8 +154,8 @@ export class TicketTypesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -173,27 +173,27 @@ export class TicketTypesClient { /** * You can fetch the details of a single ticket type. * - * @param {Intercom.unstable.GetTicketTypeRequest} request + * @param {Intercom.preview.GetTicketTypeRequest} request * @param {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.ticketTypes.getTicketType({ + * await client.preview.ticketTypes.getTicketType({ * id: "id" * }) */ public getTicketType( - request: Intercom.unstable.GetTicketTypeRequest, + request: Intercom.preview.GetTicketTypeRequest, requestOptions?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getTicketType(request, requestOptions)); } private async __getTicketType( - request: Intercom.unstable.GetTicketTypeRequest, + request: Intercom.preview.GetTicketTypeRequest, requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -220,7 +220,7 @@ export class TicketTypesClient { }); if (_response.ok) { return { - data: _response.body as Intercom.unstable.TicketType | undefined, + data: _response.body as Intercom.preview.TicketType | undefined, rawResponse: _response.rawResponse, }; } @@ -228,8 +228,8 @@ export class TicketTypesClient { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/preview/resources/ticketTypes/client/index.ts b/src/api/resources/preview/resources/ticketTypes/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/ticketTypes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts b/src/api/resources/preview/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts rename to src/api/resources/preview/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts diff --git a/src/api/resources/unstable/resources/ticketTypes/client/requests/index.ts b/src/api/resources/preview/resources/ticketTypes/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/ticketTypes/client/requests/index.ts rename to src/api/resources/preview/resources/ticketTypes/client/requests/index.ts diff --git a/src/api/resources/unstable/resources/workflows/index.ts b/src/api/resources/preview/resources/ticketTypes/index.ts similarity index 100% rename from src/api/resources/unstable/resources/workflows/index.ts rename to src/api/resources/preview/resources/ticketTypes/index.ts diff --git a/src/api/resources/unstable/resources/tickets/client/Client.ts b/src/api/resources/preview/resources/tickets/client/Client.ts similarity index 56% rename from src/api/resources/unstable/resources/tickets/client/Client.ts rename to src/api/resources/preview/resources/tickets/client/Client.ts index 4c28d71b..2f45b3a6 100644 --- a/src/api/resources/unstable/resources/tickets/client/Client.ts +++ b/src/api/resources/preview/resources/tickets/client/Client.ts @@ -28,15 +28,15 @@ export class TicketsClient { /** * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. * - * @param {Intercom.unstable.ReplyTicketRequest} request + * @param {Intercom.preview.ReplyTicketRequest} request * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tickets.replyTicket({ + * await client.preview.tickets.replyTicket({ * id: "123", * body: { * message_type: "comment", @@ -47,7 +47,7 @@ export class TicketsClient { * }) * * @example - * await client.unstable.tickets.replyTicket({ + * await client.preview.tickets.replyTicket({ * id: "123", * body: { * message_type: "note", @@ -58,7 +58,19 @@ export class TicketsClient { * }) * * @example - * await client.unstable.tickets.replyTicket({ + * await client.preview.tickets.replyTicket({ + * id: "123", + * body: { + * message_type: "note", + * type: "admin", + * body: "This note will be cross-posted to all linked conversations.", + * admin_id: "3156780", + * cross_post: true + * } + * }) + * + * @example + * await client.preview.tickets.replyTicket({ * id: "123", * body: { * message_type: "quick_reply", @@ -75,7 +87,7 @@ export class TicketsClient { * }) * * @example - * await client.unstable.tickets.replyTicket({ + * await client.preview.tickets.replyTicket({ * id: "123", * body: { * message_type: "comment", @@ -86,16 +98,16 @@ export class TicketsClient { * }) */ public replyTicket( - request: Intercom.unstable.ReplyTicketRequest, + request: Intercom.preview.ReplyTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__replyTicket(request, requestOptions)); } private async __replyTicket( - request: Intercom.unstable.ReplyTicketRequest, + request: Intercom.preview.ReplyTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, body: _body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -124,20 +136,20 @@ export class TicketsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.TicketReply, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TicketReply, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -150,17 +162,201 @@ export class TicketsClient { return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/{id}/reply"); } + /** + * Link a conversation to an existing tracker ticket. The conversation can be + * a regular conversation or one that has been converted into a customer ticket. + * + * Use this when related conversations surface after a tracker ticket has + * already been created. The ticket in the path must be a tracker ticket, and + * `conversation_id` in the body is the conversation (or customer ticket) to + * link to it. This returns the linked conversation. + * + * A tracker ticket can have up to 2,500 linked conversations; once that + * limit is reached, further requests return `linked_conversation_limit_exceeded`. + * + * Requires the `write_tickets` OAuth scope. + * + * @param {Intercom.preview.LinkConversationToTicketRequest} request + * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.tickets.linkConversationToTicket({ + * ticket_id: "64619700005694", + * conversation_id: "204" + * }) + */ + public linkConversationToTicket( + request: Intercom.preview.LinkConversationToTicketRequest, + requestOptions?: TicketsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__linkConversationToTicket(request, requestOptions)); + } + + private async __linkConversationToTicket( + request: Intercom.preview.LinkConversationToTicketRequest, + requestOptions?: TicketsClient.RequestOptions, + ): Promise> { + const { ticket_id: ticketId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${core.url.encodePathParam(ticketId)}/linked_conversations`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/tickets/{ticket_id}/linked_conversations", + ); + } + + /** + * Unlink a conversation (or converted customer ticket) from a tracker ticket + * it is currently linked to. The ticket in the path must be a tracker ticket. + * This returns the conversation that was unlinked. + * + * Requires the `write_tickets` OAuth scope. + * + * @param {Intercom.preview.UnlinkConversationFromTicketRequest} request + * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.tickets.unlinkConversationFromTicket({ + * ticket_id: "64619700005694", + * id: "204" + * }) + */ + public unlinkConversationFromTicket( + request: Intercom.preview.UnlinkConversationFromTicketRequest, + requestOptions?: TicketsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__unlinkConversationFromTicket(request, requestOptions)); + } + + private async __unlinkConversationFromTicket( + request: Intercom.preview.UnlinkConversationFromTicketRequest, + requestOptions?: TicketsClient.RequestOptions, + ): Promise> { + const { ticket_id: ticketId, id } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${core.url.encodePathParam(ticketId)}/linked_conversations/${core.url.encodePathParam(id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/tickets/{ticket_id}/linked_conversations/{id}", + ); + } + /** * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. * - * @param {Intercom.unstable.EnqueueCreateTicketRequest} request + * @param {Intercom.preview.EnqueueCreateTicketRequest} request * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.tickets.enqueueCreateTicket({ + * await client.preview.tickets.enqueueCreateTicket({ * ticket_type_id: "1234", * contacts: [{ * id: "6762f2d81bb69f9f2193bc54" @@ -168,16 +364,16 @@ export class TicketsClient { * }) */ public enqueueCreateTicket( - request: Intercom.unstable.EnqueueCreateTicketRequest, + request: Intercom.preview.EnqueueCreateTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__enqueueCreateTicket(request, requestOptions)); } private async __enqueueCreateTicket( - request: Intercom.unstable.EnqueueCreateTicketRequest, + request: Intercom.preview.EnqueueCreateTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -205,16 +401,16 @@ export class TicketsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Jobs, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Jobs, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -232,27 +428,27 @@ export class TicketsClient { /** * You can fetch the details of a single ticket. * - * @param {Intercom.unstable.GetTicketRequest} request + * @param {Intercom.preview.GetTicketRequest} request * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.tickets.getTicket({ + * await client.preview.tickets.getTicket({ * id: "id" * }) */ public getTicket( - request: Intercom.unstable.GetTicketRequest, + request: Intercom.preview.GetTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getTicket(request, requestOptions)); } private async __getTicket( - request: Intercom.unstable.GetTicketRequest, + request: Intercom.preview.GetTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -278,14 +474,14 @@ export class TicketsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Ticket | undefined, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Ticket | undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: @@ -303,15 +499,17 @@ export class TicketsClient { /** * You can update a ticket. * - * @param {Intercom.unstable.UpdateTicketRequest} request + * @param {Intercom.preview.UpdateTicketRequest} request * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} + * @throws {@link Intercom.preview.UnprocessableEntityError} * * @example - * await client.unstable.tickets.updateTicket({ + * await client.preview.tickets.updateTicket({ * id: "id", * ticket_attributes: { * "_default_title_": "example", @@ -321,11 +519,12 @@ export class TicketsClient { * open: true, * snoozed_until: 1673609604, * admin_id: 991268011, - * assignee_id: "123" + * assignee_id: "123", + * priority: "high" * }) * * @example - * await client.unstable.tickets.updateTicket({ + * await client.preview.tickets.updateTicket({ * id: "id", * ticket_attributes: { * "_default_title_": "example", @@ -337,22 +536,22 @@ export class TicketsClient { * }) * * @example - * await client.unstable.tickets.updateTicket({ + * await client.preview.tickets.updateTicket({ * id: "id", * ticket_state_id: "123" * }) */ public updateTicket( - request: Intercom.unstable.UpdateTicketRequest, + request: Intercom.preview.UpdateTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateTicket(request, requestOptions)); } private async __updateTicket( - request: Intercom.unstable.UpdateTicketRequest, + request: Intercom.preview.UpdateTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id, ..._body } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -381,20 +580,30 @@ export class TicketsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Ticket | undefined, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Ticket | undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.preview.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -408,30 +617,35 @@ export class TicketsClient { } /** - * You can delete a ticket using the Intercom provided ID. + * {% admonition type="warning" name="Irreversible operation" %} + * Deleting a ticket is permanent and cannot be reversed. + * {% /admonition %} * - * @param {Intercom.unstable.DeleteTicketRequest} request + * Deleting a ticket permanently removes it from the inbox. All sensitive data is deleted, including admin and user replies, ticket attributes, uploads, and related content. The ticket will still appear in reporting, though some data may be incomplete due to the deletion. + * + * @param {Intercom.preview.DeleteTicketRequest} request * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.tickets.deleteTicket({ + * await client.preview.tickets.deleteTicket({ * id: "id" * }) */ public deleteTicket( - request: Intercom.unstable.DeleteTicketRequest, + request: Intercom.preview.DeleteTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteTicket(request, requestOptions)); } private async __deleteTicket( - request: Intercom.unstable.DeleteTicketRequest, + request: Intercom.preview.DeleteTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -457,21 +671,23 @@ export class TicketsClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.DeleteTicketResponse, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.TicketDeleted, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -484,6 +700,93 @@ export class TicketsClient { return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/tickets/{id}"); } + /** + * You can change the type of a ticket. The new ticket type must be in the same category as the current type. Attributes matching by name and type are automatically transferred from the old type; values provided in ticket_attributes override transferred values. + * + * @param {Intercom.preview.ChangeTicketTypeRequest} request + * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.preview.BadRequestError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} + * + * @example + * await client.preview.tickets.changeTicketType({ + * ticket_id: "ticket_id", + * ticket_type_id: "1234", + * ticket_state_id: "5678" + * }) + */ + public changeTicketType( + request: Intercom.preview.ChangeTicketTypeRequest, + requestOptions?: TicketsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__changeTicketType(request, requestOptions)); + } + + private async __changeTicketType( + request: Intercom.preview.ChangeTicketTypeRequest, + requestOptions?: TicketsClient.RequestOptions, + ): Promise> { + const { ticket_id: ticketId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${core.url.encodePathParam(ticketId)}/change_type`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Intercom.preview.Ticket | undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.preview.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/tickets/{ticket_id}/change_type", + ); + } + /** * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. * @@ -520,8 +823,8 @@ export class TicketsClient { * | ticket_type_id | String | * | contact_ids | String | * | teammate_ids | String | - * | admin_assignee_id | String | - * | team_assignee_id | String | + * | admin_assignee_id | Integer | + * | team_assignee_id | Integer | * | open | Boolean | * | state | String | * | snoozed_until | Date (UNIX timestamp) | @@ -555,11 +858,11 @@ export class TicketsClient { * | ^ | String | Starts With | * | $ | String | Ends With | * - * @param {Intercom.unstable.SearchRequest} request + * @param {Intercom.preview.SearchRequest} request * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.unstable.tickets.searchTickets({ + * await client.preview.tickets.searchTickets({ * query: { * operator: "AND", * value: [{ @@ -574,16 +877,16 @@ export class TicketsClient { * }) */ public searchTickets( - request: Intercom.unstable.SearchRequest, + request: Intercom.preview.SearchRequest, requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__searchTickets(request, requestOptions)); } private async __searchTickets( - request: Intercom.unstable.SearchRequest, + request: Intercom.preview.SearchRequest, requestOptions?: TicketsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -611,7 +914,7 @@ export class TicketsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.TicketList, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.TicketList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { diff --git a/src/api/resources/preview/resources/tickets/client/index.ts b/src/api/resources/preview/resources/tickets/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/tickets/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/preview/resources/tickets/client/requests/ChangeTicketTypeRequest.ts b/src/api/resources/preview/resources/tickets/client/requests/ChangeTicketTypeRequest.ts new file mode 100644 index 00000000..10614965 --- /dev/null +++ b/src/api/resources/preview/resources/tickets/client/requests/ChangeTicketTypeRequest.ts @@ -0,0 +1,20 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * ticket_id: "ticket_id", + * ticket_type_id: "1234", + * ticket_state_id: "5678" + * } + */ +export interface ChangeTicketTypeRequest { + /** The unique identifier for the ticket which is given by Intercom. */ + ticket_id: string; + /** The ID of the new ticket type. Must be in the same category as the current type. */ + ticket_type_id: string; + /** The ID of the ticket state for the new ticket type. */ + ticket_state_id: string; + /** The attributes to set on the ticket for the new type. Attributes matching by name and type are transferred automatically from the old type; values provided here override the transferred values. */ + ticket_attributes?: Record; +} diff --git a/src/api/resources/preview/resources/tickets/client/requests/DeleteTicketRequest.ts b/src/api/resources/preview/resources/tickets/client/requests/DeleteTicketRequest.ts new file mode 100644 index 00000000..44ff9904 --- /dev/null +++ b/src/api/resources/preview/resources/tickets/client/requests/DeleteTicketRequest.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "id" + * } + */ +export interface DeleteTicketRequest { + /** + * The unique identifier for the ticket which is given by Intercom. + * {% admonition type="info" name="Not the Inbox ticket ID" %} + * This is the internal `id` field from the API response, not the `ticket_id` displayed in the Intercom Inbox (e.g., #12345). Use the `id` value from the ticket object returned by the API. + * {% /admonition %} + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts b/src/api/resources/preview/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts similarity index 80% rename from src/api/resources/unstable/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts rename to src/api/resources/preview/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts index 74d72736..7e01530a 100644 --- a/src/api/resources/unstable/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts +++ b/src/api/resources/preview/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts @@ -11,7 +11,7 @@ import type * as Intercom from "../../../../../../index.js"; * }] * } */ -export interface EnqueueCreateTicketRequest extends Intercom.unstable.CreateTicketRequestBody { +export interface EnqueueCreateTicketRequest extends Intercom.preview.CreateTicketRequestBody { /** Option to disable notifications when a Ticket is created. */ skip_notifications?: boolean; } diff --git a/src/api/resources/preview/resources/tickets/client/requests/GetTicketRequest.ts b/src/api/resources/preview/resources/tickets/client/requests/GetTicketRequest.ts new file mode 100644 index 00000000..72855444 --- /dev/null +++ b/src/api/resources/preview/resources/tickets/client/requests/GetTicketRequest.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * id: "id" + * } + */ +export interface GetTicketRequest { + /** + * The unique identifier for the ticket which is given by Intercom. + * {% admonition type="info" name="Not the Inbox ticket ID" %} + * This is the internal `id` field from the API response, not the `ticket_id` displayed in the Intercom Inbox (e.g., #12345). Use the `id` value from the ticket object returned by the API. + * {% /admonition %} + */ + id: string; +} diff --git a/src/api/resources/preview/resources/tickets/client/requests/LinkConversationToTicketRequest.ts b/src/api/resources/preview/resources/tickets/client/requests/LinkConversationToTicketRequest.ts new file mode 100644 index 00000000..19de40ba --- /dev/null +++ b/src/api/resources/preview/resources/tickets/client/requests/LinkConversationToTicketRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * ticket_id: "64619700005694", + * conversation_id: "204" + * } + */ +export interface LinkConversationToTicketRequest { + /** The unique identifier for the tracker ticket which is given by Intercom. */ + ticket_id: string; + /** The unique identifier (given by Intercom) for the conversation or customer ticket to link to the tracker ticket. */ + conversation_id: string; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/ReplyTicketRequest.ts b/src/api/resources/preview/resources/tickets/client/requests/ReplyTicketRequest.ts similarity index 72% rename from src/api/resources/unstable/resources/tickets/client/requests/ReplyTicketRequest.ts rename to src/api/resources/preview/resources/tickets/client/requests/ReplyTicketRequest.ts index 1e53f5d6..a25eb051 100644 --- a/src/api/resources/unstable/resources/tickets/client/requests/ReplyTicketRequest.ts +++ b/src/api/resources/preview/resources/tickets/client/requests/ReplyTicketRequest.ts @@ -29,6 +29,18 @@ import type * as Intercom from "../../../../../../index.js"; * { * id: "123", * body: { + * message_type: "note", + * type: "admin", + * body: "This note will be cross-posted to all linked conversations.", + * admin_id: "3156780", + * cross_post: true + * } + * } + * + * @example + * { + * id: "123", + * body: { * message_type: "quick_reply", * type: "admin", * admin_id: "3156780", @@ -52,8 +64,19 @@ import type * as Intercom from "../../../../../../index.js"; * intercom_user_id: "6762f2a41bb69f9f2193bc4c" * } * } + * + * @example + * { + * id: "123", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f2971bb69f9f2193bc49" + * } + * } */ export interface ReplyTicketRequest { id: string; - body: Intercom.unstable.ReplyTicketRequestBody; + body: Intercom.preview.ReplyTicketRequestBody; } diff --git a/src/api/resources/preview/resources/tickets/client/requests/UnlinkConversationFromTicketRequest.ts b/src/api/resources/preview/resources/tickets/client/requests/UnlinkConversationFromTicketRequest.ts new file mode 100644 index 00000000..e0ada1e4 --- /dev/null +++ b/src/api/resources/preview/resources/tickets/client/requests/UnlinkConversationFromTicketRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * ticket_id: "64619700005694", + * id: "204" + * } + */ +export interface UnlinkConversationFromTicketRequest { + /** The unique identifier for the tracker ticket which is given by Intercom. */ + ticket_id: string; + /** The unique identifier (given by Intercom) for the linked conversation or customer ticket to unlink. */ + id: string; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/UpdateTicketRequest.ts b/src/api/resources/preview/resources/tickets/client/requests/UpdateTicketRequest.ts similarity index 53% rename from src/api/resources/unstable/resources/tickets/client/requests/UpdateTicketRequest.ts rename to src/api/resources/preview/resources/tickets/client/requests/UpdateTicketRequest.ts index 63d68d08..0075379e 100644 --- a/src/api/resources/unstable/resources/tickets/client/requests/UpdateTicketRequest.ts +++ b/src/api/resources/preview/resources/tickets/client/requests/UpdateTicketRequest.ts @@ -1,5 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Intercom from "../../../../../../index.js"; + /** * @example * { @@ -12,7 +14,8 @@ * open: true, * snoozed_until: 1673609604, * admin_id: 991268011, - * assignee_id: "123" + * assignee_id: "123", + * priority: "high" * } * * @example @@ -45,23 +48,14 @@ * ticket_state_id: "123" * } */ -export interface UpdateTicketRequest { - /** The unique identifier for the ticket which is given by Intercom */ +export interface UpdateTicketRequest extends Intercom.preview.UpdateTicketRequestBody { + /** + * The unique identifier for the ticket which is given by Intercom. + * {% admonition type="info" name="Not the Inbox ticket ID" %} + * This is the internal `id` field from the API response, not the `ticket_id` displayed in the Intercom Inbox (e.g., #12345). Use the `id` value from the ticket object returned by the API. + * {% /admonition %} + */ id: string; - /** The attributes set on the ticket. */ - ticket_attributes?: Record; - /** The ID of the ticket state associated with the ticket type. */ - ticket_state_id?: string; - /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. */ - company_id?: string; - /** Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. */ - open?: boolean; - /** Specify whether the ticket is visible to users. */ - is_shared?: boolean; - /** The time you want the ticket to reopen. */ - snoozed_until?: number; - /** The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. */ - admin_id?: number; - /** The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. */ - assignee_id?: string; + /** Option to disable notifications when a Ticket is updated. */ + skip_notifications?: boolean; } diff --git a/src/api/resources/unstable/resources/tickets/client/requests/index.ts b/src/api/resources/preview/resources/tickets/client/requests/index.ts similarity index 56% rename from src/api/resources/unstable/resources/tickets/client/requests/index.ts rename to src/api/resources/preview/resources/tickets/client/requests/index.ts index 8f0e8032..06cf9269 100644 --- a/src/api/resources/unstable/resources/tickets/client/requests/index.ts +++ b/src/api/resources/preview/resources/tickets/client/requests/index.ts @@ -1,5 +1,8 @@ +export type { ChangeTicketTypeRequest } from "./ChangeTicketTypeRequest.js"; export type { DeleteTicketRequest } from "./DeleteTicketRequest.js"; export type { EnqueueCreateTicketRequest } from "./EnqueueCreateTicketRequest.js"; export type { GetTicketRequest } from "./GetTicketRequest.js"; +export type { LinkConversationToTicketRequest } from "./LinkConversationToTicketRequest.js"; export type { ReplyTicketRequest } from "./ReplyTicketRequest.js"; +export type { UnlinkConversationFromTicketRequest } from "./UnlinkConversationFromTicketRequest.js"; export type { UpdateTicketRequest } from "./UpdateTicketRequest.js"; diff --git a/src/api/resources/preview/resources/tickets/index.ts b/src/api/resources/preview/resources/tickets/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/preview/resources/tickets/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/preview/resources/tickets/types/index.ts b/src/api/resources/preview/resources/tickets/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/resources/tickets/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/resources/tickets/types/types.ts b/src/api/resources/preview/resources/tickets/types/types.ts new file mode 100644 index 00000000..54f97348 --- /dev/null +++ b/src/api/resources/preview/resources/tickets/types/types.ts @@ -0,0 +1,292 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../../../index.js"; + +export type ReplyTicketRequestBody = + | Intercom.preview.ContactReplyTicketRequest + | Intercom.preview.AdminReplyTicketRequest; + +/** + * Tickets are how you track requests from your users. + */ +export interface Ticket { + /** Always ticket */ + type?: "ticket"; + /** The unique identifier for the ticket which is given by Intercom. */ + id?: string; + /** The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. */ + ticket_id?: string; + /** Category of the Ticket. */ + category?: Ticket.Category; + ticket_attributes?: Intercom.preview.TicketCustomAttributes; + ticket_state?: Intercom.preview.TicketState; + ticket_type?: Intercom.preview.TicketType; + contacts?: Intercom.preview.TicketContacts; + /** The id representing the admin assigned to the ticket. If it's not assigned to an admin it will return 0. */ + admin_assignee_id?: number; + /** The id representing the team assigned to the ticket. If it's not assigned to a team it will return 0. */ + team_assignee_id?: number; + /** The time the ticket was created as a UTC Unix timestamp. */ + created_at?: number; + /** The last time the ticket was updated as a UTC Unix timestamp. */ + updated_at?: number; + /** Whether or not the ticket is open. If false, the ticket is closed. */ + open?: boolean; + /** The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed. */ + snoozed_until?: number; + linked_objects?: Intercom.preview.LinkedObjectList; + ticket_parts?: Intercom.preview.TicketParts; + /** Whether or not the ticket is shared with the customer. */ + is_shared?: boolean; + /** The ID of the previous ticket state from the most recent state change. Returns null if no state change history exists. Useful for tracking state transitions for reporting and compliance. */ + previous_ticket_state_id?: string; +} + +export namespace Ticket { + /** Category of the Ticket. */ + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; +} + +/** + * The list of contacts affected by a ticket. + */ +export interface TicketContacts { + /** always contact.list */ + type?: "contact.list"; + /** The list of contacts affected by this ticket. */ + contacts?: Intercom.preview.ContactReference[]; +} + +/** + * A Ticket Part represents a message in the ticket. + */ +export interface TicketPart { + /** Always ticket_part */ + type?: string; + /** The id representing the ticket part. */ + id?: string; + /** The type of ticket part. */ + part_type?: string; + /** The message body, which may contain HTML. */ + body?: string; + /** The previous state of the ticket. */ + previous_ticket_state?: TicketPart.PreviousTicketState; + /** The state of the ticket. */ + ticket_state?: TicketPart.TicketState; + /** The time the ticket part was created. */ + created_at?: number; + /** The last time the ticket part was updated. */ + updated_at?: number; + /** The assignee this ticket_part assigned the ticket to, as a reference whose `type` is `admin`, `team` or `bot`. When the part unassigned the ticket, `type` is `nobody_admin` and `id` is `null`. Null when the part did not change the assignment, or when the assignee has since been deleted. */ + assigned_to?: Intercom.preview.Reference; + /** The id of the teammate that this ticket_part assigned the ticket to, or 0 if the part removed the teammate. Null or absent when the part did not change the teammate, including an unassignment that did not name which assignee it cleared. A bot is reported here, because assignment treats anything that is not a team as a teammate. */ + admin_assignee_id?: number; + /** The id of the team that this ticket_part assigned the ticket to, or 0 if the part removed the team. Null or absent when the part did not change the team, including an unassignment that did not name which assignee it cleared. A part can assign a team and a teammate at the same time, for example when the team uses Round Robin distribution and the teammate is resolved inline. In that case assigned_to reports only the teammate, and these two fields report each assignee separately. */ + team_assignee_id?: number; + author?: Intercom.preview.TicketPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.preview.PartAttachment[]; + /** The external id of the ticket part */ + external_id?: string; + /** Whether or not the ticket part has been redacted. */ + redacted?: boolean; + /** The app package code if this part was created via API. Note this field won't show if the part was not created via API. */ + app_package_code?: string; + /** A map of the reply text keyed by locale code. Only present on the Preview API version and backs the `ticket.admin.replied.translated` webhook topic. The special `original` key holds the source locale code of the reply; every other key is a locale code whose value is the reply text translated into that locale, as HTML in the same format as `body`. The `body` field is unchanged and always stays in the original source language. Available in the Preview API version only (set `Intercom-Version: Preview`). This webhook topic is not sent for every translated reply: it is suppressed when the reply's `body` contains any text outside an HTML block element, which includes plain-text replies created through the REST API. Wrap the body in `

`, `

`, or another supported block element to avoid this. */ + translations?: Record; + /** The updated attribute data of the ticket part. Only present for attribute update parts. */ + updated_attribute_data?: TicketPart.UpdatedAttributeData; +} + +export namespace TicketPart { + /** The previous state of the ticket. */ + export const PreviousTicketState = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + export type PreviousTicketState = (typeof PreviousTicketState)[keyof typeof PreviousTicketState]; + /** The state of the ticket. */ + export const TicketState = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + export type TicketState = (typeof TicketState)[keyof typeof TicketState]; + + /** + * The updated attribute data of the ticket part. Only present for attribute update parts. + */ + export interface UpdatedAttributeData { + /** Information about the attribute that was updated. */ + attribute: UpdatedAttributeData.Attribute; + /** The new value of the attribute. */ + value: UpdatedAttributeData.Value; + } + + export namespace UpdatedAttributeData { + /** + * Information about the attribute that was updated. + */ + export interface Attribute { + /** The type of the object. Always 'attribute'. */ + type: "attribute"; + /** The unique identifier of the attribute. */ + id: string; + /** The human-readable name of the attribute. */ + label: string; + } + + /** + * The new value of the attribute. + */ + export interface Value { + /** The type of the object. Always 'value'. */ + type: "value"; + id: Value.Id; + label: Value.Label; + } + + export namespace Value { + export type Id = + /** + * The value for text/number/decimal/boolean/date attributes, or the ID of the list option for list attributes. */ + | string + | undefined + /** + * Array of file IDs for file attributes. */ + | number[]; + export type Label = + /** + * The display value for text/number/decimal/boolean/date/list attributes. */ + | string + /** + * Array of file names for file attributes. */ + | string[]; + } + } +} + +/** + * A ticket state, used to define the state of a ticket. + */ +export interface TicketState { + /** String representing the object's type. Always has the value `ticket_state`. */ + type?: string; + /** The id of the ticket state */ + id?: string; + /** The category of the ticket state */ + category?: TicketState.Category; + /** The state the ticket is currently in, in a human readable form - visible in Intercom */ + internal_label?: string; + /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ + external_label?: string; +} + +export namespace TicketState { + /** The category of the ticket state */ + export const Category = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; +} + +/** + * A ticket state, used to define the state of a ticket. + */ +export interface TicketStateDetailed { + /** String representing the object's type. Always has the value `ticket_state`. */ + type?: string; + /** The id of the ticket state */ + id?: string; + /** The category of the ticket state */ + category?: TicketStateDetailed.Category; + /** The state the ticket is currently in, in a human readable form - visible in Intercom */ + internal_label?: string; + /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ + external_label?: string; + /** Whether the ticket state is archived */ + archived?: boolean; + /** A list of ticket types associated with a given ticket state. */ + ticket_types?: TicketStateDetailed.TicketTypes; +} + +export namespace TicketStateDetailed { + /** The category of the ticket state */ + export const Category = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; + + /** + * A list of ticket types associated with a given ticket state. + */ + export interface TicketTypes { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket type attributes associated with a given ticket type. */ + data?: (Intercom.preview.TicketType | undefined)[]; + } +} + +/** + * A ticket type, used to define the data fields to be captured in a ticket. + */ +export interface TicketType { + /** String representing the object's type. Always has the value `ticket_type`. */ + type?: string; + /** The id representing the ticket type. */ + id?: string; + /** Category of the Ticket Type. */ + category?: TicketType.Category; + /** The name of the ticket type */ + name?: string; + /** The description of the ticket type */ + description?: string; + /** The icon of the ticket type */ + icon?: string; + /** The id of the workspace that the ticket type belongs to. */ + workspace_id?: string; + ticket_type_attributes?: Intercom.preview.TicketTypeAttributeList; + /** A list of ticket states associated with a given ticket type. */ + ticket_states?: TicketType.TicketStates; + /** Whether the ticket type is archived or not. */ + archived?: boolean; + /** The date and time the ticket type was created. */ + created_at?: number; + /** The date and time the ticket type was last updated. */ + updated_at?: number; +} + +export namespace TicketType { + /** Category of the Ticket Type. */ + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; + + /** + * A list of ticket states associated with a given ticket type. + */ + export interface TicketStates { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket states associated with a given ticket type. */ + data?: (Intercom.preview.TicketState | undefined)[]; + } +} diff --git a/src/api/resources/unstable/resources/visitors/client/Client.ts b/src/api/resources/preview/resources/visitors/client/Client.ts similarity index 80% rename from src/api/resources/unstable/resources/visitors/client/Client.ts rename to src/api/resources/preview/resources/visitors/client/Client.ts index 600ffecf..73f24150 100644 --- a/src/api/resources/unstable/resources/visitors/client/Client.ts +++ b/src/api/resources/preview/resources/visitors/client/Client.ts @@ -28,28 +28,28 @@ export class VisitorsClient { /** * You can fetch the details of a single visitor. * - * @param {Intercom.unstable.RetrieveVisitorWithUserIdRequest} request + * @param {Intercom.preview.RetrieveVisitorWithUserIdRequest} request * @param {VisitorsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.visitors.retrieveVisitorWithUserId({ + * await client.preview.visitors.retrieveVisitorWithUserId({ * user_id: "user_id" * }) */ public retrieveVisitorWithUserId( - request: Intercom.unstable.RetrieveVisitorWithUserIdRequest, + request: Intercom.preview.RetrieveVisitorWithUserIdRequest, requestOptions?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__retrieveVisitorWithUserId(request, requestOptions)); } private async __retrieveVisitorWithUserId( - request: Intercom.unstable.RetrieveVisitorWithUserIdRequest, + request: Intercom.preview.RetrieveVisitorWithUserIdRequest, requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { + ): Promise> { const { user_id: userId } = request; const _queryParams: Record = {}; _queryParams.user_id = userId; @@ -77,21 +77,18 @@ export class VisitorsClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.Visitor | undefined, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.Visitor | undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -114,17 +111,17 @@ export class VisitorsClient { * @param {Intercom.UpdateVisitorRequestOne} request * @param {VisitorsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.UnauthorizedError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.visitors.updateVisitor({ + * await client.preview.visitors.updateVisitor({ * "id": "6762f30c1bb69f9f2193bc5e", * "name": "Gareth Bale" * }) * * @example - * await client.unstable.visitors.updateVisitor({ + * await client.preview.visitors.updateVisitor({ * "user_id": "fail", * "name": "Christian Fail" * }) @@ -132,14 +129,14 @@ export class VisitorsClient { public updateVisitor( request?: Intercom.UpdateVisitorRequestOne, requestOptions?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateVisitor(request, requestOptions)); } private async __updateVisitor( request?: Intercom.UpdateVisitorRequestOne, requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -167,21 +164,18 @@ export class VisitorsClient { logging: this._options.logging, }); if (_response.ok) { - return { - data: _response.body as Intercom.unstable.Visitor | undefined, - rawResponse: _response.rawResponse, - }; + return { data: _response.body as Intercom.preview.Visitor | undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, @@ -201,13 +195,13 @@ export class VisitorsClient { * > * > If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers. * - * @param {Intercom.unstable.ConvertVisitorRequest} request + * @param {Intercom.preview.ConvertVisitorRequest} request * @param {VisitorsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.preview.UnauthorizedError} * * @example - * await client.unstable.visitors.convertVisitor({ + * await client.preview.visitors.convertVisitor({ * type: "user", * user: { * "email": "foo@bar.com" @@ -218,16 +212,16 @@ export class VisitorsClient { * }) */ public convertVisitor( - request: Intercom.unstable.ConvertVisitorRequest, + request: Intercom.preview.ConvertVisitorRequest, requestOptions?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__convertVisitor(request, requestOptions)); } private async __convertVisitor( - request: Intercom.unstable.ConvertVisitorRequest, + request: Intercom.preview.ConvertVisitorRequest, requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -255,14 +249,14 @@ export class VisitorsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.Contact, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.Contact, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.UnauthorizedError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); default: diff --git a/src/api/resources/preview/resources/visitors/client/index.ts b/src/api/resources/preview/resources/visitors/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/visitors/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/visitors/client/requests/ConvertVisitorRequest.ts b/src/api/resources/preview/resources/visitors/client/requests/ConvertVisitorRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/visitors/client/requests/ConvertVisitorRequest.ts rename to src/api/resources/preview/resources/visitors/client/requests/ConvertVisitorRequest.ts diff --git a/src/api/resources/unstable/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts b/src/api/resources/preview/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts rename to src/api/resources/preview/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts diff --git a/src/api/resources/unstable/resources/visitors/client/requests/index.ts b/src/api/resources/preview/resources/visitors/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/visitors/client/requests/index.ts rename to src/api/resources/preview/resources/visitors/client/requests/index.ts diff --git a/src/api/resources/preview/resources/visitors/index.ts b/src/api/resources/preview/resources/visitors/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/api/resources/preview/resources/visitors/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/unstable/resources/workflows/client/Client.ts b/src/api/resources/preview/resources/workflows/client/Client.ts similarity index 78% rename from src/api/resources/unstable/resources/workflows/client/Client.ts rename to src/api/resources/preview/resources/workflows/client/Client.ts index 9e14a53a..2ec15053 100644 --- a/src/api/resources/unstable/resources/workflows/client/Client.ts +++ b/src/api/resources/preview/resources/workflows/client/Client.ts @@ -30,32 +30,32 @@ export class WorkflowsClient { * * This endpoint is designed for EU Data Act compliance, allowing customers to export their workflow configurations. * - * {% admonition type="warning" name="Unstable API" %} - * This API is currently in the Unstable version. Its behavior may change in future releases. + * {% admonition type="info" name="Preview API" %} + * This endpoint is available in the Preview API version. We may make iterative improvements, including adding new fields or refining existing ones. * {% /admonition %} * - * @param {Intercom.unstable.ExportWorkflowRequest} request + * @param {Intercom.preview.ExportWorkflowRequest} request * @param {WorkflowsClient.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.preview.ForbiddenError} + * @throws {@link Intercom.preview.NotFoundError} * * @example - * await client.unstable.workflows.exportWorkflow({ + * await client.preview.workflows.exportWorkflow({ * id: "12345" * }) */ public exportWorkflow( - request: Intercom.unstable.ExportWorkflowRequest, + request: Intercom.preview.ExportWorkflowRequest, requestOptions?: WorkflowsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__exportWorkflow(request, requestOptions)); } private async __exportWorkflow( - request: Intercom.unstable.ExportWorkflowRequest, + request: Intercom.preview.ExportWorkflowRequest, requestOptions?: WorkflowsClient.RequestOptions, - ): Promise> { + ): Promise> { const { id } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -81,18 +81,18 @@ export class WorkflowsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.unstable.WorkflowExport, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.preview.WorkflowExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 403: - throw new Intercom.unstable.ForbiddenError( - _response.error.body as Intercom.unstable.Error_, + throw new Intercom.preview.ForbiddenError( + _response.error.body as Intercom.preview.Error_, _response.rawResponse, ); case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + throw new Intercom.preview.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/preview/resources/workflows/client/index.ts b/src/api/resources/preview/resources/workflows/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/preview/resources/workflows/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/workflows/client/requests/ExportWorkflowRequest.ts b/src/api/resources/preview/resources/workflows/client/requests/ExportWorkflowRequest.ts similarity index 100% rename from src/api/resources/unstable/resources/workflows/client/requests/ExportWorkflowRequest.ts rename to src/api/resources/preview/resources/workflows/client/requests/ExportWorkflowRequest.ts diff --git a/src/api/resources/unstable/resources/workflows/client/requests/index.ts b/src/api/resources/preview/resources/workflows/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/workflows/client/requests/index.ts rename to src/api/resources/preview/resources/workflows/client/requests/index.ts diff --git a/src/api/resources/preview/resources/workflows/index.ts b/src/api/resources/preview/resources/workflows/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/api/resources/preview/resources/workflows/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/preview/types/index.ts b/src/api/resources/preview/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/preview/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/preview/types/types.ts b/src/api/resources/preview/types/types.ts new file mode 100644 index 00000000..4defbc4c --- /dev/null +++ b/src/api/resources/preview/types/types.ts @@ -0,0 +1,4956 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../index.js"; + +export interface UnprocessableEntityErrorBody { + /** Validation messages keyed by the field they apply to, or `base` for conversation-level failures. */ + errors?: Record; +} + +/** + * A list of office hours schedules. + */ +export interface OfficeHoursScheduleList { + /** The type of the object - always `office_hours_schedule.list`. */ + type?: string; + /** An array of office hours schedules. */ + data?: Intercom.preview.OfficeHoursSchedule[]; +} + +/** + * A list of office hours exceptions. + */ +export interface OfficeHoursExceptionList { + /** The type of the object - always `office_hours_exception.list`. */ + type?: string; + /** An array of office hours exceptions. */ + data?: Intercom.preview.OfficeHoursException[]; +} + +export type Datetime = + /** + * A date and time following the ISO8601 notation. */ + | string + /** + * A date and time as UNIX timestamp notation. */ + | number; + +/** + * Activities performed by Admins. + */ +export interface ActivityLog { + /** The id representing the activity. */ + id?: string; + /** Details about the Admin involved in the activity. */ + performed_by?: ActivityLog.PerformedBy; + metadata?: Intercom.preview.ActivityLogMetadata; + /** The time the activity was created. */ + created_at?: number; + activity_type?: ActivityLog.ActivityType; + /** A sentence or two describing the activity. */ + activity_description?: string; +} + +export namespace ActivityLog { + /** + * Details about the Admin involved in the activity. + */ + export interface PerformedBy { + /** String representing the object's type. Always has the value `admin`. */ + type?: string; + /** The id representing the admin. */ + id?: string; + /** The email of the admin. */ + email?: string; + /** The IP address of the admin. */ + ip?: string; + } + + export const ActivityType = { + AdminConversationAssignmentLimitChange: "admin_conversation_assignment_limit_change", + AdminTicketAssignmentLimitChange: "admin_ticket_assignment_limit_change", + AdminAvatarChange: "admin_avatar_change", + AdminAwayModeChange: "admin_away_mode_change", + AdminDeletion: "admin_deletion", + AdminDeprovisioned: "admin_deprovisioned", + AdminImpersonationEnd: "admin_impersonation_end", + AdminImpersonationStart: "admin_impersonation_start", + AdminInviteChange: "admin_invite_change", + AdminInviteCreation: "admin_invite_creation", + AdminInviteDeletion: "admin_invite_deletion", + AdminLoginFailure: "admin_login_failure", + AdminLoginSuccess: "admin_login_success", + AdminLogout: "admin_logout", + AdminOccupancySettingChange: "admin_occupancy_setting_change", + AdminOccupancyStateChange: "admin_occupancy_state_change", + AdminPasswordResetRequest: "admin_password_reset_request", + AdminPasswordResetSuccess: "admin_password_reset_success", + AdminPermissionChange: "admin_permission_change", + AdminProvisioned: "admin_provisioned", + AdminTwoFactorAuthChange: "admin_two_factor_auth_change", + AdminUnauthorizedSignInMethod: "admin_unauthorized_sign_in_method", + AppAdminJoin: "app_admin_join", + AppAuthenticationMethodChange: "app_authentication_method_change", + AppDataDeletion: "app_data_deletion", + AppDataExport: "app_data_export", + AppGoogleSsoDomainChange: "app_google_sso_domain_change", + AppIdentityVerificationChange: "app_identity_verification_change", + AppNameChange: "app_name_change", + AppOutboundAddressChange: "app_outbound_address_change", + AppPackageInstallation: "app_package_installation", + AppPackageTokenRegeneration: "app_package_token_regeneration", + AppPackageUninstallation: "app_package_uninstallation", + AppTeamCreation: "app_team_creation", + AppTeamDeletion: "app_team_deletion", + AppTeamMembershipModification: "app_team_membership_modification", + AppTimezoneChange: "app_timezone_change", + AppWebhookCreation: "app_webhook_creation", + AppWebhookDeletion: "app_webhook_deletion", + ArticlesInMessengerEnabledChange: "articles_in_messenger_enabled_change", + BulkDelete: "bulk_delete", + BulkExport: "bulk_export", + CampaignDeletion: "campaign_deletion", + CampaignStateChange: "campaign_state_change", + ConversationPartDeletion: "conversation_part_deletion", + ConversationPdfExport: "conversation_pdf_export", + ConversationTopicChange: "conversation_topic_change", + ConversationTopicCreation: "conversation_topic_creation", + ConversationTopicDeletion: "conversation_topic_deletion", + CustomerFacingNameChange: "customer_facing_name_change", + HelpCenterSettingsChange: "help_center_settings_change", + InboundConversationsChange: "inbound_conversations_change", + InboxAccessChange: "inbox_access_change", + InboxBulkAction: "inbox_bulk_action", + MessageDeletion: "message_deletion", + MessageStateChange: "message_state_change", + MessengerLookAndFeelChange: "messenger_look_and_feel_change", + MessengerSearchRequiredChange: "messenger_search_required_change", + MessengerSpacesChange: "messenger_spaces_change", + OfficeHoursChange: "office_hours_change", + RoleChange: "role_change", + RoleCreation: "role_creation", + RoleDeletion: "role_deletion", + RulesetActivationTitlePreview: "ruleset_activation_title_preview", + RulesetCreation: "ruleset_creation", + RulesetDeletion: "ruleset_deletion", + SearchBrowseEnabledChange: "search_browse_enabled_change", + SearchBrowseRequiredChange: "search_browse_required_change", + SeatChange: "seat_change", + SeatRevoke: "seat_revoke", + SecuritySettingsChange: "security_settings_change", + TemporaryExpectationChange: "temporary_expectation_change", + UpfrontEmailCollectionChange: "upfront_email_collection_change", + WelcomeMessageChange: "welcome_message_change", + HideCsatFromAgentsSettingChange: "hide_csat_from_agents_setting_change", + } as const; + export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType]; +} + +/** + * A paginated list of activity logs. + */ +export interface ActivityLogList { + /** String representing the object's type. Always has the value `activity_log.list`. */ + type?: string; + pages?: Intercom.preview.CursorPages; + /** An array of activity logs */ + activity_logs?: (Intercom.preview.ActivityLog | undefined)[]; +} + +/** + * Additional data provided about Admin activity. + */ +export interface ActivityLogMetadata { + /** The way the admin signed in. */ + sign_in_method?: string; + /** The unique identifier for the contact which is provided by the Client. */ + external_id?: string; + /** The away mode status which is set to true when away and false when returned. */ + away_mode?: boolean; + /** The reason the Admin is away. */ + away_status_reason?: string; + /** Indicates if conversations should be reassigned while an Admin is away. */ + reassign_conversations?: boolean; + /** The action that initiated the status change. */ + source?: string; + /** Indicates if the status was changed automatically or manually. */ + auto_changed?: string; + /** The ID of the Admin who initiated the activity. */ + update_by?: number; + /** The name of the Admin who initiated the activity. */ + update_by_name?: string; + /** The state before the change. `idle` or `occupied`, and null when the Admin had not been classified yet. */ + previous_state?: string; + /** The state after the change. `idle` or `occupied`. */ + new_state?: string; + /** The inactivity window, in minutes, used to classify the Admin. */ + threshold_minutes?: number; + /** The time of the Admin's last recorded activity. */ + last_activity_at?: number; + /** Indicates the state was derived automatically rather than set by an Admin. */ + auto?: boolean; + /** The group of workspace settings the change belongs to, for example `teammate_occupancy` or `automatic_away_mode`. */ + setting_type?: string; + /** The settings altered by the change, keyed by setting name. Only settings whose value actually moved are included, so an unchanged setting is absent rather than present with equal values. */ + changes?: Record; + /** The conversation assignment limit value for an admin. */ + conversation_assignment_limit?: number; + /** The ticket assignment limit value for an admin. */ + ticket_assignment_limit?: number; +} + +export namespace ActivityLogMetadata { + export namespace Changes { + export interface Value { + /** The value before the change. */ + before?: unknown; + /** The value after the change. */ + after?: unknown; + } + } +} + +/** + * A list used to access other resources from a parent model. + */ +export interface AddressableList { + /** The addressable object type */ + type?: string; + /** The id of the addressable object */ + id?: string; + /** Url to get more company resources for this contact */ + url?: string; +} + +/** + * A list of admins associated with a given workspace. + */ +export interface AdminList { + /** String representing the object's type. Always has the value `admin.list`. */ + type?: string; + /** A list of admins associated with a given workspace. */ + admins?: (Intercom.preview.Admin | undefined)[]; +} + +/** + * Admin priority levels for the team + */ +export interface AdminPriorityLevel { + /** The primary admin ids for the team */ + primary_admin_ids?: number[]; + /** The secondary admin ids for the team */ + secondary_admin_ids?: number[]; +} + +/** + * The priority levels to set, naming only the teammates whose level is being set + */ +export interface AdminPriorityLevelRequest { + /** The ids of the teammates to make primary members of the team */ + primary_admin_ids?: number[]; + /** The ids of the teammates to make secondary members of the team */ + secondary_admin_ids?: number[]; +} + +/** + * Payload of the request to reply on behalf of an admin + */ +export interface AdminReplyConversationRequest { + message_type: AdminReplyConversationRequest.MessageType; + type: "admin"; + /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ + body?: string; + /** The id of the admin who is authoring the comment. */ + admin_id: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** The quick reply options to display to the end user. Must be present for quick_reply message types. */ + reply_options?: Intercom.preview.QuickReplyOption[]; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; + /** A list of files that will be added as attachments. You can include up to 10 files */ + attachment_files?: Intercom.preview.ConversationAttachmentFiles[]; + /** Option to disable notifications when replying to a conversation. */ + skip_notifications?: boolean; + /** When true, prevents the reply from waking a snoozed conversation. Applies to 'comment' and 'note' message types. The part is still created and visible in the conversation thread. */ + skip_unsnooze?: boolean; +} + +export namespace AdminReplyConversationRequest { + export const MessageType = { + Comment: "comment", + Note: "note", + QuickReply: "quick_reply", + } as const; + export type MessageType = (typeof MessageType)[keyof typeof MessageType]; +} + +/** + * Payload of the request to reply on behalf of an admin + */ +export interface AdminReplyTicketRequest { + /** The type of reply. Tracker tickets and back-office tickets that are not shared with the customer do not support `comment`; use `note` instead. */ + message_type: AdminReplyTicketRequest.MessageType; + type: "admin"; + /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ + body?: string; + /** The id of the admin who is authoring the comment. */ + admin_id: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** The quick reply options to display. Must be present for quick_reply message types. */ + reply_options?: AdminReplyTicketRequest.ReplyOptions.Item[]; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; + /** A list of files that will be added as attachments. You can include up to 10 files. If both attachment_files and attachment_urls are provided, attachment_files takes precedence. */ + attachment_files?: Intercom.preview.ConversationAttachmentFiles[]; + /** If set to true, the note will be cross-posted to all linked conversations. Only applicable to note message types on back-office tickets. */ + cross_post?: boolean; +} + +export namespace AdminReplyTicketRequest { + /** The type of reply. Tracker tickets and back-office tickets that are not shared with the customer do not support `comment`; use `note` instead. */ + export const MessageType = { + Comment: "comment", + Note: "note", + QuickReply: "quick_reply", + } as const; + export type MessageType = (typeof MessageType)[keyof typeof MessageType]; + export type ReplyOptions = ReplyOptions.Item[]; + + export namespace ReplyOptions { + export interface Item { + /** The text to display in this quick reply option. */ + text: string; + /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment ticket part that is created when a user clicks on this reply option. */ + uuid: string; + } + } +} + +/** + * Admins are the teammate accounts that have access to a workspace + */ +export interface AdminWithApp { + /** String representing the object's type. Always has the value `admin`. */ + type?: string; + /** The id representing the admin. */ + id?: string; + /** The name of the admin. */ + name?: string; + /** The email of the admin. */ + email?: string; + /** The job title of the admin. */ + job_title?: string; + /** Identifies if this admin is currently set in away mode. */ + away_mode_enabled?: boolean; + /** Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ + away_mode_reassign?: boolean; + /** Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ + has_inbox_seat?: boolean; + /** This is a list of ids of the teams that this admin is part of. */ + team_ids?: number[]; + /** This object represents the avatar associated with the admin. */ + avatar?: AdminWithApp.Avatar; + /** Identifies if this admin's email is verified. */ + email_verified?: boolean; + /** The role assigned to this admin. Only present if the admin has a role assigned. */ + role?: AdminWithApp.Role; + /** App that the admin belongs to. */ + app?: Intercom.preview.App; +} + +export namespace AdminWithApp { + /** + * This object represents the avatar associated with the admin. + */ + export interface Avatar { + /** This is a string that identifies the type of the object. It will always have the value `avatar`. */ + type?: string; + /** This object represents the avatar associated with the admin. */ + image_url?: string; + } + + /** + * The role assigned to this admin. Only present if the admin has a role assigned. + */ + export interface Role { + /** String representing the object's type. Always has the value `role`. */ + type?: string; + /** The id of the role. */ + id?: string; + /** The name of the role. */ + name?: string; + } +} + +/** + * An AI-generated subtopic under a topic. + */ +export interface AiSubtopic { + /** Always ai_subtopic. */ + type?: string; + /** The name of the subtopic. */ + name?: string; + /** The ID of the subtopic. */ + id?: number; +} + +/** + * An AI-generated topic assigned to the conversation. + */ +export interface AiTopic { + /** Always ai_topic. */ + type?: string; + /** The name of the AI-generated topic. */ + topic_name?: string; + /** The subtopics under this topic. */ + subtopics?: Intercom.preview.AiSubtopic[]; +} + +/** + * App is a workspace on Intercom + */ +export interface App { + /** */ + type?: string; + /** The id of the app. */ + id_code?: string; + /** The name of the app. */ + name?: string; + /** The Intercom region the app is located in. */ + region?: string; + /** The timezone of the region where the app is located. */ + timezone?: string; + /** When the app was created. */ + created_at?: number; + /** Whether or not the app uses identity verification. */ + identity_verification?: boolean; +} + +/** + * A paginated list of audience objects. + */ +export interface AudienceList { + /** The type of the object. */ + type?: "list"; + /** A list of audience objects. */ + data?: Intercom.preview.Audience[]; + /** The total number of audiences. */ + total_count?: number; + /** The current page number. */ + page?: number; + /** The number of results per page. */ + per_page?: number; + /** The total number of pages. */ + total_pages?: number; +} + +/** + * A condition used to filter contacts in an audience. + */ +export interface Predicate { + /** The attribute to filter on. */ + attribute?: string; + /** The type of the attribute. */ + type?: string; + /** The comparison operator. */ + comparison?: string; + /** The value to compare against. */ + value?: string; +} + +/** + * The Content of an Article. + */ +export interface ArticleContent { + /** The type of object - `article_content` . */ + type?: "article_content"; + /** The title of the article. */ + title?: string; + /** The description of the article. */ + description?: string; + /** The body of the article in HTML. */ + body?: string; + /** The body of the article in markdown. */ + body_markdown?: string; + /** The ID of the author of the article. */ + author_id?: number; + /** Whether the article is `published` or is a `draft` . */ + state?: ArticleContent.State; + /** The time when the article was created (seconds). */ + created_at?: number; + /** The time when the article was last updated (seconds). */ + updated_at?: number; + /** Whether this locale's published content has unpublished changes staged as a draft on top of its live content. Only returned on the `Preview` API version. */ + has_unpublished_changes?: boolean; + /** The time, in seconds, when this locale's staged draft was last edited, or `null` when there is no staged draft. Only returned on the `Preview` API version. */ + draft_updated_at?: number; + /** The URL of the article. */ + url?: string; + /** The list of audience IDs this article content is targeted to for Fin AI Agent. On multilingual help centers this field appears per-locale inside `translated_content`. On single-language help centers it appears at the article root level. Empty array means no audience targeting is set. */ + audience_ids?: number[]; + /** Whether the article is available for AI Chatbot. */ + ai_chatbot_availability?: boolean; + /** Whether the article is available for AI Copilot. */ + ai_copilot_availability?: boolean; + /** Whether the article is available for AI Sales Agent. */ + ai_sales_agent_availability?: boolean; + /** The ID of the teammate who created this content version. */ + created_by_id?: number; + /** The ID of the teammate who last updated this content version. */ + updated_by_id?: number; +} + +export namespace ArticleContent { + /** Whether the article is `published` or is a `draft` . */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * This will return a list of internal articles for the App. + */ +export interface InternalArticleList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.preview.CursorPages; + /** A count of the total number of internal articles. */ + total_count?: number; + /** An array of Internal Article objects */ + data?: Intercom.preview.InternalArticleListItem[]; +} + +/** + * Response returned when a folder is deleted + */ +export interface DeletedFolderObject { + /** The unique identifier for the deleted folder */ + id?: number; + /** The type of object - `folder`. */ + object?: "folder"; + /** Whether the folder was successfully deleted. */ + deleted?: boolean; +} + +/** + * This will return a list of articles for the App. + */ +export interface ArticleList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.preview.CursorPages; + /** A count of the total number of articles. */ + total_count?: number; + /** An array of Article objects */ + data?: Intercom.preview.ArticleListItem[]; +} + +/** + * The statistics of an article. + */ +export interface ArticleStatistics { + /** The type of object - `article_statistics`. */ + type?: "article_statistics"; + /** The number of total views the article has received. */ + views?: number; + /** The number of conversations started from the article. */ + conversions?: number; + /** The number of total reactions the article has received. */ + reactions?: number; + /** The percentage of happy reactions the article has received against other types of reaction. */ + happy_reaction_percentage?: number; + /** The percentage of neutral reactions the article has received against other types of reaction. */ + neutral_reaction_percentage?: number; + /** The percentage of sad reactions the article has received against other types of reaction. */ + sad_reaction_percentage?: number; + /** The number of conversations in which Fin AI Agent used this article, summed across all of the article's locales. */ + fin_involvements?: number; + /** The number of conversations Fin AI Agent resolved using this article, summed across all of the article's locales. */ + fin_resolutions?: number; + /** The percentage of Fin AI Agent involvements that resulted in a resolution (fin_resolutions / fin_involvements * 100). */ + fin_resolution_rate?: number; +} + +/** + * The Translated Content of an Article. The keys are the locale codes and the values are the translated content of the article. + */ +export interface ArticleTranslatedContent { + /** The type of object - article_translated_content. */ + type?: "article_translated_content"; + /** The content of the article in Arabic */ + ar?: Intercom.preview.ArticleContent; + /** The content of the article in Bulgarian */ + bg?: Intercom.preview.ArticleContent; + /** The content of the article in Bosnian */ + bs?: Intercom.preview.ArticleContent; + /** The content of the article in Catalan */ + ca?: Intercom.preview.ArticleContent; + /** The content of the article in Czech */ + cs?: Intercom.preview.ArticleContent; + /** The content of the article in Danish */ + da?: Intercom.preview.ArticleContent; + /** The content of the article in German */ + de?: Intercom.preview.ArticleContent; + /** The content of the article in Greek */ + el?: Intercom.preview.ArticleContent; + /** The content of the article in English */ + en?: Intercom.preview.ArticleContent; + /** The content of the article in Spanish */ + es?: Intercom.preview.ArticleContent; + /** The content of the article in Estonian */ + et?: Intercom.preview.ArticleContent; + /** The content of the article in Finnish */ + fi?: Intercom.preview.ArticleContent; + /** The content of the article in French */ + fr?: Intercom.preview.ArticleContent; + /** The content of the article in Hebrew */ + he?: Intercom.preview.ArticleContent; + /** The content of the article in Croatian */ + hr?: Intercom.preview.ArticleContent; + /** The content of the article in Hungarian */ + hu?: Intercom.preview.ArticleContent; + /** The content of the article in Indonesian */ + id?: Intercom.preview.ArticleContent; + /** The content of the article in Italian */ + it?: Intercom.preview.ArticleContent; + /** The content of the article in Japanese */ + ja?: Intercom.preview.ArticleContent; + /** The content of the article in Korean */ + ko?: Intercom.preview.ArticleContent; + /** The content of the article in Lithuanian */ + lt?: Intercom.preview.ArticleContent; + /** The content of the article in Latvian */ + lv?: Intercom.preview.ArticleContent; + /** The content of the article in Mongolian */ + mn?: Intercom.preview.ArticleContent; + /** The content of the article in Norwegian */ + nb?: Intercom.preview.ArticleContent; + /** The content of the article in Dutch */ + nl?: Intercom.preview.ArticleContent; + /** The content of the article in Polish */ + pl?: Intercom.preview.ArticleContent; + /** The content of the article in Portuguese (Portugal) */ + pt?: Intercom.preview.ArticleContent; + /** The content of the article in Romanian */ + ro?: Intercom.preview.ArticleContent; + /** The content of the article in Russian */ + ru?: Intercom.preview.ArticleContent; + /** The content of the article in Slovenian */ + sl?: Intercom.preview.ArticleContent; + /** The content of the article in Serbian */ + sr?: Intercom.preview.ArticleContent; + /** The content of the article in Swedish */ + sv?: Intercom.preview.ArticleContent; + /** The content of the article in Turkish */ + tr?: Intercom.preview.ArticleContent; + /** The content of the article in Vietnamese */ + vi?: Intercom.preview.ArticleContent; + /** The content of the article in Portuguese (Brazil) */ + "pt-BR"?: Intercom.preview.ArticleContent; + /** The content of the article in Chinese (China) */ + "zh-CN"?: Intercom.preview.ArticleContent; + /** The content of the article in Chinese (Taiwan) */ + "zh-TW"?: Intercom.preview.ArticleContent; +} + +/** + * A paginated list of versions of an article. + */ +export interface ArticleVersionList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.preview.CursorPages; + /** A count of the total number of versions. */ + total_count?: number; + /** An array of Article version summary objects. */ + data?: Intercom.preview.ArticleVersionSummary[]; +} + +/** + * Payload of the request to assign a conversation + */ +export interface AssignConversationRequest { + type: AssignConversationRequest.Type; + /** The id of the admin who is performing the action. */ + admin_id: string; + /** The `id` of the `admin` or `team` which will be assigned the conversation. A conversation can be assigned both an admin and a team.\nSet `0` if you want this assign to no admin or team (ie. Unassigned). */ + assignee_id: string; + /** Optionally you can send a response in the conversation when it is assigned. */ + body?: string; + /** When true, assigning a closed conversation leaves it closed instead of reopening it. No reopen event is recorded, so the conversation keeps its original close timestamp and the assignment does not count as a new closure in reporting. */ + skip_reopen?: boolean; +} + +export namespace AssignConversationRequest { + export const Type = { + Admin: "admin", + Team: "team", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * The participants of the conversation, returned after attaching or detaching a contact + */ +export interface ConversationParticipantsResponse { + /** The conversation participants after the change */ + customers: ConversationParticipantsResponse.Customers.Item[]; +} + +export namespace ConversationParticipantsResponse { + export type Customers = Customers.Item[]; + + export namespace Customers { + export interface Item { + /** The role of the participant. Can be "user" or "lead" */ + type: string; + /** The unique identifier for the participant */ + id: string; + } + } +} + +/** + * Per-admin activity metrics within a team. + */ +export interface TeamMetric { + type?: string; + /** The unique identifier for the admin. */ + admin_id?: string; + /** The number of open conversations assigned to the admin. */ + open?: number; + /** The number of idle conversations assigned to the admin. A conversation is idle when it has been open and waiting for an admin reply longer than the idle_threshold. */ + idle?: number; + /** The number of snoozed conversations assigned to the admin. */ + snoozed?: number; +} + +/** + * A list of team metrics. + */ +export interface TeamMetricList { + type?: string; + data?: Intercom.preview.TeamMetric[]; +} + +/** + * A paginated list of auth tokens. + */ +export interface AuthTokenList { + /** The type of object - `list`. */ + type?: "list"; + /** An array of auth token objects. */ + data?: Intercom.preview.AuthToken[]; + /** Pagination information. */ + pages?: AuthTokenList.Pages; +} + +export namespace AuthTokenList { + /** + * Pagination information. + */ + export interface Pages { + type?: "pages"; + /** The number of results per page. */ + per_page?: number; + /** Cursor for the next page of results. */ + next?: Pages.Next; + } + + export namespace Pages { + /** + * Cursor for the next page of results. + */ + export interface Next { + /** The cursor value to use for the next page. */ + starting_after?: string; + } + } +} + +export interface AwayStatusReason { + type?: string; + /** The unique identifier for the away status reason */ + id?: string; + /** The display text for the away status reason */ + label?: string; + /** The emoji associated with the status reason */ + emoji?: string; + /** The display order of the status reason */ + order?: number; + /** Whether the status reason has been soft deleted */ + deleted?: boolean; + /** The Unix timestamp when the status reason was created */ + created_at?: number; + /** The Unix timestamp when the status reason was last updated */ + updated_at?: number; +} + +/** + * A list of away status reasons. + */ +export interface AwayStatusReasonList { + /** The type of the object */ + type?: "list"; + /** A list of away status reason objects. */ + data?: Intercom.preview.AwayStatusReason[]; +} + +/** + * Payload of the request to close a conversation + */ +export interface CloseConversationRequest { + type: "admin"; + /** The id of the admin who is performing the action. */ + admin_id: string; + /** Optionally you can leave a message in the conversation to provide additional context to the user and other teammates. */ + body?: string; +} + +/** + * This will return a list of redirects for the help center. + */ +export interface HelpCenterRedirectList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.preview.CursorPages; + /** A count of the total number of redirects. */ + total_count?: number; + /** An array of help center redirect objects. */ + data?: Intercom.preview.HelpCenterRedirect[]; +} + +/** + * Response returned when a redirect is deleted. + */ +export interface DeletedHelpCenterRedirectObject { + /** The unique identifier for the redirect which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - `help_center_redirect` */ + object?: "help_center_redirect"; + /** Whether the redirect was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * This will return a list of Collections for the App. + */ +export interface CollectionList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.preview.CursorPages; + /** A count of the total number of collections. */ + total_count?: number; + /** An array of collection objects */ + data?: Intercom.preview.Collection[]; +} + +/** + * A list of Contact Objects + */ +export interface CompanyAttachedContacts { + /** The type of object - `list` */ + type?: "list"; + /** An array containing Contact Objects */ + data?: Intercom.preview.Contact[]; + /** The total number of contacts */ + total_count?: number; + pages?: Intercom.preview.CursorPages; +} + +/** + * A list of Segment Objects + */ +export interface CompanyAttachedSegments { + /** The type of object - `list` */ + type?: "list"; + /** An array containing Segment Objects */ + data?: Intercom.preview.Segment[]; +} + +/** + * This will return a list of companies for the App. + */ +export interface CompanyList { + /** The type of object - `list`. */ + type?: "list"; + pages?: Intercom.preview.CursorPages; + /** The total number of companies. */ + total_count?: number; + /** An array containing Company Objects. */ + data?: Intercom.preview.Company[]; +} + +/** + * Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies. + */ +export interface CompanyScroll { + /** The type of object - `list` */ + type?: "list"; + data?: Intercom.preview.Company[]; + pages?: Intercom.preview.CursorPages; + /** The total number of companies */ + total_count?: number; + /** The scroll parameter to use in the next request to fetch the next page of results. */ + scroll_param?: string; +} + +/** + * A record of a contact that was merged into another contact. + */ +export interface MergeHistoryItem { + /** The type of object. */ + type?: string; + /** The Intercom ID of the contact that was merged into this contact. */ + source_contact_id?: string; + /** The role of the contact that was merged in. */ + source_contact_role?: MergeHistoryItem.SourceContactRole; + /** (Unix timestamp in seconds) The time when the merge occurred. */ + merged_at?: number; +} + +export namespace MergeHistoryItem { + /** The role of the contact that was merged in. */ + export const SourceContactRole = { + Lead: "lead", + User: "user", + } as const; + export type SourceContactRole = (typeof SourceContactRole)[keyof typeof SourceContactRole]; +} + +/** + * A paginated list of merge history entries for a contact. + */ +export interface MergeHistoryList { + /** The type of object. */ + type?: "list"; + /** An array of merge history entries. */ + data?: Intercom.preview.MergeHistoryItem[]; + /** A cursor to pass as the `cursor` query parameter to fetch the next page of results. Absent when there are no more pages. */ + next_cursor?: string; + /** Whether there are more results to fetch. */ + has_more?: boolean; +} + +/** + * A list of Company Objects + */ +export interface ContactAttachedCompanies { + /** The type of object */ + type?: "list"; + /** An array containing Company Objects */ + companies?: Intercom.preview.Company[]; + /** The total number of companies associated to this contact */ + total_count?: number; + pages?: Intercom.preview.PagesLink; +} + +/** + * An object with metadata about companies attached to a contact . Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactCompanies { + /** An array of company data objects attached to the contact. */ + data?: Intercom.preview.CompanyData[]; + /** Url to get more company resources for this contact */ + url?: string; + /** Integer representing the total number of companies attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} + +/** + * An object containing data about the companies that a contact is associated with. + */ +export interface CompanyData { + /** The unique identifier for the company which is given by Intercom. */ + id?: string; + /** The type of the object. Always company. */ + type?: "company"; + /** The relative URL of the company. */ + url?: string; +} + +/** + * deleted contact object + */ +export interface ContactDeleted extends Intercom.preview.ContactReference { + /** Whether the contact is deleted or not. */ + deleted?: boolean; +} + +/** + * An activity event that occurred for a contact, such as creation, merge, or deletion. + */ +export interface ContactActivity { + /** Always contact_activity */ + type?: "contact_activity"; + /** The unique identifier for the activity event. */ + id?: string; + /** The type of activity event. */ + event_type?: ContactActivity.EventType; + /** The unique identifier for the contact the event relates to. */ + contact_id?: string; + /** The external identifier of the contact, if one is set. */ + external_id?: string; + /** The role of the contact at the time of the event, either user, lead, or visitor. */ + role?: string; + /** For merge events, the identifier of the contact that was merged away. */ + merge_source_id?: string; + /** For merge events, the identifier of the contact that was merged into. */ + merge_target_id?: string; + /** For failed events, the reason the activity did not succeed. */ + failure_reason?: string; + /** The time the activity event occurred, as a Unix timestamp in seconds. */ + created_at?: number; +} + +export namespace ContactActivity { + /** The type of activity event. */ + export const EventType = { + ContactCreated: "contact.created", + ContactRoleUpdated: "contact.role_updated", + ContactDeleted: "contact.deleted", + ContactMerged: "contact.merged", + ContactMergeFailed: "contact.merge_failed", + } as const; + export type EventType = (typeof EventType)[keyof typeof EventType]; +} + +/** + * A paginated list of contact activity events. + */ +export interface ContactActivityList { + /** Always list */ + type?: "list"; + /** The list of contact activity objects. */ + data?: Intercom.preview.ContactActivity[]; + /** Pagination information. */ + pages?: ContactActivityList.Pages; +} + +export namespace ContactActivityList { + /** + * Pagination information. + */ + export interface Pages { + type?: "pages"; + /** The number of results per page. */ + per_page?: number; + /** Cursor for the next page of results. */ + next?: Pages.Next; + } + + export namespace Pages { + /** + * Cursor for the next page of results. + */ + export interface Next { + /** The cursor value to use for the next page. */ + starting_after?: string; + } + } +} + +/** + * Contacts are your users in Intercom. + */ +export interface ContactList { + /** Always list */ + type?: "list"; + /** The list of contact objects */ + data?: Intercom.preview.Contact[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.preview.CursorPages; +} + +/** + * An object containing location meta data about a Intercom contact. + */ +export interface ContactLocation { + /** Always location */ + type?: string; + /** The country that the contact is located in */ + country?: string; + /** The overal region that the contact is located in */ + region?: string; + /** The city that the contact is located in */ + city?: string; +} + +/** + * An object containing notes meta data about the notes that a contact has. Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactNotes { + /** This object represents the notes attached to a contact. */ + data?: Intercom.preview.AddressableList[]; + /** Url to get more company resources for this contact */ + url?: string; + /** Int representing the total number of companyies attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} + +/** + * reference to contact object + */ +export interface ContactReference { + /** always contact */ + type?: "contact"; + /** The unique identifier for the contact which is given by Intercom. */ + id?: string; + /** The unique identifier for the contact which is provided by the Client. */ + external_id?: string; +} + +export interface ContactReplyBaseRequest { + message_type: "comment"; + type: "user"; + /** The text body of the comment. */ + body: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; + /** The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. */ + reply_options?: ContactReplyBaseRequest.ReplyOptions.Item[]; +} + +export namespace ContactReplyBaseRequest { + export type ReplyOptions = ReplyOptions.Item[]; + + export namespace ReplyOptions { + export interface Item { + /** The text of the chosen reply option. */ + text: string; + /** The unique identifier for the quick reply option selected. */ + uuid: string; + } + } +} + +export type ContactReplyConversationRequest = + | Intercom.preview.ContactReplyIntercomUserIdRequest + | Intercom.preview.ContactReplyEmailRequest + | Intercom.preview.ContactReplyUserIdRequest; + +/** + * Payload of the request to reply on behalf of a contact using their `email` + */ +export interface ContactReplyEmailRequest extends Intercom.preview.ContactReplyBaseRequest { + /** The email you have defined for the user. */ + email: string; + /** A list of files that will be added as attachments. */ + attachment_files?: Intercom.preview.ConversationAttachmentFiles[]; +} + +/** + * Payload of the request to reply on behalf of a contact using their `intercom_user_id` + */ +export interface ContactReplyIntercomUserIdRequest extends Intercom.preview.ContactReplyBaseRequest { + /** The identifier for the contact as given by Intercom. */ + intercom_user_id: string; + /** A list of files that will be added as attachments. */ + attachment_files?: Intercom.preview.ConversationAttachmentFiles[]; +} + +/** + * Payload of the request to reply on behalf of a contact using their `email` + */ +export interface ContactReplyTicketEmailRequest extends Intercom.preview.ContactReplyBaseRequest { + /** The email you have defined for the user. */ + email: string; +} + +/** + * Payload of the request to reply on behalf of a contact using their `intercom_user_id` + */ +export interface ContactReplyTicketIntercomUserIdRequest extends Intercom.preview.ContactReplyBaseRequest { + /** The identifier for the contact as given by Intercom. */ + intercom_user_id: string; +} + +export type ContactReplyTicketRequest = + | Intercom.preview.ContactReplyTicketIntercomUserIdRequest + | Intercom.preview.ContactReplyTicketUserIdRequest + | Intercom.preview.ContactReplyTicketEmailRequest; + +/** + * Payload of the request to reply on behalf of a contact using their `user_id` + */ +export interface ContactReplyTicketUserIdRequest extends Intercom.preview.ContactReplyBaseRequest { + /** The external_id you have defined for the contact. */ + user_id: string; +} + +/** + * Payload of the request to reply on behalf of a contact using their `user_id` + */ +export interface ContactReplyUserIdRequest extends Intercom.preview.ContactReplyBaseRequest { + /** The external_id you have defined for the contact. */ + user_id: string; + /** A list of files that will be added as attachments. You can include up to 10 files. */ + attachment_files?: Intercom.preview.ConversationAttachmentFiles[]; +} + +/** + * A list of segments objects attached to a specific contact. + */ +export interface ContactSegments { + /** The type of the object */ + type?: "list"; + /** Segment objects associated with the contact. */ + data?: Intercom.preview.Segment[]; +} + +/** + * An object containing social profiles that a contact has. + */ +export interface ContactSocialProfiles { + /** A list of social profiles objects associated with the contact. */ + data?: Intercom.preview.SocialProfile[]; +} + +/** + * An object containing Subscription Types meta data about the SubscriptionTypes that a contact has. + */ +export interface ContactSubscriptionTypes { + /** This object represents the subscriptions attached to a contact. */ + data?: Intercom.preview.AddressableList[]; + /** Url to get more subscription type resources for this contact */ + url?: string; + /** Int representing the total number of subscription types attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} + +/** + * An object containing tags meta data about the tags that a contact has. Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactTags { + /** This object represents the tags attached to a contact. */ + data?: Intercom.preview.AddressableList[]; + /** url to get more tag resources for this contact */ + url?: string; + /** Int representing the total number of tags attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} + +/** + * archived contact object + */ +export interface ContactArchived extends Intercom.preview.ContactReference { + /** Whether the contact is archived or not. */ + archived?: boolean; +} + +/** + * unarchived contact object + */ +export interface ContactUnarchived extends Intercom.preview.ContactReference { + /** Whether the contact is archived or not. */ + archived?: boolean; +} + +/** + * A contact that is no longer active, returned by the list deleted contacts endpoint. + */ +export interface DeletedContact { + /** always contact */ + type?: "contact"; + /** The unique identifier for the contact which is given by Intercom. */ + id?: string; + /** The unique identifier for the contact which is provided by the Client. `null` for permanently deleted contacts. */ + external_id?: string; + /** The contact's email address. `null` for permanently deleted contacts. */ + email?: string; + /** The role of the contact. */ + role?: DeletedContact.Role; + /** Why the contact is no longer active. */ + status?: DeletedContact.Status; + /** The id of the contact this one was merged into. Present only when `status` is `merged`. */ + merged_into_id?: string; + /** The time the contact record was last updated as a UNIX timestamp. This is a last-modified time, not a deletion time. */ + updated_at?: number; +} + +export namespace DeletedContact { + /** The role of the contact. */ + export const Role = { + User: "user", + Lead: "lead", + } as const; + export type Role = (typeof Role)[keyof typeof Role]; + /** Why the contact is no longer active. */ + export const Status = { + Archived: "archived", + Blocked: "blocked", + Merged: "merged", + PendingDeletion: "pending_deletion", + PermanentlyDeleted: "permanently_deleted", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; +} + +/** + * A paginated list of deleted contacts. + */ +export interface DeletedContactList { + /** Always list */ + type?: "list"; + /** The list of deleted contact objects. */ + data?: Intercom.preview.DeletedContact[]; + /** A count of the total number of deleted contacts. */ + total_count?: number; + /** Offset-based pagination metadata. */ + pages?: DeletedContactList.Pages; +} + +export namespace DeletedContactList { + /** + * Offset-based pagination metadata. + */ + export interface Pages { + type?: "pages"; + page?: number; + per_page?: number; + total_pages?: number; + } +} + +/** + * blocked contact object + */ +export interface ContactBlocked extends Intercom.preview.ContactReference { + /** Always true. */ + blocked?: boolean; +} + +/** + * Phase 1 envelope returned immediately after the request is enqueued. A future + * Preview release will replace this with a polling-friendly job resource that + * surfaces progress and per-item results (updated, unchanged, skipped, failed). + */ +export interface ContentBulkActionResponse { + type?: string; + status?: string; +} + +export interface ContentSourcesList { + type?: "content_source.list"; + /** The total number of content sources used by AI Agent in the conversation. */ + total_count?: number; + /** The content sources used by AI Agent in the conversation. */ + content_sources?: Intercom.preview.ContentSource[]; +} + +/** + * A single locale variant of a help center article returned from Knowledge Hub search. + */ +export interface ContentSearchArticleContentItem { + /** Always `article_content`. */ + type?: "article_content"; + /** The unique identifier of the article content. */ + id?: string; + /** The localized title of the article. */ + title?: string; + /** The locale of this article content. */ + locale?: string; +} + +/** + * A help center article result from Knowledge Hub search, with one nested `article_content` entry per locale. + */ +export interface ContentSearchArticleItem { + /** The unique identifier of the article. */ + id?: string; + /** The article's canonical title. */ + title?: string; + /** One entry per locale of the article. */ + contents?: Intercom.preview.ContentSearchArticleContentItem[]; +} + +/** + * The flat result shape returned from Knowledge Hub search for content snippets, external pages, uploaded files, and internal articles. + */ +export interface ContentSearchDefaultItem { + /** The unique identifier of the content item. */ + id?: string; + /** The display title of the content item. */ + title?: string; +} + +/** + * A paginated list of Knowledge Hub content results matching a search query. + */ +export interface ContentSearchResponse { + /** Always `list`. */ + type?: "list"; + /** Total number of results matching the query. */ + total_count?: number; + /** Pagination metadata, including links to neighbouring pages. */ + pages?: ContentSearchResponse.Pages; + /** The list of matched content items. Each item's `type` field determines its shape. */ + data?: Intercom.preview.ContentSearchResult[]; +} + +export namespace ContentSearchResponse { + /** + * Pagination metadata, including links to neighbouring pages. + */ + export interface Pages { + type?: "pages"; + /** The current page number. */ + page?: number; + /** Number of results per page. */ + per_page?: number; + /** Total number of pages of results. */ + total_pages?: number; + /** A link to the next page of results, or null when on the last page. */ + next?: string; + /** A link to the previous page of results, or null when on the first page. */ + prev?: string; + } +} + +/** + * A single search result. The `type` field discriminates between the flat shape used for snippets, external pages, files, and internal articles, and the nested shape used for help center articles. + */ +export type ContentSearchResult = + | Intercom.preview.ContentSearchResult.ContentSnippet + | Intercom.preview.ContentSearchResult.ExternalContent + | Intercom.preview.ContentSearchResult.FileSourceContent + | Intercom.preview.ContentSearchResult.InternalArticle + | Intercom.preview.ContentSearchResult.Article; + +export namespace ContentSearchResult { + export interface ContentSnippet extends Intercom.preview.ContentSearchDefaultItem { + type: "content_snippet"; + } + + export interface ExternalContent extends Intercom.preview.ContentSearchDefaultItem { + type: "external_content"; + } + + export interface FileSourceContent extends Intercom.preview.ContentSearchDefaultItem { + type: "file_source_content"; + } + + export interface InternalArticle extends Intercom.preview.ContentSearchDefaultItem { + type: "internal_article"; + } + + export interface Article extends Intercom.preview.ContentSearchArticleItem { + type: "article"; + } +} + +/** + * A paginated list of content snippets. + */ +export interface ContentSnippetList { + type?: "list"; + /** An array of content snippet objects. */ + data?: Intercom.preview.ContentSnippet[]; + /** The total number of content snippets. */ + total_count?: number; + /** The current page number. */ + page?: number; + /** The number of results per page. */ + per_page?: number; + /** The total number of pages. */ + total_pages?: number; +} + +/** + * The channel through which a conversation was originally initiated and its current channel. + */ +export interface ConversationChannel { + /** The channel through which the conversation was originally initiated. Possible values include `messenger`, `zendesk_sunshine`, `zendesk_ticket`, `twitter`, `email`. Returns `null` if channel data is unavailable. */ + initial?: string; + /** The current channel of the conversation. May differ from `initial` if the conversation was migrated between channels. Returns `null` if channel data is unavailable. */ + current?: string; +} + +/** + * A reference linking a conversation to a record in an external helpdesk or CRM system, surfaced for Fin Standalone workspaces. + */ +export interface ConversationExternalReference { + /** The type of external system the reference points to. Possible values include `zendesk_ticket`, `zendesk_sunshine_conversation`, `salesforce_case`, `salesforce_in_app_message_conversation`, `freshdesk_ticket`, `freshchat_conversation`, `hubspot_conversation`, `custom_helpdesk_conversation`, `api_conversation`. */ + type?: string; + /** The identifier of the record in the external system. Always serialized as a string, since some external IDs exceed 32-bit integer range. */ + id?: string; +} + +/** + * Properties of the attachment files in a conversation part + */ +export interface ConversationAttachmentFiles { + /** The content type of the file */ + content_type?: string; + /** The base64 encoded file data. */ + data?: string; + /** The name of the file. */ + name?: string; +} + +/** + * The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. + */ +export interface ConversationContacts { + /** */ + type?: "contact.list"; + /** The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. */ + contacts?: Intercom.preview.ContactReference[]; +} + +/** + * deleted conversation object + */ +export interface ConversationDeleted { + /** The unique identifier for the conversation. */ + id?: string; + /** always conversation */ + object?: "conversation"; + /** Whether the conversation is deleted or not. */ + deleted?: boolean; +} + +/** + * A paginated list of deleted conversation IDs. + */ +export interface DeletedConversationList { + /** String representing the object's type. Always has the value `conversations.list`. */ + type?: string; + /** The list of deleted conversation IDs. */ + conversations?: Intercom.preview.DeletedConversationItem[]; + /** Total number of items available. */ + total_count?: number; + pages?: Intercom.preview.PagesLink; +} + +/** + * An object containing information on the first users message. For a contact initiated message this will represent the users original message. + */ +export interface ConversationFirstContactReply { + /** */ + created_at?: number; + /** */ + type?: string; + /** */ + url?: string; +} + +/** + * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. + */ +export interface ConversationList { + /** Always conversation.list */ + type?: "conversation.list"; + /** The list of conversation objects */ + conversations?: Intercom.preview.ConversationListItem[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.preview.CursorPages; +} + +/** + * A Conversation Part represents a message in the conversation. + */ +export interface ConversationPart { + /** Always conversation_part */ + type?: string; + /** The id representing the conversation part. */ + id?: string; + /** The type of conversation part. On the Preview version a part type the API does not recognise is returned as `unknown`; on earlier versions those parts are returned as `comment`. Every value other than `unknown` is also accepted by the `include_part_types` and `exclude_part_types` query parameters when retrieving a conversation. */ + part_type?: string; + /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ + body?: string; + /** The time the conversation part was created. */ + created_at?: number; + /** The last time the conversation part was updated. */ + updated_at?: number; + /** The time the user was notified with the conversation part. */ + notified_at?: number; + /** The assignee this conversation_part assigned the conversation to, as a reference whose `type` is `admin`, `team` or `bot`. When the part unassigned the conversation, `type` is `nobody_admin` and `id` is `null`. Null when the part did not change the assignment, or when the assignee has since been deleted. */ + assigned_to?: Intercom.preview.Reference; + /** The id of the teammate that this conversation_part assigned the conversation to, or 0 if the part removed the teammate. Null or absent when the part did not change the teammate, including an unassignment that did not name which assignee it cleared. A bot is reported here, because assignment treats anything that is not a team as a teammate. */ + admin_assignee_id?: number; + /** The id of the team that this conversation_part assigned the conversation to, or 0 if the part removed the team. Null or absent when the part did not change the team, including an unassignment that did not name which assignee it cleared. A part can assign a team and a teammate at the same time, for example when the team uses Round Robin distribution and the teammate is resolved inline. In that case assigned_to reports only the teammate, and these two fields report each assignee separately. */ + team_assignee_id?: number; + author?: Intercom.preview.ConversationPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.preview.PartAttachment[]; + /** The external id of the conversation part */ + external_id?: string; + /** Whether or not the conversation part has been redacted. */ + redacted?: boolean; + email_message_metadata?: Intercom.preview.EmailMessageMetadata; + metadata?: Intercom.preview.ConversationPartMetadata; + /** Indicates the current state of conversation when the conversation part was created. */ + state?: ConversationPart.State; + /** A list of tags objects associated with the conversation part. */ + tags?: Intercom.preview.TagBasic[]; + event_details?: Intercom.preview.EventDetails; + /** The app package code if this part was created via API. null if the part was not created via API. */ + app_package_code?: string; + /** A map of the reply text keyed by locale code. Only present on the Preview API version and backs the `conversation.admin.replied.translated` webhook topic. The special `original` key holds the source locale code of the reply; every other key is a locale code whose value is the reply text translated into that locale, as HTML in the same format as `body`. The `body` field is unchanged and always stays in the original source language. Available in the Preview API version only (set `Intercom-Version: Preview`). This webhook topic is not sent for every translated reply: it is suppressed when the reply's `body` contains any text outside an HTML block element, which includes plain-text replies created through the REST API. Wrap the body in `

`, `

`, or another supported block element to avoid this. */ + translations?: Record; +} + +export namespace ConversationPart { + /** Indicates the current state of conversation when the conversation part was created. */ + export const State = { + Open: "open", + Closed: "closed", + Snoozed: "snoozed", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * The author of this conversation part. Can be a Contact, Admin, or Bot. + */ +export interface ConversationPartAuthor { + /** The type of the author */ + type?: string; + /** The id of the author */ + id?: string; + /** The name of the author */ + name?: string; + /** The email of the author */ + email?: string; + /** If this conversation part was sent by the AI Agent */ + from_ai_agent?: boolean; + /** If this conversation part body was generated by the AI Agent */ + is_ai_answer?: boolean; +} + +/** + * A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. + */ +export interface ConversationParts { + /** */ + type?: "conversation_part.list"; + /** A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. */ + conversation_parts?: Intercom.preview.ConversationPart[]; + /** A count of the conversation parts in this response, after any `include_part_types` or `exclude_part_types` filter has been applied. This is not the conversation's total part count. */ + total_count?: number; +} + +/** + * Metadata for a conversation part + */ +export interface ConversationPartMetadata { + /** The quick reply options sent by the Admin or bot, presented in this conversation part. */ + quick_reply_options?: ConversationPartMetadata.QuickReplyOptions.Item[]; + /** The unique identifier for the quick reply option that was clicked by the end user. */ + quick_reply_uuid?: string; +} + +export namespace ConversationPartMetadata { + export type QuickReplyOptions = QuickReplyOptions.Item[]; + + export namespace QuickReplyOptions { + export interface Item extends Intercom.preview.QuickReplyOption { + /** The translations for the quick reply option. */ + translations?: Record; + } + } +} + +/** + * The Conversation Rating object which contains information on the rating and/or remark added by a Contact and the Admin assigned to the conversation. + */ +export interface ConversationRating { + /** The rating, between 1 and 5, for the conversation. */ + rating?: number; + /** An optional field to add a remark to correspond to the number rating */ + remark?: string; + /** The time the rating was requested in the conversation being rated. */ + created_at?: number; + /** The time the rating was last updated. */ + updated_at?: number; + contact?: Intercom.preview.ContactReference; + teammate?: Intercom.preview.Reference; +} + +/** + * Details of first response time of assigned team in seconds. + */ +export interface ConversationResponseTime { + /** Id of the assigned team. */ + team_id?: number; + /** Name of the assigned Team, null if team does not exist, Unassigned if no team is assigned. */ + team_name?: string; + /** First response time of assigned team in seconds. */ + response_time?: number; +} + +/** + * The first message or event that started this conversation. Describes the origin and who initiated it. + */ +export interface ConversationSource { + /** The origin of this conversation. */ + type?: string; + /** The id of the source message. */ + id?: string; + /** How the conversation was initiated. */ + delivered_as?: string; + /** The recipients of the source message. Only present for email conversations. */ + recipients?: ConversationSource.Recipients.Item[]; + /** The Reply-To header addresses of the source message, where a reply will be routed. Can differ from the sender's From address. Only present for email conversations. */ + reply_to?: ConversationSource.ReplyTo.Item[]; + /** The message subject. Only present for email conversations. */ + subject?: string; + /** The message body, which may contain HTML. */ + body?: string; + author?: Intercom.preview.ConversationSourceAuthor; + /** A list of attachments on the source message. */ + attachments?: Intercom.preview.PartAttachment[]; + /** The URL where the conversation was started. */ + url?: string; + /** Whether or not the source content has been redacted. */ + redacted?: boolean; + email_message_metadata?: Intercom.preview.SourceEmailMessageMetadata; +} + +export namespace ConversationSource { + export type Recipients = Recipients.Item[]; + + export namespace Recipients { + export interface Item { + /** The recipient type. One of `to`, `cc`, or `bcc`. */ + type?: string; + /** The recipient email address. */ + email?: string; + /** The reason this recipient was dropped, if applicable. */ + drop_reason?: string; + } + } + + export type ReplyTo = ReplyTo.Item[]; + + export namespace ReplyTo { + export interface Item { + /** The Reply-To email address. */ + email?: string; + /** The display name associated with the Reply-To address. */ + name?: string; + } + } +} + +/** + * The author who started the conversation. Can be a Contact, Admin, or Bot. + */ +export interface ConversationSourceAuthor { + /** The type of the author. */ + type?: string; + /** The id of the author. */ + id?: string; + /** The name of the author. */ + name?: string; + /** The email of the author. */ + email?: string; +} + +/** + * A Statistics object containing all information required for reporting, with timestamps and calculated metrics. + */ +export interface ConversationStatistics { + /** */ + type?: string; + /** Duration until last assignment before first admin reply. In seconds. */ + time_to_assignment?: number; + /** Duration until first admin reply. Subtracts out of business hours. In seconds. */ + time_to_admin_reply?: number; + /** Duration until conversation was closed first time. Subtracts out of business hours. In seconds. */ + time_to_first_close?: number; + /** Duration until conversation was closed last time. Subtracts out of business hours. In seconds. */ + time_to_last_close?: number; + /** Median based on all admin replies after a contact reply. Subtracts out of business hours. In seconds. */ + median_time_to_reply?: number; + /** Time of first text conversation part from a contact. */ + first_contact_reply_at?: number; + /** Time of first assignment after first_contact_reply_at. */ + first_assignment_at?: number; + /** Time of first admin reply after first_contact_reply_at. */ + first_admin_reply_at?: number; + /** Time of first close after first_contact_reply_at. */ + first_close_at?: number; + /** Time of last assignment after first_contact_reply_at. */ + last_assignment_at?: number; + /** Time of first admin reply since most recent assignment. */ + last_assignment_admin_reply_at?: number; + /** Time of the last conversation part from a contact. */ + last_contact_reply_at?: number; + /** Time of the last conversation part from an admin. */ + last_admin_reply_at?: number; + /** Time of the last conversation close. */ + last_close_at?: number; + /** The last admin who closed the conversation. Returns a reference to an Admin object. */ + last_closed_by_id?: string; + /** Number of reopens after first_contact_reply_at. */ + count_reopens?: number; + /** Number of assignments after first_contact_reply_at. */ + count_assignments?: number; + /** Total number of conversation parts. */ + count_conversation_parts?: number; + /** An array of conversation response time objects */ + assigned_team_first_response_time?: Intercom.preview.ConversationResponseTime[]; + /** An array of conversation response time objects within office hours */ + assigned_team_first_response_time_in_office_hours?: Intercom.preview.ConversationResponseTime[]; + /** Time from conversation assignment to conversation close in seconds. */ + handling_time?: number; + /** Adjusted handling time for conversation in seconds. This is the active handling time excluding idle periods when teammates are not actively working on the conversation. */ + adjusted_handling_time?: number; +} + +/** + * The list of teammates who participated in the conversation (wrote at least one conversation part). + */ +export interface ConversationTeammates { + /** The type of the object - `admin.list`. */ + type?: string; + /** The list of teammates who participated in the conversation (wrote at least one conversation part). */ + teammates?: Intercom.preview.Reference[]; +} + +/** + * You can create an Article + */ +export interface CreateArticleRequest { + /** The title of the article.For multilingual articles, this will be the title of the default language's content. */ + title: string; + /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ + description?: string; + /** The content of the article in HTML. For multilingual articles, this will be the body of the default language's content. Mutually exclusive with `body_markdown`. */ + body?: string; + /** The content of the article in markdown. For multilingual articles, this will be the body of the default language's content. An alternative to `body` — you can provide content as markdown instead of HTML. Mutually exclusive with `body`. */ + body_markdown?: string; + /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ + author_id: number; + /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ + state?: CreateArticleRequest.State; + /** The id of the article's parent collection or section. An article without this field stands alone. */ + parent_id?: number; + /** The type of parent, which can either be a `collection` or `section`. */ + parent_type?: string; + /** The ids of the parent collections to place this article in. Send an empty array to leave the article without a collection. When provided, this takes precedence over `parent_id` and `parent_type`. */ + parent_ids?: number[]; + translated_content?: Intercom.preview.ArticleTranslatedContent; + /** The ID of the folder to place this article in, or null to leave it without a folder. */ + folder_id?: number; + /** The list of audience IDs to assign to this article for Fin AI Agent targeting. Sending a top-level `audience_ids` broadcasts the same set to every locale. For per-locale targeting, use `translated_content..audience_ids` instead. Sending both top-level and per-locale in the same request causes top-level to win. Unknown audience IDs return a 404 error. No partial commit occurs. */ + audience_ids?: number[]; + /** Whether the article should be available for AI Chatbot (Fin). For multilingual articles, this sets the default language's availability. */ + ai_chatbot_availability?: boolean; + /** Whether the article should be available for AI Copilot. For multilingual articles, this sets the default language's availability. */ + ai_copilot_availability?: boolean; + /** Whether the article should be available for AI Sales Agent. For multilingual articles, this sets the default language's availability. */ + ai_sales_agent_availability?: boolean; + /** ISO 8601 timestamp at which to schedule a future publish of the article. When set together with `state: "published"`, the article is scheduled instead of published immediately. Setting `null` cancels a pending publish schedule. Timestamps in the past or equal to the current time are rejected with 400 `parameter_invalid` — the value must be strictly in the future. Combining with `state: "draft"` returns 400 `parameter_invalid`. Sending in the same request as `scheduled_unpublish_at` returns 400 — only one pending schedule per article. Empty string returns 400 `parameter_invalid`. */ + scheduled_publish_at?: string; + /** ISO 8601 timestamp at which to schedule a future unpublish of the article. Setting `null` cancels a pending unpublish schedule. Timestamps in the past or equal to the current time are rejected with 400 `parameter_invalid` — the value must be strictly in the future. Rejected with 400 `parameter_invalid` if the article has never been published. Sending in the same request as `scheduled_publish_at` returns 400 — only one pending schedule per article. Empty string returns 400 `parameter_invalid`. */ + scheduled_unpublish_at?: string; +} + +export namespace CreateArticleRequest { + /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * You can create an Internal Article + */ +export interface CreateInternalArticleRequest { + /** The title of the article. */ + title: string; + /** The content of the article in HTML. Mutually exclusive with `body_markdown`. */ + body?: string; + /** The content of the article in markdown. An alternative to `body` — you can provide content as markdown instead of HTML. Mutually exclusive with `body`. */ + body_markdown?: string; + /** The id of the author of the article. */ + author_id: number; + /** The id of the owner of the article. */ + owner_id: number; + /** The ID of the folder to place this article in, or null to leave it without a folder. */ + folder_id?: number; + /** The list of audience IDs to target this internal article to for Fin AI Agent. Pass an empty array or omit the field for no audience targeting. Unknown audience IDs return a `404` error with no partial commit. */ + audience_ids?: number[]; + /** Whether the internal article should be available for AI Chatbot (Fin). Defaults to false. */ + ai_chatbot_availability?: boolean; + /** Whether the internal article should be available for AI Copilot. Defaults to false. */ + ai_copilot_availability?: boolean; + /** Whether the internal article should be available for AI Sales Agent. Defaults to false. */ + ai_sales_agent_availability?: boolean; +} + +/** + * + */ +export type CreateDataAttributeRequest = + | { + data_type?: "options" | undefined; + options: { + value?: string | undefined; + }[]; + } + | { + data_type?: ("string" | "integer" | "float" | "boolean" | "datetime" | "date") | undefined; + }; + +/** + * You can create a message + */ +export type CreateMessageRequest = unknown | undefined; + +/** + * A recipient of a message + */ +export interface Recipient { + /** The role associated to the contact - `user` or `lead`. */ + type: Recipient.Type; + /** The identifier for the contact which is given by Intercom. */ + id: string; +} + +export namespace Recipient { + /** The role associated to the contact - `user` or `lead`. */ + export const Type = { + User: "user", + Lead: "lead", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * You can create or update a Company + */ +export interface CreateOrUpdateCompanyRequest { + /** The name of the Company */ + name?: string; + /** The company id you have defined for the company. Can't be updated */ + company_id?: string; + /** The name of the plan you have associated with the company. */ + plan?: string; + /** The number of employees in this company. */ + size?: number; + /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ + website?: string; + /** The industry that this company operates in. */ + industry?: string; + /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ + custom_attributes?: Record; + /** The time the company was created by you. */ + remote_created_at?: number; + /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ + monthly_spend?: number; + /** Set to true to update the company's last seen time to now. */ + update_last_request_at?: boolean; +} + +/** + * You can create or update an existing tag. + */ +export interface CreateOrUpdateTagRequest { + /** The name of the tag, which will be created if not found, or the new name for the tag if this is an update request. Names are case insensitive. */ + name: string; + /** The id of tag to updates. */ + id?: string; +} + +/** + * You can create an phone switch + */ +export interface CreatePhoneSwitchRequest { + /** Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. */ + phone: string; + custom_attributes?: Intercom.preview.CustomAttributes; +} + +export type CreateTicketReplyWithCommentRequest = + | Intercom.preview.ContactReplyTicketRequest + | Intercom.preview.AdminReplyTicketRequest; + +/** + * You can create a Ticket + */ +export interface CreateTicketRequestBody { + /** The ID of the type of ticket you want to create */ + ticket_type_id: string; + /** The list of contacts (users or leads) affected by this ticket. Currently only one is allowed */ + contacts: CreateTicketRequestBody.Contacts.Item[]; + /** + * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: + * - conversation | back-office ticket + * - customer tickets | non-shared back-office ticket + * - conversation | tracker ticket + * - customer ticket | tracker ticket + */ + conversation_to_link_id?: string; + /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom */ + company_id?: string; + /** The time the ticket was created. If not provided, the current time will be used. */ + created_at?: number; + assignment?: CreateTicketRequestBody.Assignment; +} + +export namespace CreateTicketRequestBody { + export type Contacts = Contacts.Item[]; + + export namespace Contacts { + export type Item = + | { + id: string; + } + | { + external_id: string; + } + | { + email: string; + }; + } + + export interface Assignment { + /** The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. */ + admin_assignee_id?: string; + /** The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned. */ + team_assignee_id?: string; + } +} + +/** + * The request payload for creating a ticket type. + * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) + */ +export interface CreateTicketTypeRequest { + /** The name of the ticket type. */ + name: string; + /** The description of the ticket type. */ + description?: string; + /** Category of the Ticket Type. */ + category?: CreateTicketTypeRequest.Category; + /** The icon of the ticket type. */ + icon?: string; + /** Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute. */ + is_internal?: boolean; +} + +export namespace CreateTicketTypeRequest { + /** Category of the Ticket Type. */ + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; +} + +/** + * Cursor-based pagination is a technique used in the Intercom API to navigate through large amounts of data. + * A "cursor" or pointer is used to keep track of the current position in the result set, allowing the API to return the data in small chunks or "pages" as needed. + */ +export interface CursorPages { + /** the type of object `pages`. */ + type?: "pages"; + /** The current page */ + page?: number; + next?: Intercom.preview.StartingAfterPaging; + /** Number of results per page */ + per_page?: number; + /** Total number of pages */ + total_pages?: number; +} + +/** + * A paginated list of calls. + */ +export interface CallList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of calls. */ + data?: Intercom.preview.Call[]; + /** Total number of items available. */ + total_count?: number; + pages?: Intercom.preview.CursorPages; +} + +/** + * An object containing the different custom attributes associated to the conversation as key-value pairs. For relationship attributes the value will be a list of custom object instance models. System-defined attributes such as "CX Score rating" and "CX Score explanation" may also be included. + */ +export type CustomAttributes = Record; + +export namespace CustomAttributes { + export type Value = string | number | Intercom.preview.Datetime | Intercom.preview.CustomObjectInstanceList; +} + +/** + * deleted custom object instance object + */ +export interface CustomObjectInstanceDeleted { + /** The unique identifier of the Custom Object type that defines the structure of the Custom Object instance. */ + object?: string; + /** The Intercom defined id representing the Custom Object instance. */ + id?: string; + /** Whether the Custom Object instance is deleted or not. */ + deleted?: boolean; +} + +/** + * The list of associated custom object instances for a given reference attribute on the parent object. + */ +export interface CustomObjectInstanceList { + type?: string; + /** The list of associated custom object instances for a given reference attribute on the parent object. */ + instances?: (Intercom.preview.CustomObjectInstance | undefined)[]; +} + +export type CustomerRequest = + | { + intercom_user_id: string; + } + | { + user_id: string; + } + | { + email: string; + }; + +/** + * A list of all data attributes belonging to a workspace for contacts or companies. + */ +export interface DataAttributeList { + /** The type of the object */ + type?: "list"; + /** A list of data attributes */ + data?: Intercom.preview.DataAttribute[]; +} + +export interface ConversationAttributeBase { + /** Value is `conversation_attribute`. */ + type?: "conversation_attribute"; + /** The unique identifier for the conversation attribute. */ + id?: number; + /** Name of the attribute. */ + name?: string; + /** Readable description of the attribute. */ + description?: string; + /** Whether this attribute is required. */ + required?: boolean; + /** Team IDs that can see this attribute. Empty array means all teams. */ + visible_to_team_ids?: string[]; + /** Whether this attribute is archived. */ + archived?: boolean; + /** The time the attribute was created as a UTC Unix timestamp. */ + created_at?: number; + /** The time the attribute was last updated as a UTC Unix timestamp. */ + updated_at?: number; + /** ID of the admin who created the attribute. */ + admin_id?: string; +} + +export interface ConversationAttributeStringType extends Intercom.preview.ConversationAttributeBase { + /** Whether this string attribute is multiline. */ + multiline?: boolean; +} + +export interface ConversationAttributeIntegerType extends Intercom.preview.ConversationAttributeBase {} + +export interface ConversationAttributeListType extends Intercom.preview.ConversationAttributeBase { + /** Predefined options for this attribute. Each option has a unique UUID used to identify it in the options management endpoints. */ + options?: Intercom.preview.ConversationAttributeOption[]; +} + +export interface ConversationAttributeDecimalType extends Intercom.preview.ConversationAttributeBase {} + +export interface ConversationAttributeBooleanType extends Intercom.preview.ConversationAttributeBase {} + +export interface ConversationAttributeDatetimeType extends Intercom.preview.ConversationAttributeBase {} + +export interface ConversationAttributeRelationshipType extends Intercom.preview.ConversationAttributeBase { + /** Reference configuration for related objects. */ + reference?: ConversationAttributeRelationshipType.Reference; +} + +export namespace ConversationAttributeRelationshipType { + /** + * Reference configuration for related objects. + */ + export interface Reference { + /** The cardinality of the relationship: `one` or `many`. */ + type?: Reference.Type; + /** The ID of the related custom object type. */ + object_type_id?: string; + } + + export namespace Reference { + /** The cardinality of the relationship: `one` or `many`. */ + export const Type = { + One: "one", + Many: "many", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } +} + +export interface ConversationAttributeFilesType extends Intercom.preview.ConversationAttributeBase {} + +/** + * A list of all conversation attributes belonging to a workspace. + */ +export interface ConversationAttributeList { + /** The type of the object. */ + type?: "list"; + /** A list of conversation attributes. */ + data?: Intercom.preview.ConversationAttribute[]; +} + +/** + * A single option on a list-type conversation attribute. + */ +export interface ConversationAttributeOption { + /** The unique UUID identifier for this option. Use this value as `option_id` in the options management endpoints. */ + id?: string; + /** The display label for the option. */ + label?: string; + /** Whether this option is archived (soft-deleted). */ + archived?: boolean; +} + +/** + * Payload for adding a new option to a list-type conversation attribute. + */ +export interface CreateConversationAttributeOptionRequestBody { + /** The label for the new option. */ + label: string; +} + +export interface CreateConversationAttributeRequestBase { + /** Name of the attribute. */ + name: string; + /** Readable description of the attribute. */ + description?: string; + /** Whether this attribute is required. */ + required?: boolean; + /** Team IDs that can see this attribute. Empty array means all teams. */ + visible_to_team_ids?: string[]; +} + +export interface CreateConversationAttributeStringRequest + extends Intercom.preview.CreateConversationAttributeRequestBase { + /** Whether this string attribute is multiline. */ + multiline?: boolean; +} + +export interface CreateConversationAttributeIntegerRequest + extends Intercom.preview.CreateConversationAttributeRequestBase {} + +export interface CreateConversationAttributeListRequest + extends Intercom.preview.CreateConversationAttributeRequestBase { + /** Initial options for this list attribute. Each option must have a `label`. */ + options?: Intercom.preview.CreateConversationAttributeOptionRequestBody[]; +} + +export interface CreateConversationAttributeDecimalRequest + extends Intercom.preview.CreateConversationAttributeRequestBase {} + +export interface CreateConversationAttributeBooleanRequest + extends Intercom.preview.CreateConversationAttributeRequestBase {} + +export interface CreateConversationAttributeDatetimeRequest + extends Intercom.preview.CreateConversationAttributeRequestBase {} + +export interface CreateConversationAttributeRelationshipRequest + extends Intercom.preview.CreateConversationAttributeRequestBase { + /** Reference configuration for related objects. */ + reference?: CreateConversationAttributeRelationshipRequest.Reference; +} + +export namespace CreateConversationAttributeRelationshipRequest { + /** + * Reference configuration for related objects. + */ + export interface Reference { + /** The cardinality of the relationship: `one` or `many`. */ + type: Reference.Type; + /** The ID of the related custom object type. */ + object_type_id?: string; + } + + export namespace Reference { + /** The cardinality of the relationship: `one` or `many`. */ + export const Type = { + One: "one", + Many: "many", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } +} + +export interface CreateConversationAttributeFilesRequest + extends Intercom.preview.CreateConversationAttributeRequestBase {} + +/** + * Payload for creating a new conversation attribute. + */ +export type CreateConversationAttributeRequest = + | Intercom.preview.CreateConversationAttributeRequest.String + | Intercom.preview.CreateConversationAttributeRequest.Integer + | Intercom.preview.CreateConversationAttributeRequest.List + | Intercom.preview.CreateConversationAttributeRequest.Decimal + | Intercom.preview.CreateConversationAttributeRequest.Boolean + | Intercom.preview.CreateConversationAttributeRequest.Datetime + | Intercom.preview.CreateConversationAttributeRequest.Relationship + | Intercom.preview.CreateConversationAttributeRequest.Files; + +export namespace CreateConversationAttributeRequest { + export interface String extends Intercom.preview.CreateConversationAttributeStringRequest { + data_type: "string"; + } + + export interface Integer extends Intercom.preview.CreateConversationAttributeIntegerRequest { + data_type: "integer"; + } + + export interface List extends Intercom.preview.CreateConversationAttributeListRequest { + data_type: "list"; + } + + export interface Decimal extends Intercom.preview.CreateConversationAttributeDecimalRequest { + data_type: "decimal"; + } + + export interface Boolean extends Intercom.preview.CreateConversationAttributeBooleanRequest { + data_type: "boolean"; + } + + export interface Datetime extends Intercom.preview.CreateConversationAttributeDatetimeRequest { + data_type: "datetime"; + } + + export interface Relationship extends Intercom.preview.CreateConversationAttributeRelationshipRequest { + data_type: "relationship"; + } + + export interface Files extends Intercom.preview.CreateConversationAttributeFilesRequest { + data_type: "files"; + } +} + +/** + * A paginated list of data connector execution results. + */ +export interface DataConnectorExecutionResultList { + /** The type of object - `list`. */ + type?: "list"; + /** An array of execution result objects. */ + data?: Intercom.preview.DataConnectorExecutionResult[]; + /** Pagination information. */ + pages?: DataConnectorExecutionResultList.Pages; +} + +export namespace DataConnectorExecutionResultList { + /** + * Pagination information. + */ + export interface Pages { + type?: "pages"; + /** The number of results per page. */ + per_page?: number; + /** Cursor for the next page of results. */ + next?: Pages.Next; + } + + export namespace Pages { + /** + * Cursor for the next page of results. + */ + export interface Next { + /** The cursor value to use for the next page. */ + starting_after?: string; + } + } +} + +/** + * A paginated list of data connectors. + */ +export interface DataConnectorList { + /** The type of object - `list`. */ + type?: "list"; + /** An array of data connector objects. */ + data?: Intercom.preview.DataConnector[]; + /** Pagination information. */ + pages?: DataConnectorList.Pages; +} + +export namespace DataConnectorList { + /** + * Pagination information. + */ + export interface Pages { + type?: "pages"; + /** The number of results per page. */ + per_page?: number; + /** Cursor for the next page of results. */ + next?: Pages.Next; + } + + export namespace Pages { + /** + * Cursor for the next page of results. + */ + export interface Next { + /** The cursor value to use for the next page. */ + starting_after?: string; + } + } +} + +/** + * Response returned when a data connector is deleted. + */ +export interface DeletedDataConnectorObject { + /** The unique identifier for the data connector. */ + id?: string; + /** The type of object which was deleted. */ + object?: "data_connector"; + /** Whether the data connector was deleted successfully. */ + deleted?: boolean; +} + +/** + * This will return a list of data events for the App. + */ +export interface DataEventList { + /** The type of the object */ + type?: "event.list"; + /** A list of data events */ + events?: Intercom.preview.DataEvent[]; + /** Pagination */ + pages?: DataEventList.Pages; +} + +export namespace DataEventList { + /** + * Pagination + */ + export interface Pages { + next?: string; + since?: string; + } +} + +/** + * This will return a summary of data events for the App. + */ +export interface DataEventSummary { + /** The type of the object */ + type?: "event.summary"; + /** The email address of the user */ + email?: string; + /** The Intercom user ID of the user */ + intercom_user_id?: string; + /** The user ID of the user */ + user_id?: string; + /** A summary of data events */ + events?: (Intercom.preview.DataEventSummaryItem | undefined)[]; +} + +/** + * This will return a summary of a data event for the App. + */ +export interface DataEventSummaryItem { + /** The name of the event */ + name?: string; + /** The first time the event was sent */ + first?: string; + /** The last time the event was sent */ + last?: string; + /** The number of times the event was sent */ + count?: number; + /** The description of the event */ + description?: string; +} + +/** + * A CSV output file + */ +export interface DataExportCsv { + /** The user_id of the user who was sent the message. */ + user_id?: string; + /** The external_user_id of the user who was sent the message */ + user_external_id?: string; + /** The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. */ + company_id?: string; + /** The users email who was sent the message. */ + email?: string; + /** The full name of the user receiving the message */ + name?: string; + /** The id of the message. */ + ruleset_id?: string; + /** The specific content that was received. In an A/B test each version has its own Content ID. */ + content_id?: string; + /** Email, Chat, Post etc. */ + content_type?: string; + /** The title of the content you see in your Intercom workspace. */ + content_title?: string; + /** As you edit content we record new versions. This ID can help you determine which version of a piece of content that was received. */ + ruleset_version_id?: string; + /** ID for this receipt. Will be included with any related stats in other files to identify this specific delivery of a message. */ + receipt_id?: string; + /** Timestamp for when the receipt was recorded. */ + received_at?: number; + /** The id of the series that this content is part of. Will return -1 if not part of a series. */ + series_id?: string; + /** The title of the series that this content is part of. */ + series_title?: string; + /** The id of the series node that this ruleset is associated with. Each block in a series has a corresponding node_id. */ + node_id?: string; + /** The first time a user replied to this message if the content was able to receive replies. Only events within the export job's requested date range are counted. */ + first_reply?: number; + /** The first time a user completed this message if the content was able to be completed e.g. Tours, Surveys. Only events within the export job's requested date range are counted. */ + first_completion?: number; + /** The first time the series this message was a part of was completed by the user. Only events within the export job's requested date range are counted. */ + first_series_completion?: number; + /** The first time the series this message was a part of was disengaged by the user. Only events within the export job's requested date range are counted. */ + first_series_disengagement?: number; + /** The first time the series this message was a part of was exited by the user. Only events within the export job's requested date range are counted. */ + first_series_exit?: number; + /** The first time the user met this messages associated goal if one exists. Only events within the export job's requested date range are counted. */ + first_goal_success?: number; + /** The first time the user opened this message. Only events within the export job's requested date range are counted. */ + first_open?: number; + /** The first time the series the user clicked on a link within this message. Only events within the export job's requested date range are counted. */ + first_click?: number; + /** The first time the series the user dismissed this message. Only events within the export job's requested date range are counted. */ + first_dismisall?: number; + /** The first time the user unsubscribed from this message. Only events within the export job's requested date range are counted. */ + first_unsubscribe?: number; + /** The first time this message hard bounced for this user. Only events within the export job's requested date range are counted. */ + first_hard_bounce?: number; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedArticleObject { + /** The unique identifier for the article which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - article */ + object?: "article"; + /** Whether the article was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedInternalArticleObject { + /** The unique identifier for the internal article which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - internal_article */ + object?: "internal_article"; + /** Whether the internal article was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedCollectionObject { + /** The unique identifier for the collection which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - `collection` */ + object?: "collection"; + /** Whether the collection was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedCompanyObject { + /** The unique identifier for the company which is given by Intercom. */ + id?: string; + /** The type of object which was deleted. - `company` */ + object?: "company"; + /** Whether the company was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedObject { + /** The unique identifier for the news item which you provided in the URL. */ + id?: string; + /** The type of object which was deleted - news-item. */ + object?: "news-item"; + /** Whether the news item was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedNoteObject { + /** The unique identifier for the note which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - `note` */ + type?: "note"; + /** Whether the note was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Returned after a multipart catalog part is successfully uploaded. + */ +export interface EcommerceCatalogUploadPartResponse { + /** + * The unique identifier for the active upload session. Pass this as `import_job_id` + * in subsequent part uploads and in the finalization request. + */ + import_job_id?: string; + /** The part number to use in the next upload request. */ + next_part_number?: number; +} + +/** + * Returned when a catalog upload is accepted and sync has started. + */ +export interface EcommerceCatalogUploadResponse { + /** The unique identifier for the import job. */ + import_job_id?: string; + /** The current status of the catalog sync. */ + status?: "processing"; + /** A human-readable description of the sync status. */ + message?: string; +} + +/** + * A product variant in an ecommerce catalog upload. + */ +export interface EcommerceCatalogVariant { + /** Unique identifier for this variant within the product. */ + id?: string; + /** Variant display name shown to shoppers (e.g. "Small / Blue"). */ + title?: string; + /** Price of this specific variant. Fin uses variant prices for precise budget filtering and displays the variant price in recommendation cards. */ + price?: number; + /** Original price before a discount. When provided, Fin will naturally mention the saving to the shopper (e.g. "down from $129 to $99"). */ + compare_at_price?: number; + /** Whether this variant is currently available. Out-of-stock variants are not shown in Fin's recommendation cards and Fin will not suggest them to shoppers. */ + in_stock?: boolean; + /** Direct link to this variant's page. Takes precedence over the product URL in recommendation cards. If omitted, constructed automatically as `{product_url}?variant={id}`. */ + url?: string; + /** Image specific to this variant. Takes precedence over the product's `featured_image_url`. Falls back to `featured_image_url`, then `image_urls`. If no valid image can be resolved, this variant's recommendation card will not be shown. */ + image_url?: string; + /** The specific option values that define this variant (e.g. Size=Small, Color=Blue). Fin uses these to match shopper requests like "do you have this in medium?" to the correct variant. */ + selected_options?: EcommerceCatalogVariant.SelectedOptions.Item[]; + /** Stock-keeping unit for this specific variant. Fin uses this to resolve shopper requests like "do you have this in size M?" to the exact variant, and can quote it back when a shopper asks for it directly. */ + sku?: string; +} + +export namespace EcommerceCatalogVariant { + export type SelectedOptions = SelectedOptions.Item[]; + + export namespace SelectedOptions { + export interface Item { + /** Option name. */ + name?: string; + /** Selected option value. */ + value?: string; + } + } +} + +/** + * A product object in an ecommerce catalog upload. The catalog file must be a JSON + * array of these objects. The `id`, `title`, and `url` fields are required; all + * others are optional. + */ +export interface EcommerceCatalogProduct { + /** Your unique product identifier. Used to match products on re-upload so only changed products are re-indexed. Also the delete key — any product ID absent from a new upload is removed from Fin's knowledge. Must be stable across uploads. */ + id: string; + /** Product name. Used by Fin when searching for and recommending products. */ + title: string; + /** Canonical product page URL shown in Fin's product recommendations. Must be a valid https:// URL. */ + url: string; + /** Product description that Fin reads to understand what the product is. HTML formatting is supported and safely sanitized (`description_html` takes precedence if both are provided). This is the primary field Fin uses to match products to shopper questions — a richer description leads to better recommendations. */ + description?: string; + /** HTML product description. Takes precedence over `description` when both are provided. HTML is safely sanitized before indexing. */ + description_html?: string; + /** Primary product image shown in Fin's recommendation cards. Falls back to the first entry of `image_urls` if not provided. If no valid image can be resolved for a variant, that variant's recommendation card is not shown to the shopper. */ + featured_image_url?: string; + /** Additional product images. Used as a fallback image source when `featured_image_url` is absent or when a variant has no specific image. */ + image_urls?: string[]; + /** Lowest price across all variants. If omitted, derived automatically from variant prices. Fin uses this to filter products when a shopper mentions a budget (e.g. "under $100"). Displayed as a range alongside `price_max`, or as a single value if both are equal. */ + price_min?: number; + /** Highest price across all variants. If omitted, derived from variant prices. Used alongside `price_min` for budget filtering and price display. */ + price_max?: number; + /** ISO 4217 currency code for all prices on this product (e.g. "USD", "EUR", "GBP"). Defaults to USD if omitted. Used to format prices with the correct symbol in Fin's responses and product cards. */ + currency?: string; + /** + * Whether the product is available to purchase. If omitted, derived from variant stock — the + * product is in stock if at least one variant has `in_stock: true`. Products with no in-stock + * variants are hidden from Fin entirely and will not be recommended to shoppers. + */ + in_stock?: boolean; + /** Free-form keywords matching how shoppers phrase needs in chat (e.g. "waterproof", "gift", "plus-size"). Used by Fin to match fuzzy queries; complements `category_path` and `collections`. */ + tags?: string[]; + /** Collections or groupings this product belongs to in your store. Fin uses collections to understand your catalog's structure and answer questions like "what's in the sale collection?". Each element may be a plain string or an object with a `title` field. */ + collections?: EcommerceCatalogProduct.Collections.Item[]; + /** + * Hierarchical category breadcrumb for the product. Fin understands the hierarchy — a + * shopper asking about "Clothing" will see products from all subcategories underneath it. + * The most specific category is shown in search results. Strongly recommended. Provide as + * a pre-formatted string (e.g. `"Clothing > T-Shirts"`) or as an array of path segments + * (e.g. `["Clothing", "T-Shirts"]`). Array segments are joined with ` > `. + */ + category_path?: EcommerceCatalogProduct.CategoryPath; + /** + * Option types available for this product and their possible values + * (e.g. `{"name": "Size", "values": ["S", "M", "L"]}`). Fin uses these to understand what + * choices a shopper can make and to correctly filter variants when a shopper asks for a + * specific size, colour, or other attribute. + */ + available_options?: EcommerceCatalogProduct.AvailableOptions.Item[]; + /** Individual purchasable variants of the product. Fin recommends specific variants (not just products), so populating variants with accurate stock, price, and option data leads to more precise recommendations. See `ecommerce_catalog_variant` for the variant object schema. */ + variants?: Intercom.preview.EcommerceCatalogVariant[]; + /** Custom attributes for your business. Fin uses these to show each customer only the products relevant to them (e.g. regional availability or warehouse codes). All keys must be consistent across all products in your catalog — the attribute schema is read from the first product in the file. */ + additional_data?: Record; +} + +export namespace EcommerceCatalogProduct { + export type Collections = Collections.Item[]; + + export namespace Collections { + export type Item = + | string + | { + title?: string | undefined; + }; + } + + /** + * Hierarchical category breadcrumb for the product. Fin understands the hierarchy — a + * shopper asking about "Clothing" will see products from all subcategories underneath it. + * The most specific category is shown in search results. Strongly recommended. Provide as + * a pre-formatted string (e.g. `"Clothing > T-Shirts"`) or as an array of path segments + * (e.g. `["Clothing", "T-Shirts"]`). Array segments are joined with ` > `. + */ + export type CategoryPath = string | string[]; + export type AvailableOptions = AvailableOptions.Item[]; + + export namespace AvailableOptions { + export interface Item { + /** Option name (e.g. "Size"). */ + name?: string; + /** All available values for this option. */ + values?: string[]; + } + } +} + +/** + * Contains data for an email address header for a conversation part that was sent as an email. + */ +export interface EmailAddressHeader { + /** The type of email address header */ + type?: string; + /** The email address */ + email_address?: string; + /** The name associated with the email address */ + name?: string; +} + +/** + * Contains metadata if the message was sent as an email + */ +export interface EmailMessageMetadata { + /** The subject of the email */ + subject?: string; + /** A list of an email address headers. */ + email_address_headers?: Intercom.preview.EmailAddressHeader[]; + /** The unique identifier for the email message as specified in the Message-ID header */ + message_id?: string; +} + +/** + * Contains metadata if the message was sent as an email + */ +export interface SourceEmailMessageMetadata { + /** The unique identifier for the email message as specified in the Message-ID header */ + message_id?: string; + /** The subject of the email */ + subject?: string; + /** A list of an email address headers. */ + email_address_headers?: Intercom.preview.EmailAddressHeader[]; + /** The HTML content of any quoted or forwarded email history from the initial inbound message */ + history?: string; +} + +/** + * Contains details about the workflow that was triggered and any Custom Data Attributes (CDAs) that were modified during the workflow execution for conversation part type conversation_attribute_updated_by_workflow. + */ +export interface ConversationAttributeUpdatedByWorkflow { + workflow?: ConversationAttributeUpdatedByWorkflow.Workflow; + attribute?: ConversationAttributeUpdatedByWorkflow.Attribute; + value?: ConversationAttributeUpdatedByWorkflow.Value; +} + +export namespace ConversationAttributeUpdatedByWorkflow { + export interface Workflow { + /** Name of the workflow */ + name?: string; + } + + export interface Attribute { + /** Name of the CDA updated */ + name?: string; + } + + export interface Value { + /** Value of the CDA updated */ + name?: string; + } +} + +/** + * Contains details about Custom Data Attributes (CDAs) that were modified by an admin (operator) for conversation part type conversation_attribute_updated_by_admin. + */ +export interface ConversationAttributeUpdatedByAdmin { + attribute?: ConversationAttributeUpdatedByAdmin.Attribute; + value?: ConversationAttributeUpdatedByAdmin.Value; +} + +export namespace ConversationAttributeUpdatedByAdmin { + export interface Attribute { + /** Name of the CDA updated */ + name?: string; + } + + export interface Value { + /** Current value of the CDA updated */ + name?: string; + /** Previous value of the CDA */ + previous?: string; + } +} + +/** + * Contains details about Custom Data Attributes (CDAs) that were modified by a user for conversation part type conversation_attribute_updated_by_user. + */ +export interface ConversationAttributeUpdatedByUser { + attribute?: ConversationAttributeUpdatedByUser.Attribute; + value?: ConversationAttributeUpdatedByUser.Value; +} + +export namespace ConversationAttributeUpdatedByUser { + export interface Attribute { + /** Name of the CDA updated */ + name?: string; + } + + export interface Value { + /** Current value of the CDA updated */ + name?: string; + /** Previous value of the CDA (null for older events) */ + previous?: string; + } +} + +/** + * Contains details about name of the action that was initiated for conversation part type custom_action_started. + */ +export interface CustomActionStarted { + action?: CustomActionStarted.Action; +} + +export namespace CustomActionStarted { + export interface Action { + /** Name of the action */ + name?: string; + } +} + +/** + * Contains details about final status of the completed action for conversation part type custom_action_finished. + */ +export interface CustomActionFinished { + action?: CustomActionFinished.Action; +} + +export namespace CustomActionFinished { + export interface Action { + /** Name of the action */ + name?: string; + /** Status of the action */ + result?: Action.Result; + } + + export namespace Action { + /** Status of the action */ + export const Result = { + Success: "success", + Failed: "failed", + } as const; + export type Result = (typeof Result)[keyof typeof Result]; + } +} + +/** + * Contains details about name of the workflow for conversation part type operator_workflow_event. + */ +export interface OperatorWorkflowEvent { + workflow?: OperatorWorkflowEvent.Workflow; + event?: OperatorWorkflowEvent.Event; +} + +export namespace OperatorWorkflowEvent { + export interface Workflow { + /** The name of the workflow */ + name?: string; + } + + export interface Event { + /** Type of the workflow event initiated */ + type?: string; + /** Result of the workflow event */ + result?: string; + } +} + +/** + * Contains details about tags that were added or removed from a conversation for conversation part type conversation_tags_updated. + */ +export interface ConversationTagsUpdated { + /** Array of tag names that were added */ + tags_added?: string[]; + /** Array of tag names that were removed */ + tags_removed?: string[]; +} + +/** + * Contains details about conversation snooze timing for conversation part type snoozed. + */ +export interface Snoozed { + /** Human-readable description of snooze duration */ + until?: string; + /** ISO timestamp for custom snooze times (null for general snoozes) */ + custom_until_time?: string; +} + +/** + * Contains details about priority changes for conversation part type priority_changed. + */ +export interface PriorityChanged { + /** Current priority level */ + current_priority?: PriorityChanged.CurrentPriority; + /** Previous priority level */ + previous_priority?: PriorityChanged.PreviousPriority; +} + +export namespace PriorityChanged { + /** Current priority level */ + export const CurrentPriority = { + None: "none", + Low: "low", + Medium: "medium", + High: "high", + Urgent: "urgent", + } as const; + export type CurrentPriority = (typeof CurrentPriority)[keyof typeof CurrentPriority]; + /** Previous priority level */ + export const PreviousPriority = { + None: "none", + Low: "low", + Medium: "medium", + High: "high", + Urgent: "urgent", + } as const; + export type PreviousPriority = (typeof PreviousPriority)[keyof typeof PreviousPriority]; +} + +/** + * Contains details about SLA applied by modern Operator workflows for conversation part type conversation_sla_applied_by_rule. + */ +export interface ConversationSlaAppliedByRule { + /** Name of the SLA that was applied */ + sla_name?: string; + /** Target times configured for the SLA (in seconds) */ + sla_definition?: ConversationSlaAppliedByRule.SlaDefinition; +} + +export namespace ConversationSlaAppliedByRule { + /** + * Target times configured for the SLA (in seconds) + */ + export interface SlaDefinition { + /** First response time target in seconds */ + first_reply_time?: number; + /** Next reply time target in seconds */ + next_reply_time?: number; + /** Resolution time target in seconds */ + resolution_time?: number; + /** Time to close target in seconds */ + time_to_close?: number; + } +} + +/** + * Contains details about SLA applied by legacy Inbox Rules for conversation part type conversation_sla_applied_by_workflow. + */ +export interface ConversationSlaAppliedByWorkflow { + /** Name of the SLA that was applied */ + sla_name?: string; + /** Target times configured for the SLA (in seconds) */ + sla_definition?: ConversationSlaAppliedByWorkflow.SlaDefinition; +} + +export namespace ConversationSlaAppliedByWorkflow { + /** + * Target times configured for the SLA (in seconds) + */ + export interface SlaDefinition { + /** First response time target in seconds */ + first_reply_time?: number; + /** Next reply time target in seconds */ + next_reply_time?: number; + /** Resolution time target in seconds */ + resolution_time?: number; + /** Time to close target in seconds */ + time_to_close?: number; + } +} + +/** + * Contains complete status of all SLA targets when a breach occurs for conversation part type conversation_sla_target_missed. + */ +export interface ConversationSlaTargetMissed { + /** Name of the SLA */ + sla_name?: string; + /** Which specific target was missed */ + sla_target_type?: ConversationSlaTargetMissed.SlaTargetType; + /** Overall SLA status */ + current_sla_status?: ConversationSlaTargetMissed.CurrentSlaStatus; + /** Status of all SLA targets at the time of breach */ + sla_states?: Record; +} + +export namespace ConversationSlaTargetMissed { + /** Which specific target was missed */ + export const SlaTargetType = { + FirstReplyTime: "first_reply_time", + NextReplyTime: "next_reply_time", + ResolutionTime: "resolution_time", + TimeToClose: "time_to_close", + } as const; + export type SlaTargetType = (typeof SlaTargetType)[keyof typeof SlaTargetType]; + /** Overall SLA status */ + export const CurrentSlaStatus = { + Hit: "hit", + Missed: "missed", + Active: "active", + Paused: "paused", + Canceled: "canceled", + } as const; + export type CurrentSlaStatus = (typeof CurrentSlaStatus)[keyof typeof CurrentSlaStatus]; + + export namespace SlaStates { + export interface Value { + /** Status of this specific target */ + status?: Value.Status; + /** Time remaining for active/paused targets (null for hit/missed) */ + seconds_remaining?: number; + } + + export namespace Value { + /** Status of this specific target */ + export const Status = { + Hit: "hit", + Missed: "missed", + Active: "active", + Paused: "paused", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; + } + } +} + +/** + * Contains SLA status at the moment of pausing for conversation part type conversation_sla_paused. + */ +export interface ConversationSlaPaused { + /** Name of the SLA being paused */ + sla_name?: string; + /** Overall SLA status at pause time */ + current_sla_status?: ConversationSlaPaused.CurrentSlaStatus; + /** Status of all SLA targets at pause time */ + sla_states?: Record; +} + +export namespace ConversationSlaPaused { + /** Overall SLA status at pause time */ + export const CurrentSlaStatus = { + Active: "active", + Hit: "hit", + Missed: "missed", + Canceled: "canceled", + } as const; + export type CurrentSlaStatus = (typeof CurrentSlaStatus)[keyof typeof CurrentSlaStatus]; + + export namespace SlaStates { + export interface Value { + /** Status of this specific target (always paused) */ + status?: "paused"; + /** Time remaining when paused */ + seconds_remaining?: number; + } + } +} + +/** + * Contains basic SLA information when unpaused for conversation part type conversation_sla_unpaused. + */ +export interface ConversationSlaUnpaused { + /** Name of the SLA being unpaused */ + sla_name?: string; +} + +/** + * Contains basic SLA information when removed for conversation part type conversation_sla_removed. + */ +export interface ConversationSlaRemoved { + /** Name of the SLA that was removed */ + sla_name?: string; +} + +/** + * Contains the id of the call the summary describes, for conversation part type call_summary. A conversation can contain several calls, and therefore several call summaries, so this identifies which call each summary belongs to. The id matches the id returned by the Calls API and by the call.started, call.ended, call.recording_available and call.transcription_available webhook topics. + */ +export interface CallSummary { + /** The id of the call the summary describes */ + call_id?: string; +} + +/** + * Contains the reason Fin could not verify a contact by one-time passcode email, for conversation part type ai_agent_event when the event type is otp_email_verification_failed. Other ai_agent_event event types are not described here. + */ +export interface AiAgentEventOtpEmailVerificationFailed { + /** The event the part records */ + event?: AiAgentEventOtpEmailVerificationFailed.Event; +} + +export namespace AiAgentEventOtpEmailVerificationFailed { + /** + * The event the part records + */ + export interface Event { + /** The event type */ + type?: string; + /** A readable label for the event */ + value?: string; + /** Data recorded with the event. Empty when the failure was recorded without a reason. */ + data?: Event.Data; + } + + export namespace Event { + /** + * Data recorded with the event. Empty when the failure was recorded without a reason. + */ + export interface Data { + /** Details of the failed verification */ + otp_email_verification_failed?: Data.OtpEmailVerificationFailed; + } + + export namespace Data { + /** + * Details of the failed verification + */ + export interface OtpEmailVerificationFailed { + /** Why the one-time passcode email could not verify the contact. Treat this as a free-form string and fall back to value for a reason you do not recognise. no_email means the contact has no email address on record. */ + reason?: string; + } + } + } +} + +export type EventDetails = + | Intercom.preview.ConversationAttributeUpdatedByWorkflow + | Intercom.preview.ConversationAttributeUpdatedByAdmin + | Intercom.preview.ConversationAttributeUpdatedByUser + | Intercom.preview.CustomActionStarted + | Intercom.preview.CustomActionFinished + | Intercom.preview.OperatorWorkflowEvent + | Intercom.preview.ConversationTagsUpdated + | Intercom.preview.Snoozed + | Intercom.preview.PriorityChanged + | Intercom.preview.ConversationSlaAppliedByRule + | Intercom.preview.ConversationSlaAppliedByWorkflow + | Intercom.preview.ConversationSlaTargetMissed + | Intercom.preview.ConversationSlaPaused + | Intercom.preview.ConversationSlaUnpaused + | Intercom.preview.ConversationSlaRemoved + | Intercom.preview.CallSummary + | Intercom.preview.AiAgentEventOtpEmailVerificationFailed; + +/** + * The API will return an Error List for a failed request, which will contain one or more Error objects. + */ +export interface Error_ { + /** The type is error.list */ + type: string; + /** */ + request_id?: string; + /** An array of one or more error objects */ + errors: Error_.Errors.Item[]; +} + +export namespace Error_ { + export type Errors = Errors.Item[]; + + export namespace Errors { + export interface Item { + /** A string indicating the kind of error, used to further qualify the HTTP response code */ + code: string; + /** Optional. Human readable description of the error. */ + message?: string; + /** Optional. Used to identify a particular field or query parameter that was in error. */ + field?: string; + } + } +} + +/** + * The value describing a file upload set for a custom attribute + */ +export interface FileAttribute { + type?: string; + /** The name of the file */ + name?: string; + /** The url of the file. This is a temporary URL and will expire after 30 minutes. */ + url?: string; + /** The type of file */ + content_type?: string; + /** The size of the file in bytes */ + filesize?: number; + /** The width of the file in pixels, if applicable */ + width?: number; + /** The height of the file in pixels, if applicable */ + height?: number; +} + +/** + * The Content of a Group. + */ +export interface GroupContent { + /** The type of object - `group_content` . */ + type?: "group_content"; + /** The name of the collection or section. */ + name?: string; + /** The description of the collection. Only available for collections. */ + description?: string; +} + +/** + * The Translated Content of an Group. The keys are the locale codes and the values are the translated content of the Group. + */ +export interface GroupTranslatedContent { + /** The type of object - group_translated_content. */ + type?: "group_translated_content"; + /** The content of the group in Arabic */ + ar?: Intercom.preview.GroupContent; + /** The content of the group in Bulgarian */ + bg?: Intercom.preview.GroupContent; + /** The content of the group in Bosnian */ + bs?: Intercom.preview.GroupContent; + /** The content of the group in Catalan */ + ca?: Intercom.preview.GroupContent; + /** The content of the group in Czech */ + cs?: Intercom.preview.GroupContent; + /** The content of the group in Danish */ + da?: Intercom.preview.GroupContent; + /** The content of the group in German */ + de?: Intercom.preview.GroupContent; + /** The content of the group in Greek */ + el?: Intercom.preview.GroupContent; + /** The content of the group in English */ + en?: Intercom.preview.GroupContent; + /** The content of the group in Spanish */ + es?: Intercom.preview.GroupContent; + /** The content of the group in Estonian */ + et?: Intercom.preview.GroupContent; + /** The content of the group in Finnish */ + fi?: Intercom.preview.GroupContent; + /** The content of the group in French */ + fr?: Intercom.preview.GroupContent; + /** The content of the group in Hebrew */ + he?: Intercom.preview.GroupContent; + /** The content of the group in Croatian */ + hr?: Intercom.preview.GroupContent; + /** The content of the group in Hungarian */ + hu?: Intercom.preview.GroupContent; + /** The content of the group in Indonesian */ + id?: Intercom.preview.GroupContent; + /** The content of the group in Italian */ + it?: Intercom.preview.GroupContent; + /** The content of the group in Japanese */ + ja?: Intercom.preview.GroupContent; + /** The content of the group in Korean */ + ko?: Intercom.preview.GroupContent; + /** The content of the group in Lithuanian */ + lt?: Intercom.preview.GroupContent; + /** The content of the group in Latvian */ + lv?: Intercom.preview.GroupContent; + /** The content of the group in Mongolian */ + mn?: Intercom.preview.GroupContent; + /** The content of the group in Norwegian */ + nb?: Intercom.preview.GroupContent; + /** The content of the group in Dutch */ + nl?: Intercom.preview.GroupContent; + /** The content of the group in Polish */ + pl?: Intercom.preview.GroupContent; + /** The content of the group in Portuguese (Portugal) */ + pt?: Intercom.preview.GroupContent; + /** The content of the group in Romanian */ + ro?: Intercom.preview.GroupContent; + /** The content of the group in Russian */ + ru?: Intercom.preview.GroupContent; + /** The content of the group in Slovenian */ + sl?: Intercom.preview.GroupContent; + /** The content of the group in Serbian */ + sr?: Intercom.preview.GroupContent; + /** The content of the group in Swedish */ + sv?: Intercom.preview.GroupContent; + /** The content of the group in Turkish */ + tr?: Intercom.preview.GroupContent; + /** The content of the group in Vietnamese */ + vi?: Intercom.preview.GroupContent; + /** The content of the group in Portuguese (Brazil) */ + "pt-BR"?: Intercom.preview.GroupContent; + /** The content of the group in Chinese (China) */ + "zh-CN"?: Intercom.preview.GroupContent; + /** The content of the group in Chinese (Taiwan) */ + "zh-TW"?: Intercom.preview.GroupContent; +} + +/** + * A list of the company ids a contact has been granted access to. + */ +export interface GrantedCompanyList { + /** The type of object */ + type?: "list"; + /** The `company_id` values of the companies the contact has been granted access to. */ + company_ids?: string[]; + /** Pagination details. Null on the replace response, which returns the whole stored set. */ + pages?: Intercom.preview.PagesLink; + /** The total number of companies the contact has been granted access to. */ + total_count?: number; +} + +/** + * A pause or resume event for a conversation + */ +export interface HandlingEvent { + teammate: Intercom.preview.TeammateReference; + /** The type of handling event */ + type: HandlingEvent.Type; + /** ISO8601 timestamp when the event occurred */ + timestamp: string; + /** Optional reason for the event (e.g., "Paused", "Away") */ + reason?: string; +} + +export namespace HandlingEvent { + /** The type of handling event */ + export const Type = { + Paused: "paused", + Resumed: "resumed", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * A list of handling events for a conversation + */ +export interface HandlingEventList { + /** Array of handling events */ + handling_events?: Intercom.preview.HandlingEvent[]; +} + +/** + * A single event in a Fin human-in-the-loop consultation on a conversation. + */ +export interface HitlEvent { + /** Identifies the consultation this event belongs to. The same on every event of one consultation, so it is not unique per event. */ + hitl_cycle_id?: string; + /** What happened. */ + event_type?: HitlEvent.EventType; + /** The conversation part this event relates to, where one exists. */ + conversation_part_id?: string; + /** The escalation rule that triggered the consultation, as recorded when it began. Null if no rule triggered it. */ + rule_id?: string; + /** The rule's name as recorded when the consultation began, which may differ from its current name. */ + rule_name?: string; + /** Unix timestamp for when the event occurred. Approximate on `fin_draft_proposed`. */ + created_at?: number; + /** Fields specific to this event. Which are present depends on `event_type` — see the endpoint description for the full mapping. */ + data?: HitlEvent.Data; +} + +export namespace HitlEvent { + /** What happened. */ + export const EventType = { + FinConsultationStarted: "fin_consultation_started", + FinDraftProposed: "fin_draft_proposed", + FinTeammateInputReceived: "fin_teammate_input_received", + FinDraftRevised: "fin_draft_revised", + FinConsultationFinished: "fin_consultation_finished", + } as const; + export type EventType = (typeof EventType)[keyof typeof EventType]; + + /** + * Fields specific to this event. Which are present depends on `event_type` — see the endpoint description for the full mapping. + */ + export interface Data { + /** The channel the conversation was on when Fin consulted a teammate. */ + channel?: Data.Channel; + /** The confidence threshold the rule required, as a percentage. */ + rule_threshold_percent?: number; + /** How confident Fin was in its answer, as a percentage. Compare against `rule_threshold_percent`. */ + confidence_percent?: number; + /** The question Fin put to the teammate. */ + sharp_ask?: string; + /** Why Fin needed to ask. */ + ask_rationale?: string; + /** Fin's summary of what the customer needs. */ + issue_summary?: string; + /** The customer's message that prompted the consultation. */ + customer_question?: string; + /** The reply Fin proposed to the teammate. */ + draft?: string; + /** Which round of teammate feedback this event belongs to, starting at 1. */ + round_index?: number; + /** The feedback the teammate gave Fin. */ + teammate_input?: string; + /** The teammate involved in this event — who gave the feedback, or who approved the draft or took over. */ + reviewer_admin_id?: string; + /** How Fin responded to the feedback. `answer` means it produced a revised draft, and is the only value accompanied by a `fin_draft_revised` event. `no_answer` means it had nothing to send, `failed` that regeneration failed, `consult_teammate` that it asked the teammate again, and `pending` that the consultation ended before Fin responded. */ + regeneration_outcome?: string; + /** The reply Fin produced after the teammate's feedback. */ + revised_draft?: string; + /** How the consultation ended. */ + outcome?: Data.Outcome; + /** Whether the teammate approved Fin's original draft or the one it revised after their feedback. */ + approved_draft_type?: Data.ApprovedDraftType; + /** The reply as it stood when the consultation ended. */ + final_draft?: string; + /** What was sent to the customer. Null when nothing was sent. */ + sent_text?: string; + /** How long the consultation took, in seconds. */ + duration_seconds?: number; + /** How many rounds of teammate feedback the consultation had. Only the ten most recent are returned as events, so this can exceed the number of `fin_teammate_input_received` events. */ + rounds_count?: number; + /** Whether any text on this consultation was too long to store in full and was cut. */ + payload_truncated?: boolean; + } + + export namespace Data { + /** The channel the conversation was on when Fin consulted a teammate. */ + export const Channel = { + Email: "email", + Chat: "chat", + Voice: "voice", + Unknown: "unknown", + } as const; + export type Channel = (typeof Channel)[keyof typeof Channel]; + /** How the consultation ended. */ + export const Outcome = { + Approved: "approved", + TakenOver: "taken_over", + TimedOutSent: "timed_out_sent", + TimedOutEscalated: "timed_out_escalated", + Superseded: "superseded", + } as const; + export type Outcome = (typeof Outcome)[keyof typeof Outcome]; + /** Whether the teammate approved Fin's original draft or the one it revised after their feedback. */ + export const ApprovedDraftType = { + Original: "original", + Revised: "revised", + } as const; + export type ApprovedDraftType = (typeof ApprovedDraftType)[keyof typeof ApprovedDraftType]; + } +} + +/** + * A list of human-in-the-loop events for a conversation, oldest first. + */ +export interface HitlEventList { + /** The type of the object. */ + type?: "list"; + /** An array of HITL event objects. */ + data?: Intercom.preview.HitlEvent[]; +} + +/** + * A side conversation with its conversation parts. + */ +export interface SideConversationSummary { + /** The unique identifier for the side conversation. */ + side_conversation_id?: string; + /** The conversation parts (messages) in this side conversation. */ + conversation_parts?: Intercom.preview.ConversationPart[]; + /** The total number of conversation parts in this side conversation. */ + total_count?: number; +} + +/** + * A paginated list of side conversations for a conversation. + */ +export interface SideConversationList { + /** The type of the response object. */ + type?: "side_conversation.list"; + /** An array of side conversation objects. */ + side_conversations?: Intercom.preview.SideConversationSummary[]; + /** The total number of side conversations. */ + total_count?: number; + /** Pagination metadata. */ + pages?: SideConversationList.Pages; +} + +export namespace SideConversationList { + /** + * Pagination metadata. + */ + export interface Pages { + type?: "pages"; + /** The current page number. */ + page?: number; + /** The number of results per page. */ + per_page?: number; + /** The total number of pages. */ + total_pages?: number; + } +} + +/** + * A list of identity verification secrets for the workspace. The `secret` field is intentionally omitted from each entry. + */ +export interface IdentityVerificationSecretList { + /** The type of the object */ + type?: "list"; + /** The identity verification secrets configured for the workspace. */ + data?: Intercom.preview.IdentityVerificationSecret[]; +} + +/** + * A linked conversation or ticket. + */ +export interface LinkedObject { + /** ticket or conversation */ + type?: LinkedObject.Type; + /** The ID of the linked object */ + id?: string; + /** Category of the Linked Ticket Object. */ + category?: LinkedObject.Category; +} + +export namespace LinkedObject { + /** ticket or conversation */ + export const Type = { + Ticket: "ticket", + Conversation: "conversation", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + /** Category of the Linked Ticket Object. */ + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; +} + +/** + * An object containing metadata about linked conversations and linked tickets. Up to 1000 can be returned. + */ +export interface LinkedObjectList { + /** Always list. */ + type?: "list"; + /** The total number of linked objects. */ + total_count?: number; + /** Whether or not there are more linked objects than returned. */ + has_more?: boolean; + /** An array containing the linked conversations and linked tickets. */ + data?: Intercom.preview.LinkedObject[]; +} + +/** + * The result of a merge preview. Either the merge is allowed (with a summary of the changes) or it is not (with reasons). + */ +export type MergePreviewResponse = Intercom.preview.MergePreviewAllowed | Intercom.preview.MergePreviewBlocked; + +/** + * Returned when the merge is allowed. + */ +export interface MergePreviewAllowed { + /** Always true. The merge is allowed. */ + allowed?: boolean; + summary?: Intercom.preview.MergePreviewSummary; +} + +/** + * Returned when the merge is not allowed. + */ +export interface MergePreviewBlocked { + /** Always false. The merge is not allowed. */ + allowed?: boolean; + /** One or more reasons the merge is not allowed. */ + reasons?: Intercom.preview.MergePreviewReason[]; +} + +/** + * A reason a merge is not allowed. + */ +export interface MergePreviewReason { + /** A stable code identifying the reason. Branch on this value. */ + code?: MergePreviewReason.Code; + /** A human-readable explanation. Display this to people; do not match on it, as the wording may change. */ + message?: string; +} + +export namespace MergePreviewReason { + /** A stable code identifying the reason. Branch on this value. */ + export const Code = { + SourceSameAsTarget: "source_same_as_target", + InvalidMergeRolePair: "invalid_merge_role_pair", + NoSharedIdentifier: "no_shared_identifier", + FacebookUser: "facebook_user", + ExternalLeadChannelNotAllowed: "external_lead_channel_not_allowed", + MailingList: "mailing_list", + UserToLead: "user_to_lead", + WhatsappDataCannotBeMerged: "whatsapp_data_cannot_be_merged", + TelegramDataCannotBeMerged: "telegram_data_cannot_be_merged", + SourceHasTelegramData: "source_has_telegram_data", + PhoneDataCannotBeMerged: "phone_data_cannot_be_merged", + } as const; + export type Code = (typeof Code)[keyof typeof Code]; +} + +/** + * A summary of the changes the merge would make to the surviving contact. + */ +export interface MergePreviewSummary { + attribute_changes?: Intercom.preview.MergePreviewAttributeChanges; + reassignments?: Intercom.preview.MergePreviewReassignments; +} + +/** + * The attribute changes the merge would make to the surviving contact. + */ +export interface MergePreviewAttributeChanges { + /** The individual attribute changes. Capped at 50 items; total_count reflects the full number of changes. */ + attributes?: Intercom.preview.MergePreviewAttributeChange[]; + /** The total number of attribute changes detected, which may exceed the number of items in attributes. */ + total_count?: number; +} + +/** + * A single attribute change on the surviving contact. + */ +export interface MergePreviewAttributeChange { + /** The contact field that would change. */ + field?: string; + /** How the value is resolved. adopted = the source's value is taken; discarded = the source's value is dropped and the target's kept; merged = the two values are combined. */ + outcome?: MergePreviewAttributeChange.Outcome; + /** The source contact's value. Omitted when null. May be a string, array, or object depending on the field. */ + from_value?: unknown; + /** The target contact's value. Omitted when null. May be a string, array, or object depending on the field. */ + into_value?: unknown; + /** The resulting value on the surviving contact. Always present; may be null. May be a string, array, or object depending on the field. */ + new_into_value?: unknown; +} + +export namespace MergePreviewAttributeChange { + /** How the value is resolved. adopted = the source's value is taken; discarded = the source's value is dropped and the target's kept; merged = the two values are combined. */ + export const Outcome = { + Adopted: "adopted", + Discarded: "discarded", + Merged: "merged", + } as const; + export type Outcome = (typeof Outcome)[keyof typeof Outcome]; +} + +/** + * Two counts per object type — `from`, how many are on the lead and would move to the surviving contact, and `into`, how many the surviving contact already has. Only types with reassignments are included, and both counts are always present on a type that is included. + */ +export interface MergePreviewReassignments { + /** Distinct non-ticket conversations, counting both conversations the contact owns and conversations it participates in. Tickets are excluded here and reported separately under `tickets`. */ + conversations?: MergePreviewReassignments.Conversations; + /** Tickets, meaning conversations of any ticket type. Counted separately from `conversations` so a single conversation is never counted twice. */ + tickets?: MergePreviewReassignments.Tickets; + /** Phone calls. Present only for phone-lead merges. */ + phone_calls?: MergePreviewReassignments.PhoneCalls; + /** Tags. `from` counts only tags the surviving contact does not already have. */ + tags?: MergePreviewReassignments.Tags; + /** Notes attached to the contact. */ + notes?: MergePreviewReassignments.Notes; +} + +export namespace MergePreviewReassignments { + /** + * Distinct non-ticket conversations, counting both conversations the contact owns and conversations it participates in. Tickets are excluded here and reported separately under `tickets`. + */ + export interface Conversations { + /** The number of non-ticket conversations on the lead that would be reassigned to the surviving contact. */ + from: number; + /** The number of non-ticket conversations the surviving contact already has. */ + into: number; + } + + /** + * Tickets, meaning conversations of any ticket type. Counted separately from `conversations` so a single conversation is never counted twice. + */ + export interface Tickets { + /** The number of tickets on the lead that would be reassigned to the surviving contact. */ + from: number; + /** The number of tickets the surviving contact already has. */ + into: number; + } + + /** + * Phone calls. Present only for phone-lead merges. + */ + export interface PhoneCalls { + /** The number of phone calls on the lead that would be reassigned to the surviving contact. */ + from: number; + /** The number of phone calls the surviving contact already has. */ + into: number; + } + + /** + * Tags. `from` counts only tags the surviving contact does not already have. + */ + export interface Tags { + /** The number of tags on the lead that would be added to the surviving contact. */ + from: number; + /** The number of tags the surviving contact already has. */ + into: number; + } + + /** + * Notes attached to the contact. + */ + export interface Notes { + /** The number of notes on the lead that would be reassigned to the surviving contact. */ + from: number; + /** The number of notes the surviving contact already has. */ + into: number; + } +} + +export interface WhatsappMessageStatusList { + type: "list"; + /** The provided ruleset ID */ + ruleset_id: string; + pages: WhatsappMessageStatusList.Pages; + /** Total number of events */ + total_count: number; + events: WhatsappMessageStatusList.Events.Item[]; +} + +export namespace WhatsappMessageStatusList { + export interface Pages { + type: "pages"; + /** Number of results per page */ + per_page: number; + /** Total number of pages */ + total_pages: number; + /** Information for fetching next page (null if no more pages) */ + next?: Pages.Next; + } + + export namespace Pages { + /** + * Information for fetching next page (null if no more pages) + */ + export interface Next { + /** Cursor for the next page */ + starting_after?: string; + } + } + + export type Events = Events.Item[]; + + export namespace Events { + export interface Item { + /** Event ID */ + id: string; + /** ID of the conversation */ + conversation_id: string; + /** Current status of the message */ + status: Item.Status; + /** Event type */ + type: "broadcast_outbound"; + /** Creation timestamp */ + created_at: number; + /** Last update timestamp */ + updated_at: number; + /** WhatsApp's message identifier */ + whatsapp_message_id: string; + /** Name of the WhatsApp template used */ + template_name?: string; + } + + export namespace Item { + /** Current status of the message */ + export const Status = { + Sent: "sent", + Delivered: "delivered", + Read: "read", + Failed: "failed", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; + } + } +} + +/** + * The delivery status of a specific WhatsApp message. + */ +export interface WhatsappMessageStatus { + /** ID of the conversation */ + conversation_id?: string; + /** Current delivery status of the message */ + status?: WhatsappMessageStatus.Status; + /** Event type */ + type?: string; + /** Creation timestamp */ + created_at?: number; + /** Last update timestamp */ + updated_at?: number; + /** Name of the WhatsApp template used */ + template_name?: string; + /** The WhatsApp message ID */ + message_id?: string; + /** Error details, present only when status is "failed" */ + error?: WhatsappMessageStatus.Error_; +} + +export namespace WhatsappMessageStatus { + /** Current delivery status of the message */ + export const Status = { + Sent: "sent", + Delivered: "delivered", + Read: "read", + Failed: "failed", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; + + /** + * Error details, present only when status is "failed" + */ + export interface Error_ { + /** Error message */ + message?: string; + /** Detailed error information */ + details?: string; + } +} + +/** + * Search using Intercoms Search APIs with more than one filter. + */ +export interface MultipleFilterSearchRequest { + /** An operator to allow boolean inspection between multiple fields. */ + operator?: MultipleFilterSearchRequest.Operator; + value?: MultipleFilterSearchRequest.Value; +} + +export namespace MultipleFilterSearchRequest { + /** An operator to allow boolean inspection between multiple fields. */ + export const Operator = { + And: "AND", + Or: "OR", + } as const; + export type Operator = (typeof Operator)[keyof typeof Operator]; + export type Value = + /** + * Add mutiple filters. */ + | Intercom.preview.MultipleFilterSearchRequest[] + /** + * Add a single filter field. */ + | Intercom.preview.SingleFilterSearchRequest[]; +} + +/** + * A News Item is a content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers. + */ +export interface NewsItemRequest { + /** The title of the news item. */ + title: string; + /** The news item body, which may contain HTML. */ + body?: string; + /** The id of the sender of the news item. Must be a teammate on the workspace. */ + sender_id: number; + /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ + state?: NewsItemRequest.State; + /** When set to `true`, the news item will appear in the messenger newsfeed without showing a notification badge. */ + deliver_silently?: boolean; + /** Label names displayed to users to categorize the news item. */ + labels?: string[]; + /** Ordered list of emoji reactions to the news item. When empty, reactions are disabled. */ + reactions?: (string | undefined)[]; + /** A list of newsfeed_assignments to assign to the specified newsfeed. */ + newsfeed_assignments?: Intercom.preview.NewsfeedAssignment[]; +} + +export namespace NewsItemRequest { + /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ + export const State = { + Draft: "draft", + Live: "live", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * A list of banners a contact currently matches. + */ +export interface BannerList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** An array of banners. */ + data?: Intercom.preview.Banner[]; +} + +/** + * A paginated list of notes associated with a contact or a company. + */ +export interface NoteList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** An array of notes. */ + data?: Intercom.preview.Note[]; + /** A count of the total number of notes. */ + total_count?: number; + pages?: Intercom.preview.CursorPages; +} + +/** + * Payload of the request to open a conversation + */ +export interface OpenConversationRequest { + /** The id of the admin who is performing the action. */ + admin_id: string; +} + +/** + * The majority of list resources in the API are paginated to allow clients to traverse data over multiple requests. + * + * Their responses are likely to contain a pages object that hosts pagination links which a client can use to paginate through the data without having to construct a query. The link relations for the pages field are as follows. + */ +export interface PagesLink { + type?: "pages"; + page?: number; + /** A link to the next page of results. A response that does not contain a next link does not have further data to fetch. */ + next?: string; + per_page?: number; + total_pages?: number; +} + +export type PaginatedResponseDataItem = + | Intercom.preview.PaginatedResponseDataItem.NewsItem + | Intercom.preview.PaginatedResponseDataItem.Newsfeed; + +export namespace PaginatedResponseDataItem { + export interface NewsItem extends Intercom.preview.NewsItem { + type: "news-item"; + } + + export interface Newsfeed extends Intercom.preview.Newsfeed { + type: "newsfeed"; + } +} + +/** + * Paginated Response + */ +export interface PaginatedResponse { + /** The type of object */ + type?: PaginatedResponse.Type; + pages?: Intercom.preview.CursorPages; + /** A count of the total number of objects. */ + total_count?: number; + /** An array of Objects */ + data?: Intercom.preview.PaginatedResponseDataItem[]; +} + +export namespace PaginatedResponse { + /** The type of object */ + export const Type = { + List: "list", + ConversationList: "conversation.list", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * The file attached to a part + */ +export interface PartAttachment { + /** The type of attachment */ + type?: string; + /** The name of the attachment */ + name?: string; + /** The URL of the attachment */ + url?: string; + /** The content type of the attachment */ + content_type?: string; + /** The size of the attachment */ + filesize?: number; + /** The width of the attachment */ + width?: number; + /** The height of the attachment */ + height?: number; +} + +/** + * Phone Switch Response + */ +export interface PhoneSwitch { + /** */ + type?: "phone_call_redirect"; + /** Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. */ + phone?: string; +} + +export interface QuickReplyOption { + /** The text to display in this quick reply option. */ + text: string; + /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment conversation part that is created when a user clicks on this reply option. */ + uuid: string; +} + +export type RedactConversationRequest = + /** + * Payload of the request to redact a conversation part */ + | Intercom.preview.RedactConversationRequest.ConversationPart + /** + * Payload of the request to redact a conversation source */ + | Intercom.preview.RedactConversationRequest.Source; + +export namespace RedactConversationRequest { + export interface ConversationPart { + type: "conversation_part"; + /** The id of the conversation. */ + conversation_id: string; + /** The id of the conversation_part. */ + conversation_part_id: string; + } + + export interface Source { + type: "source"; + /** The id of the conversation. */ + conversation_id: string; + /** The id of the source. */ + source_id: string; + } +} + +/** + * reference to another object + */ +export interface Reference { + /** */ + type?: string; + /** */ + id?: string; +} + +export type ReplyConversationRequestBody = + | Intercom.preview.ContactReplyConversationRequest + | Intercom.preview.AdminReplyConversationRequest; + +/** + * Search using Intercoms Search APIs. + */ +export interface SearchRequest { + query: SearchRequest.Query; + pagination?: Intercom.preview.StartingAfterPaging; +} + +export namespace SearchRequest { + export type Query = Intercom.preview.SingleFilterSearchRequest | Intercom.preview.MultipleFilterSearchRequest; +} + +/** + * This will return a list of Segment Objects. The result may also have a pages object if the response is paginated. + */ +export interface SegmentList { + /** The type of the object */ + type?: "segment.list"; + /** A list of Segment objects */ + segments?: Intercom.preview.Segment[]; + /** A pagination object, which may be empty, indicating no further pages to fetch. */ + pages?: Record; +} + +/** + * Search using Intercoms Search APIs with a single filter. + */ +export interface SingleFilterSearchRequest { + /** The accepted field that you want to search on. */ + field?: string; + /** + * The accepted operators you can use to define how you want to search for the value. Operator support depends on the field's data type. The breakdown below is for Contacts search; the other search endpoints that share this schema accept a different set per field: + * - `string` fields: `=`, `!=`, `IN`, `NIN`, `~`, `!~`, `^`, `$` + * - `tag_id`: `=` and `!=` only. Every other operator returns an error. + * - `boolean` fields: `=`, `!=`, `IN`, `NIN` + * - `integer` fields: `=`, `!=`, `IN`, `NIN`, `<`, `>`, `<=`, `>=` + * - `datetime` fields (standard contact timestamps such as `created_at` and `last_seen_at`): `=`, `!=`, `<`, `>`, `<=`, `>=`. Filtering is on the exact second, in UTC. + * - `date` fields (Date custom attributes): `=`, `<`, `>` only. `!=`, `<=`, and `>=` are not supported and return an error. Values are truncated to a whole UTC day. + */ + operator?: SingleFilterSearchRequest.Operator; + /** The value that you want to search on. */ + value?: SingleFilterSearchRequest.Value; +} + +export namespace SingleFilterSearchRequest { + /** + * The accepted operators you can use to define how you want to search for the value. Operator support depends on the field's data type. The breakdown below is for Contacts search; the other search endpoints that share this schema accept a different set per field: + * - `string` fields: `=`, `!=`, `IN`, `NIN`, `~`, `!~`, `^`, `$` + * - `tag_id`: `=` and `!=` only. Every other operator returns an error. + * - `boolean` fields: `=`, `!=`, `IN`, `NIN` + * - `integer` fields: `=`, `!=`, `IN`, `NIN`, `<`, `>`, `<=`, `>=` + * - `datetime` fields (standard contact timestamps such as `created_at` and `last_seen_at`): `=`, `!=`, `<`, `>`, `<=`, `>=`. Filtering is on the exact second, in UTC. + * - `date` fields (Date custom attributes): `=`, `<`, `>` only. `!=`, `<=`, and `>=` are not supported and return an error. Values are truncated to a whole UTC day. + */ + export const Operator = { + EqualTo: "=", + NotEquals: "!=", + In: "IN", + Nin: "NIN", + LessThan: "<", + GreaterThan: ">", + } as const; + export type Operator = (typeof Operator)[keyof typeof Operator]; + /** + * The value that you want to search on. + */ + export type Value = string | number | boolean | (string | number)[]; +} + +/** + * The SLA Applied object contains the details for which SLA has been applied to this conversation. + * Important: if there are any canceled sla_events for the conversation - meaning an SLA has been manually removed from a conversation, the sla_status will always be returned as null. + */ +export interface SlaApplied { + /** object type */ + type?: string; + /** The name of the SLA as given by the teammate when it was created. */ + sla_name?: string; + /** + * SLA statuses: + * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. + * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. + * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. + */ + sla_status?: SlaApplied.SlaStatus; +} + +export namespace SlaApplied { + /** + * SLA statuses: + * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. + * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. + * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. + */ + export const SlaStatus = { + Hit: "hit", + Missed: "missed", + Cancelled: "cancelled", + Active: "active", + } as const; + export type SlaStatus = (typeof SlaStatus)[keyof typeof SlaStatus]; +} + +/** + * Payload of the request to snooze a conversation + */ +export interface SnoozeConversationRequest { + /** The id of the admin who is performing the action. */ + admin_id: string; + /** The time you want the conversation to reopen. */ + snoozed_until: number; +} + +/** + * A Social Profile allows you to label your contacts, companies, and conversations and list them using that Social Profile. + */ +export interface SocialProfile { + /** value is "social_profile" */ + type?: string; + /** The name of the Social media profile */ + name?: string; + /** The name of the Social media profile */ + url?: string; +} + +export interface StartingAfterPaging { + /** The number of results to fetch per page. */ + per_page?: number; + /** The cursor to use in the next request to get the next page of results. */ + starting_after?: string; +} + +/** + * A list of subscription type objects. + */ +export interface SubscriptionTypeList { + /** The type of the object */ + type?: "list"; + /** A list of subscription type objects associated with the workspace . */ + data?: Intercom.preview.SubscriptionType[]; +} + +/** + * The response for creating or updating a tag, including the entities that were tagged or untagged. + */ +export interface TagCreateResponse extends Intercom.preview.TagBasic { + /** The users that were tagged or untagged. */ + users?: TagCreateResponse.Users.Item[]; + /** The companies that were tagged or untagged. */ + companies?: TagCreateResponse.Companies.Item[]; +} + +export namespace TagCreateResponse { + export type Users = Users.Item[]; + + export namespace Users { + export interface Item { + /** The Intercom ID of the user. */ + id?: string; + /** Whether the user was tagged (true) or untagged (false). */ + tagged?: boolean; + } + } + + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom ID of the company. */ + id?: string; + /** Whether the company was tagged (true) or untagged (false). */ + tagged?: boolean; + } + } +} + +/** + * You can tag a single company or a list of companies. + */ +export interface TagCompanyRequest { + /** The name of the tag, which will be created if not found. */ + name: string; + /** The id or company_id of the company can be passed as input parameters. */ + companies: TagCompanyRequest.Companies.Item[]; +} + +export namespace TagCompanyRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom defined id representing the company. */ + id?: string; + /** The company id you have defined for the company. */ + company_id?: string; + } + } +} + +/** + * A list of tags objects in the workspace. + */ +export interface TagList { + /** The type of the object */ + type?: "list"; + /** A list of tags objects associated with the workspace . */ + data?: Intercom.preview.Tag[]; +} + +/** + * You can tag a list of users. + */ +export interface TagMultipleUsersRequest { + /** The name of the tag, which will be created if not found. */ + name: string; + users: TagMultipleUsersRequest.Users.Item[]; +} + +export namespace TagMultipleUsersRequest { + export type Users = Users.Item[]; + + export namespace Users { + export interface Item { + /** The Intercom defined id representing the user. */ + id?: string; + } + } +} + +/** + * A list of tags objects associated with a conversation + */ +export interface Tags { + /** The type of the object */ + type?: "tag.list"; + /** A list of tags objects associated with the conversation. */ + tags?: Intercom.preview.Tag[]; +} + +/** + * This will return a list of team objects for the App. + */ +export interface TeamList { + /** The type of the object */ + type?: "team.list"; + /** A list of team objects */ + teams?: Intercom.preview.Team[]; +} + +/** + * Admin priority levels for teams + */ +export interface TeamPriorityLevel { + /** The primary team ids for the team */ + primary_team_ids?: number[]; + /** The secondary team ids for the team */ + secondary_team_ids?: number[]; +} + +/** + * A reference to a teammate (admin, team, or bot) + */ +export interface TeammateReference { + /** The type of teammate */ + type: TeammateReference.Type; + /** The unique identifier of the teammate */ + id: number; + /** The display name of the teammate */ + name: string; + /** The email address of the teammate (optional for teams/bots) */ + email?: string; +} + +export namespace TeammateReference { + /** The type of teammate */ + export const Type = { + Admin: "admin", + Team: "team", + Bot: "bot", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * deleted ticket object + */ +export interface TicketDeleted { + /** The unique identifier for the ticket. */ + id?: string; + /** always ticket */ + object?: "ticket"; + /** Whether the ticket is deleted or not. */ + deleted?: boolean; +} + +/** + * An object containing the different attributes associated to the ticket as key-value pairs. For the default title and description attributes, the keys are `_default_title_` and `_default_description_`. + */ +export type TicketCustomAttributes = Record; + +export namespace TicketCustomAttributes { + export type Value = string | undefined | number | boolean | unknown[] | Intercom.preview.FileAttribute; +} + +/** + * Tickets are how you track requests from your users. + */ +export interface TicketList { + /** Always ticket.list */ + type?: "ticket.list"; + /** The list of ticket objects */ + tickets?: (Intercom.preview.Ticket | undefined)[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.preview.CursorPages; +} + +/** + * The author that wrote or triggered the part. Can be a bot, admin, team or user. + */ +export interface TicketPartAuthor { + /** The type of the author */ + type?: TicketPartAuthor.Type; + /** The id of the author */ + id?: string; + /** The name of the author */ + name?: string; + /** The email of the author */ + email?: string; +} + +export namespace TicketPartAuthor { + /** The type of the author */ + export const Type = { + Admin: "admin", + Bot: "bot", + Team: "team", + User: "user", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * A list of Ticket Part objects for each note and event in the ticket. There is a limit of 500 parts. + */ +export interface TicketParts { + /** */ + type?: "ticket_part.list"; + /** A list of Ticket Part objects for each ticket. There is a limit of 500 parts. */ + ticket_parts?: Intercom.preview.TicketPart[]; + /** */ + total_count?: number; +} + +/** + * A Ticket Part representing a note, comment, or quick_reply on a ticket + */ +export interface TicketReply { + /** Always ticket_part */ + type?: "ticket_part"; + /** The id representing the part. */ + id?: string; + /** Type of the part */ + part_type?: TicketReply.PartType; + /** The message body, which may contain HTML. */ + body?: string; + /** The time the note was created. */ + created_at?: number; + /** The last time the note was updated. */ + updated_at?: number; + author?: Intercom.preview.TicketPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.preview.PartAttachment[]; + /** Whether or not the ticket part has been redacted. */ + redacted?: boolean; + /** A map of the reply text keyed by locale code. Only present on the Preview API version and backs the `ticket.admin.replied.translated` webhook topic. The special `original` key holds the source locale code of the reply; every other key is a locale code whose value is the reply text translated into that locale, as HTML in the same format as `body`. The `body` field is unchanged and always stays in the original source language. Available in the Preview API version only (set `Intercom-Version: Preview`). This webhook topic is not sent for every translated reply: it is suppressed when the reply's `body` contains any text outside an HTML block element, which includes plain-text replies created through the REST API. Wrap the body in `

`, `

`, or another supported block element to avoid this. */ + translations?: Record; +} + +export namespace TicketReply { + /** Type of the part */ + export const PartType = { + Note: "note", + Comment: "comment", + QuickReply: "quick_reply", + } as const; + export type PartType = (typeof PartType)[keyof typeof PartType]; +} + +/** + * The attributes set on the ticket. When setting the default title and description attributes, the attribute keys that should be used are `_default_title_` and `_default_description_`. When setting ticket type attributes of the list attribute type, the key should be the attribute name and the value of the attribute should be the list item id, obtainable by [listing the ticket type](ref:get_ticket-types). For example, if the ticket type has an attribute called `priority` of type `list`, the key should be `priority` and the value of the attribute should be the guid of the list item (e.g. `de1825a0-0164-4070-8ca6-13e22462fa7e`). + */ +export type TicketRequestCustomAttributes = Record; + +export namespace TicketRequestCustomAttributes { + export type Value = string | undefined | number | boolean | unknown[]; +} + +/** + * A list of ticket states associated with a given ticket type. + */ +export interface TicketStateList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket states associated with a given ticket type. */ + data?: (Intercom.preview.TicketStateDetailed | undefined)[]; +} + +/** + * Ticket type attribute, used to define each data field to be captured in a ticket. + */ +export interface TicketTypeAttribute { + /** String representing the object's type. Always has the value `ticket_type_attribute`. */ + type?: string; + /** The id representing the ticket type attribute. */ + id?: string; + /** The id of the workspace that the ticket type attribute belongs to. */ + workspace_id?: string; + /** The name of the ticket type attribute */ + name?: string; + /** The description of the ticket type attribute */ + description?: string; + /** The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ + data_type?: string; + /** Input options for the attribute */ + input_options?: Record; + /** The order of the attribute against other attributes */ + order?: number; + /** Whether the attribute is required or not for teammates. */ + required_to_create?: boolean; + /** Whether the attribute is required or not for contacts. */ + required_to_create_for_contacts?: boolean; + /** Whether the attribute is visible or not to teammates. */ + visible_on_create?: boolean; + /** Whether the attribute is visible or not to contacts. */ + visible_to_contacts?: boolean; + /** Whether the attribute is built in or not. */ + default?: boolean; + /** The id of the ticket type that the attribute belongs to. */ + ticket_type_id?: number; + /** Whether the ticket type attribute is archived or not. */ + archived?: boolean; + /** The date and time the ticket type attribute was created. */ + created_at?: number; + /** The date and time the ticket type attribute was last updated. */ + updated_at?: number; +} + +/** + * A list of attributes associated with a given ticket type. + */ +export interface TicketTypeAttributeList { + /** String representing the object's type. Always has the value `ticket_type_attributes.list`. */ + type?: string; + /** A list of ticket type attributes associated with a given ticket type. */ + ticket_type_attributes?: (Intercom.preview.TicketTypeAttribute | undefined)[]; +} + +/** + * A list of ticket types associated with a given workspace. + */ +export interface TicketTypeList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket_types associated with a given workspace. */ + data?: (Intercom.preview.TicketType | undefined)[]; +} + +/** + * A translation object contains the localised details of a subscription type. + */ +export interface Translation { + /** The localised name of the subscription type. */ + name?: string; + /** The localised description of the subscription type. */ + description?: string; + /** The two character identifier for the language of the translation object. */ + locale?: string; +} + +/** + * You can tag a single company or a list of companies. + */ +export interface UntagCompanyRequest { + /** The name of the tag which will be untagged from the company */ + name: string; + /** The id or company_id of the company can be passed as input parameters. */ + companies: UntagCompanyRequest.Companies.Item[]; +} + +export namespace UntagCompanyRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom defined id representing the company. */ + id?: string; + /** The company id you have defined for the company. */ + company_id?: string; + /** Always set to true */ + untag?: boolean; + } + } +} + +/** + * Optional body for publishing a staged article draft. On a single-language + * workspace the body can be omitted. On a multilingual workspace, `locales` + * is required and lists which locales' drafts to publish. + */ +export interface PublishArticleDraftRequestBody { + /** + * The locales whose staged drafts should be published. Required on + * multilingual workspaces; each locale must have a pending draft. + */ + locales?: string[]; +} + +/** + * You can Stage a Draft for an Article + */ +export interface UpdateArticleRequestBody { + /** The title of the article.For multilingual articles, this will be the title of the default language's content. */ + title?: string; + /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ + description?: string; + /** The content of the article in HTML. For multilingual articles, this will be the body of the default language's content. Mutually exclusive with `body_markdown`. */ + body?: string; + /** The content of the article in markdown. For multilingual articles, this will be the body of the default language's content. An alternative to `body` — you can provide content as markdown instead of HTML. Mutually exclusive with `body`. */ + body_markdown?: string; + /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ + author_id?: number; + /** Whether the article will be `published` or will be a `draft`. Omitting this field leaves the publish state unchanged, so a draft stays a draft and an edit to a published article goes live immediately unless that article already has a pending draft or a scheduled publish time is set in the same request. The `PUT /articles/{id}/draft` endpoint ignores this field and always stages a draft. For multilingual articles, this will be the state of the default language's content. */ + state?: UpdateArticleRequestBody.State; + /** The id of the article's parent collection or section. An article without this field stands alone. */ + parent_id?: string; + /** The type of parent, which can either be a `collection` or `section`. */ + parent_type?: string; + /** The ids of the parent collections to place this article in. Send an empty array to remove the article from all collections. When provided, this takes precedence over `parent_id` and `parent_type`. */ + parent_ids?: number[]; + translated_content?: Intercom.preview.ArticleTranslatedContent; + /** The ID of the folder to place this article in, or null to remove it from its folder. */ + folder_id?: number; + /** The list of audience IDs to assign to this article for Fin AI Agent targeting. Sending a top-level `audience_ids` broadcasts the same set to every locale. Sending `audience_ids: []` clears all audience memberships from every locale. For per-locale targeting, use `translated_content..audience_ids` instead. Sending both top-level and per-locale in the same request causes top-level to win. Unknown audience IDs return a 404 error. No partial commit occurs. */ + audience_ids?: number[]; + /** Whether the article should be available for AI Chatbot (Fin). For multilingual articles, this sets the default language's availability. */ + ai_chatbot_availability?: boolean; + /** Whether the article should be available for AI Copilot. For multilingual articles, this sets the default language's availability. */ + ai_copilot_availability?: boolean; + /** Whether the article should be available for AI Sales Agent. For multilingual articles, this sets the default language's availability. */ + ai_sales_agent_availability?: boolean; + /** ISO 8601 timestamp at which to schedule a future publish of the article. When set together with `state: "published"`, the article is scheduled instead of published immediately. Setting `null` cancels a pending publish schedule. Timestamps in the past or equal to the current time are rejected with 400 `parameter_invalid` — the value must be strictly in the future. Combining with `state: "draft"` returns 400 `parameter_invalid`. Sending in the same request as `scheduled_unpublish_at` returns 400 — only one pending schedule per article. Empty string returns 400 `parameter_invalid`. */ + scheduled_publish_at?: string; + /** ISO 8601 timestamp at which to schedule a future unpublish of the article. Setting `null` cancels a pending unpublish schedule. Timestamps in the past or equal to the current time are rejected with 400 `parameter_invalid` — the value must be strictly in the future. Rejected with 400 `parameter_invalid` if the article has never been published. Sending in the same request as `scheduled_publish_at` returns 400 — only one pending schedule per article. Empty string returns 400 `parameter_invalid`. */ + scheduled_unpublish_at?: string; +} + +export namespace UpdateArticleRequestBody { + /** Whether the article will be `published` or will be a `draft`. Omitting this field leaves the publish state unchanged, so a draft stays a draft and an edit to a published article goes live immediately unless that article already has a pending draft or a scheduled publish time is set in the same request. The `PUT /articles/{id}/draft` endpoint ignores this field and always stages a draft. For multilingual articles, this will be the state of the default language's content. */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * + */ +export type UpdateDataAttributeRequestBody = + | { + options: { + value?: string | undefined; + }[]; + } + | unknown; + +/** + * You can update a Ticket + */ +export interface UpdateTicketRequestBody { + /** The attributes set on the ticket. */ + ticket_attributes?: Record; + /** The ID of the ticket state associated with the ticket type. */ + ticket_state_id?: string; + /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. The company must be associated with one of the contacts on the ticket, otherwise the request will fail with a `parameter_invalid` error. Set to nil to remove company. */ + company_id?: string; + /** Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. */ + open?: boolean; + /** Specify whether the ticket is visible to users. */ + is_shared?: boolean; + /** The time you want the ticket to reopen. */ + snoozed_until?: number; + /** The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. */ + admin_id?: number; + /** The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. */ + assignee_id?: string; + /** The priority level to set on the ticket. Accepts one of none, low, medium, high, or urgent. Set none to clear an existing priority. The change is attributed to admin_id, or to Operator when admin_id is omitted. */ + priority?: UpdateTicketRequestBody.Priority; +} + +export namespace UpdateTicketRequestBody { + /** The priority level to set on the ticket. Accepts one of none, low, medium, high, or urgent. Set none to clear an existing priority. The change is attributed to admin_id, or to Operator when admin_id is omitted. */ + export const Priority = { + None: "none", + Low: "low", + Medium: "medium", + High: "high", + Urgent: "urgent", + } as const; + export type Priority = (typeof Priority)[keyof typeof Priority]; +} + +/** + * Visitors are useful for representing anonymous people that have not yet been identified. They usually represent website visitors. Visitors are not visible in Intercom platform. The Visitors resource provides methods to fetch, update, convert and delete. + */ +export interface Visitor { + /** Value is 'visitor' */ + type?: string; + /** The Intercom defined id representing the Visitor. */ + id?: string; + /** Automatically generated identifier for the Visitor. */ + user_id?: string; + /** Identifies if this visitor is anonymous. */ + anonymous?: boolean; + /** The email of the visitor. */ + email?: string; + /** The phone number of the visitor. */ + phone?: string; + /** The name of the visitor. */ + name?: string; + /** The pseudonym of the visitor. */ + pseudonym?: string; + avatar?: Visitor.Avatar; + /** The id of the app the visitor is associated with. */ + app_id?: string; + companies?: Visitor.Companies; + location_data?: Visitor.LocationData; + /** The time the Lead last recorded making a request. */ + las_request_at?: number; + /** The time the Visitor was added to Intercom. */ + created_at?: number; + /** The time the Visitor was added to Intercom. */ + remote_created_at?: number; + /** The time the Visitor signed up for your product. */ + signed_up_at?: number; + /** The last time the Visitor was updated. */ + updated_at?: number; + /** The number of sessions the Visitor has had. */ + session_count?: number; + social_profiles?: Visitor.SocialProfiles; + /** The id of the admin that owns the Visitor. */ + owner_id?: string; + /** Whether the Visitor is unsubscribed from emails. */ + unsubscribed_from_emails?: boolean; + /** Identifies if this visitor has marked an email as spam. */ + marked_email_as_spam?: boolean; + /** Identifies if this visitor has had a hard bounce. */ + has_hard_bounced?: boolean; + tags?: Visitor.Tags; + segments?: Visitor.Segments; + /** The custom attributes you have set on the Visitor. */ + custom_attributes?: Record; + /** The referer of the visitor. */ + referrer?: string; + /** The utm_campaign of the visitor. */ + utm_campaign?: string; + /** The utm_content of the visitor. */ + utm_content?: string; + /** The utm_medium of the visitor. */ + utm_medium?: string; + /** The utm_source of the visitor. */ + utm_source?: string; + /** The utm_term of the visitor. */ + utm_term?: string; + /** Identifies if this visitor has do not track enabled. */ + do_not_track?: boolean; +} + +export namespace Visitor { + export interface Avatar { + /** */ + type?: string; + /** This object represents the avatar associated with the visitor. */ + image_url?: string; + } + + export interface Companies { + /** The type of the object */ + type?: "company.list"; + companies?: Intercom.preview.Company[]; + } + + export interface LocationData { + /** */ + type?: string; + /** The city name of the visitor. */ + city_name?: string; + /** The continent code of the visitor. */ + continent_code?: string; + /** The country code of the visitor. */ + country_code?: string; + /** The country name of the visitor. */ + country_name?: string; + /** The postal code of the visitor. */ + postal_code?: string; + /** The region name of the visitor. */ + region_name?: string; + /** The timezone of the visitor. */ + timezone?: string; + } + + export interface SocialProfiles { + /** The type of the object */ + type?: "social_profile.list"; + social_profiles?: string[]; + } + + export interface Tags { + /** The type of the object */ + type?: "tag.list"; + tags?: Tags.Tags.Item[]; + } + + export namespace Tags { + export type Tags = Tags.Item[]; + + export namespace Tags { + export interface Item { + /** The type of the object */ + type?: "tag"; + /** The id of the tag. */ + id?: string; + /** The name of the tag. */ + name?: string; + } + } + } + + export interface Segments { + /** The type of the object */ + type?: "segment.list"; + segments?: string[]; + } +} + +/** + * Response returned when an object is deleted + */ +export interface VisitorDeletedObject { + /** The unique identifier for the visitor which is given by Intercom. */ + id?: string; + /** The type of object which was deleted */ + type?: "visitor"; + /** Automatically generated identifier for the Visitor. */ + user_id?: string; +} + +/** + * A workflow export containing the complete workflow configuration. + */ +export interface WorkflowExport { + /** The version of the export format. */ + export_version?: string; + /** The timestamp when the export was generated. */ + exported_at?: string; + /** The workspace identifier. */ + app_id?: number; + /** The workflow configuration. */ + workflow?: WorkflowExport.Workflow; +} + +export namespace WorkflowExport { + /** + * The workflow configuration. + */ + export interface Workflow { + /** The unique identifier for the workflow. */ + id?: string; + /** The title of the workflow. */ + title?: string; + /** The description of the workflow. */ + description?: string; + /** The type of trigger that starts this workflow. */ + trigger_type?: string; + /** The current state of the workflow. */ + state?: Workflow.State; + /** The channels this workflow targets. */ + target_channels?: string[]; + /** The preferred devices for this workflow. */ + preferred_devices?: string[]; + /** When the workflow was created. */ + created_at?: string; + /** When the workflow was last updated. */ + updated_at?: string; + /** The targeting rules for this workflow. */ + targeting?: Record; + /** The current snapshot of workflow steps and configuration. */ + snapshot?: Record; + /** Custom attributes defined for this workflow. */ + attributes?: Record[]; + /** Rules embedded within the workflow steps. */ + embedded_rules?: Record[]; + } + + export namespace Workflow { + /** The current state of the workflow. */ + export const State = { + Live: "live", + Draft: "draft", + Paused: "paused", + } as const; + export type State = (typeof State)[keyof typeof State]; + } +} + +/** + * Response containing information about a Fin Voice call + */ +export interface AiCallResponse { + /** The unique identifier for the external reference */ + id?: number; + /** The workspace identifier */ + app_id?: number; + /** Phone number in E.164 format for the call */ + user_phone_number?: string; + /** Status of the call. Can be "registered", "in-progress", or a resolution state */ + status?: string; + /** The Intercom call identifier, if the call has been matched */ + intercom_call_id?: string; + /** The external call identifier from the call provider */ + external_call_id?: string; + /** The Intercom conversation identifier, if a conversation has been created */ + intercom_conversation_id?: string; + /** Array of transcript entries for the call */ + call_transcript?: Record[]; + /** Summary of the call conversation, truncated to 256 characters. Empty string if no summary available. */ + call_summary?: string; + /** Array of intent classifications for the call */ + intent?: Record[]; +} + +/** + * Register a Fin Voice call with Intercom + */ +export interface RegisterFinVoiceCallRequest { + /** Phone number in E.164 format for the call */ + phone_number: string; + /** External call identifier from the call provider */ + call_id: string; + /** Source of the call. Can be "five9", "zoom_phone", or defaults to "aws_connect" */ + source?: RegisterFinVoiceCallRequest.Source; + /** Additional metadata about the call */ + data?: Record; +} + +export namespace RegisterFinVoiceCallRequest { + /** Source of the call. Can be "five9", "zoom_phone", or defaults to "aws_connect" */ + export const Source = { + Five9: "five9", + ZoomPhone: "zoom_phone", + AwsConnect: "aws_connect", + } as const; + export type Source = (typeof Source)[keyof typeof Source]; +} diff --git a/src/api/resources/export/client/Client.ts b/src/api/resources/reportingDataExport/client/Client.ts similarity index 89% rename from src/api/resources/export/client/Client.ts rename to src/api/resources/reportingDataExport/client/Client.ts index 521fe210..f4be0d5b 100644 --- a/src/api/resources/export/client/Client.ts +++ b/src/api/resources/reportingDataExport/client/Client.ts @@ -9,29 +9,29 @@ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCode import * as errors from "../../../../errors/index.js"; import * as Intercom from "../../../index.js"; -export declare namespace ExportClient { +export declare namespace ReportingDataExportClient { export interface Options extends BaseClientOptions {} export interface RequestOptions extends BaseRequestOptions {} } -export class ExportClient { - protected readonly _options: NormalizedClientOptionsWithAuth; +export class ReportingDataExportClient { + protected readonly _options: NormalizedClientOptionsWithAuth; - constructor(options: ExportClient.Options = {}) { + constructor(options: ReportingDataExportClient.Options = {}) { this._options = normalizeClientOptionsWithAuth(options); } /** * @param {Intercom.PostExportReportingDataEnqueueRequest} request - * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {ReportingDataExportClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.BadRequestError} * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.TooManyRequestsError} * * @example - * await client.export.enqueueANewReportingDataExportJob({ + * await client.reportingDataExport.enqueueANewReportingDataExportJob({ * dataset_id: "conversation", * attribute_ids: ["conversation_id", "conversation_started_at"], * start_time: 1717490000, @@ -40,14 +40,14 @@ export class ExportClient { */ public enqueueANewReportingDataExportJob( request: Intercom.PostExportReportingDataEnqueueRequest, - requestOptions?: ExportClient.RequestOptions, + requestOptions?: ReportingDataExportClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__enqueueANewReportingDataExportJob(request, requestOptions)); } private async __enqueueANewReportingDataExportJob( request: Intercom.PostExportReportingDataEnqueueRequest, - requestOptions?: ExportClient.RequestOptions, + requestOptions?: ReportingDataExportClient.RequestOptions, ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -114,19 +114,19 @@ export class ExportClient { } /** - * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration. + * @param {ReportingDataExportClient.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.export.listAvailableDatasetsAndAttributes() + * await client.reportingDataExport.listAvailableDatasetsAndAttributes() */ public listAvailableDatasetsAndAttributes( - requestOptions?: ExportClient.RequestOptions, + requestOptions?: ReportingDataExportClient.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__listAvailableDatasetsAndAttributes(requestOptions)); } private async __listAvailableDatasetsAndAttributes( - requestOptions?: ExportClient.RequestOptions, + requestOptions?: ReportingDataExportClient.RequestOptions, ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( diff --git a/src/api/resources/reportingDataExport/client/index.ts b/src/api/resources/reportingDataExport/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/reportingDataExport/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts b/src/api/resources/reportingDataExport/client/requests/PostExportReportingDataEnqueueRequest.ts similarity index 100% rename from src/api/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts rename to src/api/resources/reportingDataExport/client/requests/PostExportReportingDataEnqueueRequest.ts diff --git a/src/api/resources/unstable/resources/export/client/requests/index.ts b/src/api/resources/reportingDataExport/client/requests/index.ts similarity index 100% rename from src/api/resources/unstable/resources/export/client/requests/index.ts rename to src/api/resources/reportingDataExport/client/requests/index.ts diff --git a/src/api/resources/reportingDataExport/index.ts b/src/api/resources/reportingDataExport/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/reportingDataExport/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/reportingDataExport/types/index.ts b/src/api/resources/reportingDataExport/types/index.ts new file mode 100644 index 00000000..a0c4ebf2 --- /dev/null +++ b/src/api/resources/reportingDataExport/types/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts b/src/api/resources/reportingDataExport/types/types.ts similarity index 83% rename from src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts rename to src/api/resources/reportingDataExport/types/types.ts index 725ac29a..8747ec24 100644 --- a/src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts +++ b/src/api/resources/reportingDataExport/types/types.ts @@ -1,5 +1,12 @@ // This file was auto-generated by Fern from our API Definition. +export interface PostExportReportingDataEnqueueResponse { + job_identifier?: string; + status?: string; + download_url?: string; + download_expires_at?: string; +} + export interface GetExportReportingDataGetDatasetsResponse { type?: string; data?: GetExportReportingDataGetDatasetsResponse.Data.Item[]; diff --git a/src/api/resources/segments/types/index.ts b/src/api/resources/segments/types/index.ts index a934b01a..a0c4ebf2 100644 --- a/src/api/resources/segments/types/index.ts +++ b/src/api/resources/segments/types/index.ts @@ -1 +1 @@ -export * from "./Segment.js"; +export * from "./types.js"; diff --git a/src/api/resources/unstable/resources/segments/types/Segment.ts b/src/api/resources/segments/types/types.ts similarity index 85% rename from src/api/resources/unstable/resources/segments/types/Segment.ts rename to src/api/resources/segments/types/types.ts index 5fbb6b53..2d06b0f4 100644 --- a/src/api/resources/unstable/resources/segments/types/Segment.ts +++ b/src/api/resources/segments/types/types.ts @@ -5,17 +5,17 @@ */ export interface Segment { /** The type of object. */ - type?: "segment"; + type: "segment"; /** The unique identifier representing the segment. */ - id?: string; + id: string; /** The name of the segment. */ - name?: string; + name: string; /** The time the segment was created. */ - created_at?: number; + created_at: number; /** The time the segment was updated. */ - updated_at?: number; + updated_at: number; /** Type of the contact: contact (lead) or user. */ - person_type?: Segment.PersonType; + person_type: Segment.PersonType; /** The number of items in the user segment. It's returned when `include_count=true` is included in the request. */ count?: number; } diff --git a/src/api/resources/subscriptionTypes/types/index.ts b/src/api/resources/subscriptionTypes/types/index.ts index b6a27359..a0c4ebf2 100644 --- a/src/api/resources/subscriptionTypes/types/index.ts +++ b/src/api/resources/subscriptionTypes/types/index.ts @@ -1 +1 @@ -export * from "./SubscriptionType.js"; +export * from "./types.js"; diff --git a/src/api/resources/subscriptionTypes/types/SubscriptionType.ts b/src/api/resources/subscriptionTypes/types/types.ts similarity index 100% rename from src/api/resources/subscriptionTypes/types/SubscriptionType.ts rename to src/api/resources/subscriptionTypes/types/types.ts diff --git a/src/api/resources/tags/client/Client.ts b/src/api/resources/tags/client/Client.ts index 33235bf3..eb10c94d 100644 --- a/src/api/resources/tags/client/Client.ts +++ b/src/api/resources/tags/client/Client.ts @@ -470,14 +470,14 @@ export class TagsClient { public create( request: Intercom.TagsCreateRequestBody, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); } private async __create( request: Intercom.TagsCreateRequestBody, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, @@ -505,7 +505,7 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.TagBasic, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -549,14 +549,14 @@ export class TagsClient { public find( request: Intercom.FindTagRequest, requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); } private async __find( request: Intercom.FindTagRequest, requestOptions?: TagsClient.RequestOptions, - ): Promise> { + ): Promise> { const { tag_id: tagId } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -582,7 +582,7 @@ export class TagsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.TagBasic, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { diff --git a/src/api/resources/tags/types/Tag.ts b/src/api/resources/tags/types/Tag.ts deleted file mode 100644 index 3a2c7940..00000000 --- a/src/api/resources/tags/types/Tag.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A tag allows you to label your contacts, companies, and conversations and list them using that tag. - */ -export interface Tag { - /** value is "tag" */ - type: "tag"; - /** The id of the tag */ - id: string; - /** The name of the tag */ - name: string; - /** The time when the tag was applied to the object */ - applied_at?: number; - applied_by?: Intercom.Reference; -} diff --git a/src/api/resources/tags/types/TagBasic.ts b/src/api/resources/tags/types/TagBasic.ts deleted file mode 100644 index 8e8b815d..00000000 --- a/src/api/resources/tags/types/TagBasic.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A tag allows you to label your contacts, companies, and conversations and list them using that tag. - */ -export interface TagBasic { - /** value is "tag" */ - type?: string; - /** The id of the tag */ - id?: string; - /** The name of the tag */ - name?: string; -} diff --git a/src/api/resources/tags/types/TagsCreateRequestBody.ts b/src/api/resources/tags/types/TagsCreateRequestBody.ts deleted file mode 100644 index 3858b435..00000000 --- a/src/api/resources/tags/types/TagsCreateRequestBody.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type TagsCreateRequestBody = - | Intercom.CreateOrUpdateTagRequest - | Intercom.TagCompanyRequest - | Intercom.UntagCompanyRequest - | Intercom.TagMultipleUsersRequest; diff --git a/src/api/resources/tags/types/index.ts b/src/api/resources/tags/types/index.ts index 9a358541..a0c4ebf2 100644 --- a/src/api/resources/tags/types/index.ts +++ b/src/api/resources/tags/types/index.ts @@ -1,3 +1 @@ -export * from "./Tag.js"; -export * from "./TagBasic.js"; -export * from "./TagsCreateRequestBody.js"; +export * from "./types.js"; diff --git a/src/api/resources/tags/types/types.ts b/src/api/resources/tags/types/types.ts new file mode 100644 index 00000000..d34f5231 --- /dev/null +++ b/src/api/resources/tags/types/types.ts @@ -0,0 +1,37 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../index.js"; + +export type TagsCreateRequestBody = + | Intercom.CreateOrUpdateTagRequest + | Intercom.TagCompanyRequest + | Intercom.UntagCompanyRequest + | Intercom.TagMultipleUsersRequest; + +/** + * A tag allows you to label your contacts, companies, and conversations and list them using that tag. + */ +export interface Tag { + /** value is "tag" */ + type: "tag"; + /** The id of the tag */ + id: string; + /** The name of the tag */ + name: string; + /** The time when the tag was applied to the object. Only present when the tag is returned as part of a tagging operation on a contact, conversation, or ticket. */ + applied_at?: number; + /** The admin who applied the tag. Only present when the tag is returned as part of a tagging operation on a contact, conversation, or ticket. */ + applied_by?: Intercom.Reference; +} + +/** + * A tag allows you to label your contacts, companies, and conversations and list them using that tag. + */ +export interface TagBasic { + /** value is "tag" */ + type?: string; + /** The id of the tag */ + id?: string; + /** The name of the tag */ + name?: string; +} diff --git a/src/api/resources/teams/types/index.ts b/src/api/resources/teams/types/index.ts index bc100e99..a0c4ebf2 100644 --- a/src/api/resources/teams/types/index.ts +++ b/src/api/resources/teams/types/index.ts @@ -1 +1 @@ -export * from "./Team.js"; +export * from "./types.js"; diff --git a/src/api/resources/teams/types/Team.ts b/src/api/resources/teams/types/types.ts similarity index 89% rename from src/api/resources/teams/types/Team.ts rename to src/api/resources/teams/types/types.ts index 8b038649..fa5ee2ef 100644 --- a/src/api/resources/teams/types/Team.ts +++ b/src/api/resources/teams/types/types.ts @@ -7,13 +7,13 @@ import type * as Intercom from "../../../index.js"; */ export interface Team { /** Value is always "team" */ - type?: string; + type: string; /** The id of the team */ - id?: string; + id: string; /** The name of the team */ - name?: string; + name: string; /** The list of admin IDs that are a part of the team. */ - admin_ids?: number[]; + admin_ids: number[]; admin_priority_level?: Intercom.AdminPriorityLevel; /** The assignment limit for the team. This field is only present when the team's distribution type is load balanced. */ assignment_limit?: number; diff --git a/src/api/resources/tickets/client/Client.ts b/src/api/resources/tickets/client/Client.ts index d7456f7f..2654cb75 100644 --- a/src/api/resources/tickets/client/Client.ts +++ b/src/api/resources/tickets/client/Client.ts @@ -61,6 +61,18 @@ export class TicketsClient { * await client.tickets.reply({ * ticket_id: "123", * body: { + * message_type: "note", + * type: "admin", + * body: "This note will be cross-posted to all linked conversations.", + * admin_id: "3156780", + * cross_post: true + * } + * }) + * + * @example + * await client.tickets.reply({ + * ticket_id: "123", + * body: { * message_type: "quick_reply", * type: "admin", * admin_id: "3156780", @@ -484,12 +496,17 @@ export class TicketsClient { } /** - * You can delete a ticket using the Intercom provided ID. + * {% admonition type="warning" name="Irreversible operation" %} + * Deleting a ticket is permanent and cannot be reversed. + * {% /admonition %} + * + * Deleting a ticket permanently removes it from the inbox. All sensitive data is deleted, including admin and user replies, ticket attributes, uploads, and related content. The ticket will still appear in reporting, though some data may be incomplete due to the deletion. * * @param {Intercom.DeleteTicketRequest} request * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} + * @throws {@link Intercom.ForbiddenError} * @throws {@link Intercom.NotFoundError} * * @example @@ -500,14 +517,14 @@ export class TicketsClient { public deleteTicket( request: Intercom.DeleteTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__deleteTicket(request, requestOptions)); } private async __deleteTicket( request: Intercom.DeleteTicketRequest, requestOptions?: TicketsClient.RequestOptions, - ): Promise> { + ): Promise> { const { ticket_id: ticketId } = request; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( @@ -533,7 +550,7 @@ export class TicketsClient { logging: this._options.logging, }); if (_response.ok) { - return { data: _response.body as Intercom.DeleteTicketResponse, rawResponse: _response.rawResponse }; + return { data: _response.body as Intercom.TicketDeleted, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -543,6 +560,8 @@ export class TicketsClient { _response.error.body as Intercom.Error_, _response.rawResponse, ); + case 403: + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: diff --git a/src/api/resources/tickets/client/requests/FindTicketRequest.ts b/src/api/resources/tickets/client/requests/FindTicketRequest.ts index f3f1e814..10aeef05 100644 --- a/src/api/resources/tickets/client/requests/FindTicketRequest.ts +++ b/src/api/resources/tickets/client/requests/FindTicketRequest.ts @@ -7,6 +7,11 @@ * } */ export interface FindTicketRequest { - /** The unique identifier for the ticket which is given by Intercom. */ + /** + * The unique identifier for the ticket which is given by Intercom. + * {% admonition type="info" name="Not the Inbox ticket ID" %} + * This is the internal `id` field from the API response, not the `ticket_id` displayed in the Intercom Inbox (e.g., #12345). Use the `id` value from the ticket object returned by the API. + * {% /admonition %} + */ ticket_id: string; } diff --git a/src/api/resources/tickets/client/requests/ReplyToTicketRequest.ts b/src/api/resources/tickets/client/requests/ReplyToTicketRequest.ts index b67d7011..d8e43c22 100644 --- a/src/api/resources/tickets/client/requests/ReplyToTicketRequest.ts +++ b/src/api/resources/tickets/client/requests/ReplyToTicketRequest.ts @@ -29,6 +29,18 @@ import type * as Intercom from "../../../../index.js"; * { * ticket_id: "123", * body: { + * message_type: "note", + * type: "admin", + * body: "This note will be cross-posted to all linked conversations.", + * admin_id: "3156780", + * cross_post: true + * } + * } + * + * @example + * { + * ticket_id: "123", + * body: { * message_type: "quick_reply", * type: "admin", * admin_id: "3156780", diff --git a/src/api/resources/tickets/client/requests/UpdateTicketRequest.ts b/src/api/resources/tickets/client/requests/UpdateTicketRequest.ts index 7ba6219a..9b56dbef 100644 --- a/src/api/resources/tickets/client/requests/UpdateTicketRequest.ts +++ b/src/api/resources/tickets/client/requests/UpdateTicketRequest.ts @@ -1,5 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Intercom from "../../../../index.js"; + /** * @example * { @@ -45,23 +47,14 @@ * ticket_state_id: "123" * } */ -export interface UpdateTicketRequest { - /** The unique identifier for the ticket which is given by Intercom */ +export interface UpdateTicketRequest extends Intercom.UpdateTicketRequestBody { + /** + * The unique identifier for the ticket which is given by Intercom. + * {% admonition type="info" name="Not the Inbox ticket ID" %} + * This is the internal `id` field from the API response, not the `ticket_id` displayed in the Intercom Inbox (e.g., #12345). Use the `id` value from the ticket object returned by the API. + * {% /admonition %} + */ ticket_id: string; - /** The attributes set on the ticket. */ - ticket_attributes?: Record; - /** The ID of the ticket state associated with the ticket type. */ - ticket_state_id?: string; - /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. */ - company_id?: string; - /** Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. */ - open?: boolean; - /** Specify whether the ticket is visible to users. */ - is_shared?: boolean; - /** The time you want the ticket to reopen. */ - snoozed_until?: number; - /** The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. */ - admin_id?: number; - /** The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. */ - assignee_id?: string; + /** Option to disable notifications when a Ticket is updated. */ + skip_notifications?: boolean; } diff --git a/src/api/resources/tickets/types/DeleteTicketResponse.ts b/src/api/resources/tickets/types/DeleteTicketResponse.ts deleted file mode 100644 index cdad7f2d..00000000 --- a/src/api/resources/tickets/types/DeleteTicketResponse.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response when a ticket is deleted. - */ -export interface DeleteTicketResponse { - /** The unique identifier for the ticket. */ - id?: string; - /** always ticket */ - object?: "ticket"; - /** Whether the ticket is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/tickets/types/Ticket.ts b/src/api/resources/tickets/types/Ticket.ts deleted file mode 100644 index 5e686d50..00000000 --- a/src/api/resources/tickets/types/Ticket.ts +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Tickets are how you track requests from your users. - */ -export interface Ticket { - /** Always ticket */ - type: "ticket"; - /** The unique identifier for the ticket which is given by Intercom. */ - id: string; - /** The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. */ - ticket_id: string; - /** Category of the Ticket. */ - category: Ticket.Category; - ticket_attributes: Intercom.TicketCustomAttributes; - ticket_state?: Intercom.TicketState; - ticket_type?: Intercom.TicketType; - contacts: Intercom.TicketContacts; - /** The id representing the admin assigned to the ticket. */ - admin_assignee_id?: string; - /** The id representing the team assigned to the ticket. */ - team_assignee_id?: string; - /** The time the ticket was created as a UTC Unix timestamp. */ - created_at?: number; - /** The last time the ticket was updated as a UTC Unix timestamp. */ - updated_at?: number; - /** Whether or not the ticket is open. If false, the ticket is closed. */ - open?: boolean; - /** The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed. */ - snoozed_until?: number; - linked_objects?: Intercom.LinkedObjectList; - ticket_parts?: Intercom.TicketParts; - /** Whether or not the ticket is shared with the customer. */ - is_shared?: boolean; -} - -export namespace Ticket { - /** Category of the Ticket. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/tickets/types/TicketContacts.ts b/src/api/resources/tickets/types/TicketContacts.ts deleted file mode 100644 index 1d775525..00000000 --- a/src/api/resources/tickets/types/TicketContacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The list of contacts affected by a ticket. - */ -export interface TicketContacts { - /** always contact.list */ - type?: "contact.list"; - /** The list of contacts affected by this ticket. */ - contacts?: Intercom.ContactReference[]; -} diff --git a/src/api/resources/tickets/types/TicketPart.ts b/src/api/resources/tickets/types/TicketPart.ts deleted file mode 100644 index ffe19d95..00000000 --- a/src/api/resources/tickets/types/TicketPart.ts +++ /dev/null @@ -1,109 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A Ticket Part represents a message in the ticket. - */ -export interface TicketPart { - /** Always ticket_part */ - type?: string; - /** The id representing the ticket part. */ - id?: string; - /** The type of ticket part. */ - part_type?: string; - /** The message body, which may contain HTML. */ - body?: string; - /** The previous state of the ticket. */ - previous_ticket_state?: TicketPart.PreviousTicketState; - /** The state of the ticket. */ - ticket_state?: TicketPart.TicketState; - /** The time the ticket part was created. */ - created_at?: number; - /** The last time the ticket part was updated. */ - updated_at?: number; - /** The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.) */ - assigned_to?: Intercom.Reference; - author?: Intercom.TicketPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.PartAttachment[]; - /** The external id of the ticket part */ - external_id?: string; - /** Whether or not the ticket part has been redacted. */ - redacted?: boolean; - /** The app package code if this part was created via API. Note this field won't show if the part was not created via API. */ - app_package_code?: string; - /** The updated attribute data of the ticket part. Only present for attribute update parts. */ - updated_attribute_data?: TicketPart.UpdatedAttributeData; -} - -export namespace TicketPart { - /** The previous state of the ticket. */ - export const PreviousTicketState = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type PreviousTicketState = (typeof PreviousTicketState)[keyof typeof PreviousTicketState]; - /** The state of the ticket. */ - export const TicketState = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type TicketState = (typeof TicketState)[keyof typeof TicketState]; - - /** - * The updated attribute data of the ticket part. Only present for attribute update parts. - */ - export interface UpdatedAttributeData { - /** Information about the attribute that was updated. */ - attribute: UpdatedAttributeData.Attribute; - /** The new value of the attribute. */ - value: UpdatedAttributeData.Value; - } - - export namespace UpdatedAttributeData { - /** - * Information about the attribute that was updated. - */ - export interface Attribute { - /** The type of the object. Always 'attribute'. */ - type: "attribute"; - /** The unique identifier of the attribute. */ - id: string; - /** The human-readable name of the attribute. */ - label: string; - } - - /** - * The new value of the attribute. - */ - export interface Value { - /** The type of the object. Always 'value'. */ - type: "value"; - id: Value.Id; - label: Value.Label; - } - - export namespace Value { - export type Id = - /** - * The value for text/number/decimal/boolean/date attributes, or the ID of the list option for list attributes. */ - | string - | undefined - /** - * Array of file IDs for file attributes. */ - | number[]; - export type Label = - /** - * The display value for text/number/decimal/boolean/date/list attributes. */ - | string - /** - * Array of file names for file attributes. */ - | string[]; - } - } -} diff --git a/src/api/resources/tickets/types/TicketState.ts b/src/api/resources/tickets/types/TicketState.ts deleted file mode 100644 index beef89c7..00000000 --- a/src/api/resources/tickets/types/TicketState.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A ticket state, used to define the state of a ticket. - */ -export interface TicketState { - /** String representing the object's type. Always has the value `ticket_state`. */ - type?: string; - /** The id of the ticket state */ - id?: string; - /** The category of the ticket state */ - category?: TicketState.Category; - /** The state the ticket is currently in, in a human readable form - visible in Intercom */ - internal_label?: string; - /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ - external_label?: string; -} - -export namespace TicketState { - /** The category of the ticket state */ - export const Category = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/tickets/types/TicketStateDetailed.ts b/src/api/resources/tickets/types/TicketStateDetailed.ts deleted file mode 100644 index df97b118..00000000 --- a/src/api/resources/tickets/types/TicketStateDetailed.ts +++ /dev/null @@ -1,44 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A ticket state, used to define the state of a ticket. - */ -export interface TicketStateDetailed { - /** String representing the object's type. Always has the value `ticket_state`. */ - type?: string; - /** The id of the ticket state */ - id?: string; - /** The category of the ticket state */ - category?: TicketStateDetailed.Category; - /** The state the ticket is currently in, in a human readable form - visible in Intercom */ - internal_label?: string; - /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ - external_label?: string; - /** Whether the ticket state is archived */ - archived?: boolean; - /** A list of ticket types associated with a given ticket state. */ - ticket_types?: TicketStateDetailed.TicketTypes; -} - -export namespace TicketStateDetailed { - /** The category of the ticket state */ - export const Category = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; - - /** - * A list of ticket types associated with a given ticket state. - */ - export interface TicketTypes { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of ticket type attributes associated with a given ticket type. */ - data?: (Intercom.TicketType | undefined)[]; - } -} diff --git a/src/api/resources/tickets/types/TicketType.ts b/src/api/resources/tickets/types/TicketType.ts deleted file mode 100644 index 5ad0cd5d..00000000 --- a/src/api/resources/tickets/types/TicketType.ts +++ /dev/null @@ -1,52 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A ticket type, used to define the data fields to be captured in a ticket. - */ -export interface TicketType { - /** String representing the object's type. Always has the value `ticket_type`. */ - type?: string; - /** The id representing the ticket type. */ - id?: string; - /** Category of the Ticket Type. */ - category?: TicketType.Category; - /** The name of the ticket type */ - name?: string; - /** The description of the ticket type */ - description?: string; - /** The icon of the ticket type */ - icon?: string; - /** The id of the workspace that the ticket type belongs to. */ - workspace_id?: string; - ticket_type_attributes?: Intercom.TicketTypeAttributeList; - /** A list of ticket states associated with a given ticket type. */ - ticket_states?: TicketType.TicketStates; - /** Whether the ticket type is archived or not. */ - archived?: boolean; - /** The date and time the ticket type was created. */ - created_at?: number; - /** The date and time the ticket type was last updated. */ - updated_at?: number; -} - -export namespace TicketType { - /** Category of the Ticket Type. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; - - /** - * A list of ticket states associated with a given ticket type. - */ - export interface TicketStates { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of ticket states associated with a given ticket type. */ - data?: (Intercom.TicketState | undefined)[]; - } -} diff --git a/src/api/resources/tickets/types/TicketsReplyRequestBody.ts b/src/api/resources/tickets/types/TicketsReplyRequestBody.ts deleted file mode 100644 index f56d4a42..00000000 --- a/src/api/resources/tickets/types/TicketsReplyRequestBody.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type TicketsReplyRequestBody = Intercom.ContactReplyTicketRequest | Intercom.AdminReplyTicketRequest; diff --git a/src/api/resources/tickets/types/index.ts b/src/api/resources/tickets/types/index.ts index 0802fc77..a0c4ebf2 100644 --- a/src/api/resources/tickets/types/index.ts +++ b/src/api/resources/tickets/types/index.ts @@ -1,8 +1 @@ -export * from "./DeleteTicketResponse.js"; -export * from "./Ticket.js"; -export * from "./TicketContacts.js"; -export * from "./TicketPart.js"; -export * from "./TicketState.js"; -export * from "./TicketStateDetailed.js"; -export * from "./TicketsReplyRequestBody.js"; -export * from "./TicketType.js"; +export * from "./types.js"; diff --git a/src/api/resources/tickets/types/types.ts b/src/api/resources/tickets/types/types.ts new file mode 100644 index 00000000..8ad4d45f --- /dev/null +++ b/src/api/resources/tickets/types/types.ts @@ -0,0 +1,282 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../../../index.js"; + +export type TicketsReplyRequestBody = Intercom.ContactReplyTicketRequest | Intercom.AdminReplyTicketRequest; + +/** + * Tickets are how you track requests from your users. + */ +export interface Ticket { + /** Always ticket */ + type: "ticket"; + /** The unique identifier for the ticket which is given by Intercom. */ + id: string; + /** The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. */ + ticket_id: string; + /** Category of the Ticket. */ + category: Ticket.Category; + ticket_attributes: Intercom.TicketCustomAttributes; + ticket_state?: Intercom.TicketState; + ticket_type?: Intercom.TicketType; + contacts: Intercom.TicketContacts; + /** The id representing the admin assigned to the ticket. */ + admin_assignee_id?: string; + /** The id representing the team assigned to the ticket. */ + team_assignee_id?: string; + /** The time the ticket was created as a UTC Unix timestamp. */ + created_at?: number; + /** The last time the ticket was updated as a UTC Unix timestamp. */ + updated_at?: number; + /** Whether or not the ticket is open. If false, the ticket is closed. */ + open?: boolean; + /** The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed. */ + snoozed_until?: number; + linked_objects?: Intercom.LinkedObjectList; + ticket_parts?: Intercom.TicketParts; + /** Whether or not the ticket is shared with the customer. */ + is_shared?: boolean; +} + +export namespace Ticket { + /** Category of the Ticket. */ + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; +} + +/** + * The list of contacts affected by a ticket. + */ +export interface TicketContacts { + /** always contact.list */ + type?: "contact.list"; + /** The list of contacts affected by this ticket. */ + contacts?: Intercom.ContactReference[]; +} + +/** + * A Ticket Part represents a message in the ticket. + */ +export interface TicketPart { + /** Always ticket_part */ + type: string; + /** The id representing the ticket part. */ + id: string; + /** The type of ticket part. */ + part_type: string; + /** The message body, which may contain HTML. */ + body?: string; + /** The previous state of the ticket. */ + previous_ticket_state?: TicketPart.PreviousTicketState; + /** The state of the ticket. */ + ticket_state?: TicketPart.TicketState; + /** The time the ticket part was created. */ + created_at: number; + /** The last time the ticket part was updated. */ + updated_at: number; + /** The assignee this ticket_part assigned the ticket to, as a reference whose `type` is `admin`, `team` or `bot`. When the part unassigned the ticket, `type` is `nobody_admin` and `id` is `null`. Null when the part did not change the assignment, or when the assignee has since been deleted. */ + assigned_to?: Intercom.Reference; + author: Intercom.TicketPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.PartAttachment[]; + /** The external id of the ticket part */ + external_id?: string; + /** Whether or not the ticket part has been redacted. */ + redacted: boolean; + /** The app package code if this part was created via API. Note this field won't show if the part was not created via API. */ + app_package_code?: string; + /** The updated attribute data of the ticket part. Only present for attribute update parts. */ + updated_attribute_data?: TicketPart.UpdatedAttributeData; +} + +export namespace TicketPart { + /** The previous state of the ticket. */ + export const PreviousTicketState = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + export type PreviousTicketState = (typeof PreviousTicketState)[keyof typeof PreviousTicketState]; + /** The state of the ticket. */ + export const TicketState = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + export type TicketState = (typeof TicketState)[keyof typeof TicketState]; + + /** + * The updated attribute data of the ticket part. Only present for attribute update parts. + */ + export interface UpdatedAttributeData { + /** Information about the attribute that was updated. */ + attribute: UpdatedAttributeData.Attribute; + /** The new value of the attribute. */ + value: UpdatedAttributeData.Value; + } + + export namespace UpdatedAttributeData { + /** + * Information about the attribute that was updated. + */ + export interface Attribute { + /** The type of the object. Always 'attribute'. */ + type: "attribute"; + /** The unique identifier of the attribute. */ + id: string; + /** The human-readable name of the attribute. */ + label: string; + } + + /** + * The new value of the attribute. + */ + export interface Value { + /** The type of the object. Always 'value'. */ + type: "value"; + id: Value.Id; + label: Value.Label; + } + + export namespace Value { + export type Id = + /** + * The value for text/number/decimal/boolean/date attributes, or the ID of the list option for list attributes. */ + | string + | undefined + /** + * Array of file IDs for file attributes. */ + | number[]; + export type Label = + /** + * The display value for text/number/decimal/boolean/date/list attributes. */ + | string + /** + * Array of file names for file attributes. */ + | string[]; + } + } +} + +/** + * A ticket state, used to define the state of a ticket. + */ +export interface TicketState { + /** String representing the object's type. Always has the value `ticket_state`. */ + type?: string; + /** The id of the ticket state */ + id?: string; + /** The category of the ticket state */ + category?: TicketState.Category; + /** The state the ticket is currently in, in a human readable form - visible in Intercom */ + internal_label?: string; + /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ + external_label?: string; +} + +export namespace TicketState { + /** The category of the ticket state */ + export const Category = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; +} + +/** + * A ticket state, used to define the state of a ticket. + */ +export interface TicketStateDetailed { + /** String representing the object's type. Always has the value `ticket_state`. */ + type?: string; + /** The id of the ticket state */ + id?: string; + /** The category of the ticket state */ + category?: TicketStateDetailed.Category; + /** The state the ticket is currently in, in a human readable form - visible in Intercom */ + internal_label?: string; + /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ + external_label?: string; + /** Whether the ticket state is archived */ + archived?: boolean; + /** A list of ticket types associated with a given ticket state. */ + ticket_types?: TicketStateDetailed.TicketTypes; +} + +export namespace TicketStateDetailed { + /** The category of the ticket state */ + export const Category = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; + + /** + * A list of ticket types associated with a given ticket state. + */ + export interface TicketTypes { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket type attributes associated with a given ticket type. */ + data?: (Intercom.TicketType | undefined)[]; + } +} + +/** + * A ticket type, used to define the data fields to be captured in a ticket. + */ +export interface TicketType { + /** String representing the object's type. Always has the value `ticket_type`. */ + type?: string; + /** The id representing the ticket type. */ + id?: string; + /** Category of the Ticket Type. */ + category?: TicketType.Category; + /** The name of the ticket type */ + name?: string; + /** The description of the ticket type */ + description?: string; + /** The icon of the ticket type */ + icon?: string; + /** The id of the workspace that the ticket type belongs to. */ + workspace_id?: string; + ticket_type_attributes?: Intercom.TicketTypeAttributeList; + /** A list of ticket states associated with a given ticket type. */ + ticket_states?: TicketType.TicketStates; + /** Whether the ticket type is archived or not. */ + archived?: boolean; + /** The date and time the ticket type was created. */ + created_at?: number; + /** The date and time the ticket type was last updated. */ + updated_at?: number; +} + +export namespace TicketType { + /** Category of the Ticket Type. */ + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; + + /** + * A list of ticket states associated with a given ticket type. + */ + export interface TicketStates { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket states associated with a given ticket type. */ + data?: (Intercom.TicketState | undefined)[]; + } +} diff --git a/src/api/resources/unstable/resources/admins/types/Admin.ts b/src/api/resources/unstable/resources/admins/types/Admin.ts deleted file mode 100644 index 113cc504..00000000 --- a/src/api/resources/unstable/resources/admins/types/Admin.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Admins are teammate accounts that have access to a workspace. - */ -export interface Admin { - /** String representing the object's type. Always has the value `admin`. */ - type?: string; - /** The id representing the admin. */ - id?: string; - /** The name of the admin. */ - name?: string; - /** The email of the admin. */ - email?: string; - /** The job title of the admin. */ - job_title?: string; - /** Identifies if this admin is currently set in away mode. */ - away_mode_enabled?: boolean; - /** Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ - away_mode_reassign?: boolean; - /** The unique identifier of the away status reason */ - away_status_reason_id?: number; - /** Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ - has_inbox_seat?: boolean; - /** This object represents the avatar associated with the admin. */ - team_ids?: number[]; - /** Image for the associated team or teammate */ - avatar?: string; - team_priority_level?: Intercom.unstable.TeamPriorityLevel; -} diff --git a/src/api/resources/unstable/resources/admins/types/index.ts b/src/api/resources/unstable/resources/admins/types/index.ts deleted file mode 100644 index 838f94f4..00000000 --- a/src/api/resources/unstable/resources/admins/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Admin.js"; diff --git a/src/api/resources/unstable/resources/aiAgent/types/index.ts b/src/api/resources/unstable/resources/aiAgent/types/index.ts deleted file mode 100644 index 27ef772f..00000000 --- a/src/api/resources/unstable/resources/aiAgent/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./AiAgent.js"; diff --git a/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts b/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts deleted file mode 100644 index e65d8d1a..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An external source for External Pages that you add to your Fin Content Library. - */ -export interface ContentImportSource { - /** Always external_page */ - type: "content_import_source"; - /** The unique identifier for the content import source which is given by Intercom. */ - id: number; - /** The time when the content import source was last synced. */ - last_synced_at: number; - /** If you intend to create or update External Pages via the API, this should be set to `api`. */ - sync_behavior: ContentImportSource.SyncBehavior; - /** The status of the content import source. */ - status: ContentImportSource.Status; - /** The URL of the root of the external source. */ - url: string; - /** The time when the content import source was created. */ - created_at: number; - /** The time when the content import source was last updated. */ - updated_at: number; -} - -export namespace ContentImportSource { - /** If you intend to create or update External Pages via the API, this should be set to `api`. */ - export const SyncBehavior = { - Api: "api", - Automatic: "automatic", - Manual: "manual", - } as const; - export type SyncBehavior = (typeof SyncBehavior)[keyof typeof SyncBehavior]; - /** The status of the content import source. */ - export const Status = { - Active: "active", - Deactivated: "deactivated", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts b/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts deleted file mode 100644 index ca3dfb3a..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * This will return a list of the content import sources for the App. - */ -export interface ContentImportSourcesList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.unstable.PagesLink; - /** A count of the total number of content import sources. */ - total_count?: number; - /** An array of Content Import Source objects */ - data?: Intercom.unstable.ContentImportSource[]; -} diff --git a/src/api/resources/unstable/resources/aiContent/types/ExternalPage.ts b/src/api/resources/unstable/resources/aiContent/types/ExternalPage.ts deleted file mode 100644 index 97afb31c..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/ExternalPage.ts +++ /dev/null @@ -1,35 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * External pages that you have added to your Fin Content Library. - */ -export interface ExternalPage { - /** Always external_page */ - type: "external_page"; - /** The unique identifier for the external page which is given by Intercom. */ - id: string; - /** The title of the external page. */ - title: string; - /** The body of the external page in HTML. */ - html: string; - /** The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. */ - url?: string; - /** Whether the external page should be used to answer questions by AI Agent. */ - ai_agent_availability: boolean; - /** Whether the external page should be used to answer questions by AI Copilot. */ - ai_copilot_availability: boolean; - /** Deprecated. Use ai_agent_availability and ai_copilot_availability instead. */ - fin_availability?: boolean; - /** Always en */ - locale: "en"; - /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ - source_id: number; - /** The identifier for the external page which was given by the source. Must be unique for the source. */ - external_id: string; - /** The time when the external page was created. */ - created_at: number; - /** The time when the external page was last updated. */ - updated_at: number; - /** The time when the external page was last ingested. */ - last_ingested_at: number; -} diff --git a/src/api/resources/unstable/resources/aiContent/types/ExternalPagesList.ts b/src/api/resources/unstable/resources/aiContent/types/ExternalPagesList.ts deleted file mode 100644 index 94172e4f..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/ExternalPagesList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * This will return a list of external pages for the App. - */ -export interface ExternalPagesList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.unstable.PagesLink; - /** A count of the total number of external pages. */ - total_count?: number; - /** An array of External Page objects */ - data?: Intercom.unstable.ExternalPage[]; -} diff --git a/src/api/resources/unstable/resources/aiContent/types/index.ts b/src/api/resources/unstable/resources/aiContent/types/index.ts deleted file mode 100644 index 4a084844..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./ContentImportSource.js"; -export * from "./ContentImportSourcesList.js"; -export * from "./ExternalPage.js"; -export * from "./ExternalPagesList.js"; diff --git a/src/api/resources/unstable/resources/aiContentSource/types/index.ts b/src/api/resources/unstable/resources/aiContentSource/types/index.ts deleted file mode 100644 index 190780ca..00000000 --- a/src/api/resources/unstable/resources/aiContentSource/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./ContentSource.js"; diff --git a/src/api/resources/unstable/resources/articles/client/requests/index.ts b/src/api/resources/unstable/resources/articles/client/requests/index.ts deleted file mode 100644 index e0a15786..00000000 --- a/src/api/resources/unstable/resources/articles/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { DeleteArticleRequest } from "./DeleteArticleRequest.js"; -export type { RetrieveArticleRequest } from "./RetrieveArticleRequest.js"; -export type { SearchArticlesRequest } from "./SearchArticlesRequest.js"; diff --git a/src/api/resources/unstable/resources/articles/types/Article.ts b/src/api/resources/unstable/resources/articles/types/Article.ts deleted file mode 100644 index cab08a5d..00000000 --- a/src/api/resources/unstable/resources/articles/types/Article.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * The Articles API is a central place to gather all information and take actions on your articles. Articles can live within collections and sections, or alternatively they can stand alone. - */ -export interface Article extends Intercom.unstable.ArticleListItem { - statistics?: Intercom.unstable.ArticleStatistics; -} diff --git a/src/api/resources/unstable/resources/articles/types/ArticleListItem.ts b/src/api/resources/unstable/resources/articles/types/ArticleListItem.ts deleted file mode 100644 index 9c33e430..00000000 --- a/src/api/resources/unstable/resources/articles/types/ArticleListItem.ts +++ /dev/null @@ -1,49 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * The data returned about your articles when you list them. - */ -export interface ArticleListItem { - /** The type of object - `article`. */ - type?: "article"; - /** The unique identifier for the article which is given by Intercom. */ - id?: string; - /** The id of the workspace which the article belongs to. */ - workspace_id?: string; - /** The title of the article. For multilingual articles, this will be the title of the default language's content. */ - title?: string; - /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ - description?: string; - /** The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. */ - body?: string; - /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ - author_id?: number; - /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ - state?: ArticleListItem.State; - /** The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. */ - created_at?: number; - /** The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. */ - updated_at?: number; - /** The URL of the article. For multilingual articles, this will be the URL of the default language's content. */ - url?: string; - /** The id of the article's parent collection or section. An article without this field stands alone. */ - parent_id?: number; - /** The ids of the article's parent collections or sections. An article without this field stands alone. */ - parent_ids?: number[]; - /** The type of parent, which can either be a `collection` or `section`. */ - parent_type?: string; - /** The default locale of the help center. This field is only returned for multilingual help centers. */ - default_locale?: string; - translated_content?: Intercom.unstable.ArticleTranslatedContent; -} - -export namespace ArticleListItem { - /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ - export const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts b/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts deleted file mode 100644 index c80f22fa..00000000 --- a/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts +++ /dev/null @@ -1,61 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The highlighted results of an Article search. In the examples provided my search query is always "my query". - */ -export interface ArticleSearchHighlights { - /** The ID of the corresponding article. */ - article_id?: string; - /** An Article title highlighted. */ - highlighted_title?: ArticleSearchHighlights.HighlightedTitle.Item[]; - /** An Article description and body text highlighted. */ - highlighted_summary?: ArticleSearchHighlights.HighlightedSummary.Item[][]; -} - -export namespace ArticleSearchHighlights { - export type HighlightedTitle = HighlightedTitle.Item[]; - - export namespace HighlightedTitle { - /** - * A highlighted article title. - */ - export interface Item { - /** The type of text - `highlight` or `plain`. */ - type?: Item.Type; - /** The text of the title. */ - text?: string; - } - - export namespace Item { - /** The type of text - `highlight` or `plain`. */ - export const Type = { - Highlight: "highlight", - Plain: "plain", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } - - export type HighlightedSummary = HighlightedSummary.Item[]; - - export namespace HighlightedSummary { - /** - * An instance of highlighted summary text. - */ - export interface Item { - /** The type of text - `highlight` or `plain`. */ - type?: Item.Type; - /** The text of the title. */ - text?: string; - } - - export namespace Item { - /** The type of text - `highlight` or `plain`. */ - export const Type = { - Highlight: "highlight", - Plain: "plain", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } -} diff --git a/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts b/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts deleted file mode 100644 index 71b72609..00000000 --- a/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * The results of an Article search - */ -export interface ArticleSearchResponse { - /** The type of the object - `list`. */ - type?: "list"; - /** The total number of Articles matching the search query */ - total_count?: number; - /** An object containing the results of the search. */ - data?: ArticleSearchResponse.Data; - pages?: Intercom.unstable.CursorPages; -} - -export namespace ArticleSearchResponse { - /** - * An object containing the results of the search. - */ - export interface Data { - /** An array of Article objects */ - articles?: Intercom.unstable.Article[]; - /** A corresponding array of highlighted Article content */ - highlights?: Intercom.unstable.ArticleSearchHighlights[]; - } -} diff --git a/src/api/resources/unstable/resources/articles/types/InternalArticle.ts b/src/api/resources/unstable/resources/articles/types/InternalArticle.ts deleted file mode 100644 index 9cea2830..00000000 --- a/src/api/resources/unstable/resources/articles/types/InternalArticle.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * The Internal Articles API is a central place to gather all information and take actions on your internal articles. - */ -export type InternalArticle = Intercom.unstable.InternalArticleListItem; diff --git a/src/api/resources/unstable/resources/articles/types/index.ts b/src/api/resources/unstable/resources/articles/types/index.ts deleted file mode 100644 index ac1a15f9..00000000 --- a/src/api/resources/unstable/resources/articles/types/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from "./Article.js"; -export * from "./ArticleListItem.js"; -export * from "./ArticleSearchHighlights.js"; -export * from "./ArticleSearchResponse.js"; -export * from "./InternalArticle.js"; diff --git a/src/api/resources/unstable/resources/brands/types/BrandList.ts b/src/api/resources/unstable/resources/brands/types/BrandList.ts deleted file mode 100644 index 3d7330de..00000000 --- a/src/api/resources/unstable/resources/brands/types/BrandList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A list of brands - */ -export interface BrandList { - /** The type of object */ - type?: string; - data?: Intercom.unstable.Brand[]; -} diff --git a/src/api/resources/unstable/resources/brands/types/index.ts b/src/api/resources/unstable/resources/brands/types/index.ts deleted file mode 100644 index c0d308e0..00000000 --- a/src/api/resources/unstable/resources/brands/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Brand.js"; -export * from "./BrandList.js"; diff --git a/src/api/resources/unstable/resources/calls/types/ListCallsWithTranscriptsResponse.ts b/src/api/resources/unstable/resources/calls/types/ListCallsWithTranscriptsResponse.ts deleted file mode 100644 index ec066741..00000000 --- a/src/api/resources/unstable/resources/calls/types/ListCallsWithTranscriptsResponse.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export interface ListCallsWithTranscriptsResponse { - type?: string; - data?: ListCallsWithTranscriptsResponse.Data.Item[]; -} - -export namespace ListCallsWithTranscriptsResponse { - export type Data = Data.Item[]; - - export namespace Data { - export interface Item extends Intercom.unstable.Call { - /** The call transcript if available, otherwise an empty array. */ - transcript?: Record[]; - /** The status of the transcript if available. */ - transcript_status?: string; - } - } -} diff --git a/src/api/resources/unstable/resources/calls/types/index.ts b/src/api/resources/unstable/resources/calls/types/index.ts deleted file mode 100644 index a7b7c7f7..00000000 --- a/src/api/resources/unstable/resources/calls/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Call.js"; -export * from "./ListCallsWithTranscriptsResponse.js"; diff --git a/src/api/resources/unstable/resources/companies/types/index.ts b/src/api/resources/unstable/resources/companies/types/index.ts deleted file mode 100644 index 19a19f61..00000000 --- a/src/api/resources/unstable/resources/companies/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Company.js"; diff --git a/src/api/resources/unstable/resources/contacts/client/Client.ts b/src/api/resources/unstable/resources/contacts/client/Client.ts deleted file mode 100644 index 531e8b52..00000000 --- a/src/api/resources/unstable/resources/contacts/client/Client.ts +++ /dev/null @@ -1,1251 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace ContactsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your contacts - */ -export class ContactsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ContactsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of companies that are associated to a contact. - * - * @param {Intercom.unstable.ListCompaniesForAContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.contacts.listCompaniesForAContact({ - * id: "63a07ddf05a32042dffac965" - * }) - */ - public listCompaniesForAContact( - request: Intercom.unstable.ListCompaniesForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listCompaniesForAContact(request, requestOptions)); - } - - private async __listCompaniesForAContact( - request: Intercom.unstable.ListCompaniesForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/companies`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ContactAttachedCompanies, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}/companies"); - } - - /** - * You can fetch a list of segments that are associated to a contact. - * - * @param {Intercom.unstable.ListSegmentsForAContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.contacts.listSegmentsForAContact({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public listSegmentsForAContact( - request: Intercom.unstable.ListSegmentsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listSegmentsForAContact(request, requestOptions)); - } - - private async __listSegmentsForAContact( - request: Intercom.unstable.ListSegmentsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/segments`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.ContactSegments, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/{contact_id}/segments", - ); - } - - /** - * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. - * This will return a list of Subscription Type objects that the contact is associated with. - * - * The data property will show a combined list of: - * - * 1.Opt-out subscription types that the user has opted-out from. - * 2.Opt-in subscription types that the user has opted-in to receiving. - * - * @param {Intercom.unstable.ListSubscriptionsForAContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.contacts.listSubscriptionsForAContact({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public listSubscriptionsForAContact( - request: Intercom.unstable.ListSubscriptionsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listSubscriptionsForAContact(request, requestOptions)); - } - - private async __listSubscriptionsForAContact( - request: Intercom.unstable.ListSubscriptionsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/subscriptions`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.SubscriptionTypeList, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/{contact_id}/subscriptions", - ); - } - - /** - * You can fetch a list of all tags that are attached to a specific contact. - * - * @param {Intercom.unstable.ListTagsForAContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.contacts.listTagsForAContact({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public listTagsForAContact( - request: Intercom.unstable.ListTagsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listTagsForAContact(request, requestOptions)); - } - - private async __listTagsForAContact( - request: Intercom.unstable.ListTagsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/tags`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.TagList, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{contact_id}/tags"); - } - - /** - * You can fetch the details of a single contact. - * - * @param {Intercom.unstable.ShowContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.showContact({ - * id: "63a07ddf05a32042dffac965" - * }) - */ - public showContact( - request: Intercom.unstable.ShowContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showContact(request, requestOptions)); - } - - private async __showContact( - request: Intercom.unstable.ShowContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ShowContactResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}"); - } - - /** - * You can update an existing contact (ie. user or lead). - * - * {% admonition type="info" %} - * This endpoint handles both **contact updates** and **custom object associations**. - * - * See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. - * {% /admonition %} - * - * @param {Intercom.unstable.UpdateContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.updateContact({ - * id: "63a07ddf05a32042dffac965", - * email: "joebloggs@intercom.io", - * name: "joe bloggs" - * }) - * - * @example - * await client.unstable.contacts.updateContact({ - * id: "63a07ddf05a32042dffac965", - * custom_attributes: { - * "order": [ - * "21" - * ] - * } - * }) - */ - public updateContact( - request: Intercom.unstable.UpdateContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateContact(request, requestOptions)); - } - - private async __updateContact( - request: Intercom.unstable.UpdateContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.UpdateContactResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/contacts/{id}"); - } - - /** - * You can delete a single contact. - * - * @param {Intercom.unstable.DeleteContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.deleteContact({ - * id: "id" - * }) - */ - public deleteContact( - request: Intercom.unstable.DeleteContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteContact(request, requestOptions)); - } - - private async __deleteContact( - request: Intercom.unstable.DeleteContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.ContactDeleted, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/contacts/{id}"); - } - - /** - * You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. - * - * @param {Intercom.unstable.MergeContactsRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.mergeContact({ - * from: "6762f0d51bb69f9f2193bb7f", - * into: "6762f0d51bb69f9f2193bb80" - * }) - */ - public mergeContact( - request: Intercom.unstable.MergeContactsRequest = {}, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__mergeContact(request, requestOptions)); - } - - private async __mergeContact( - request: Intercom.unstable.MergeContactsRequest = {}, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts/merge", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.MergeContactResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/merge"); - } - - /** - * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. - * - * To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`. - * - * This will accept a query object in the body which will define your filters in order to search for contacts. - * - * {% admonition type="warning" name="Optimizing search queries" %} - * Search queries can be complex, so optimizing them can help the performance of your search. - * Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize - * pagination to limit the number of results returned. The default is `50` results per page. - * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. - * {% /admonition %} - * ### Contact Creation Delay - * - * If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. - * - * ### Nesting & Limitations - * - * You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). - * There are some limitations to the amount of multiple's there can be: - * * There's a limit of max 2 nested filters - * * There's a limit of max 15 filters for each AND or OR group - * - * ### Searching for Timestamp Fields - * - * All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. - * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. - * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). - * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly. - * - * ### Accepted Fields - * - * Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). - * - * | Field | Type | - * | ---------------------------------- | ------------------------------ | - * | id | String | - * | role | String
Accepts user or lead | - * | name | String | - * | avatar | String | - * | owner_id | Integer | - * | email | String | - * | email_domain | String | - * | phone | String | - * | formatted_phone | String | - * | external_id | String | - * | created_at | Date (UNIX Timestamp) | - * | signed_up_at | Date (UNIX Timestamp) | - * | updated_at | Date (UNIX Timestamp) | - * | last_seen_at | Date (UNIX Timestamp) | - * | last_contacted_at | Date (UNIX Timestamp) | - * | last_replied_at | Date (UNIX Timestamp) | - * | last_email_opened_at | Date (UNIX Timestamp) | - * | last_email_clicked_at | Date (UNIX Timestamp) | - * | language_override | String | - * | browser | String | - * | browser_language | String | - * | os | String | - * | location.country | String | - * | location.region | String | - * | location.city | String | - * | unsubscribed_from_emails | Boolean | - * | marked_email_as_spam | Boolean | - * | has_hard_bounced | Boolean | - * | ios_last_seen_at | Date (UNIX Timestamp) | - * | ios_app_version | String | - * | ios_device | String | - * | ios_app_device | String | - * | ios_os_version | String | - * | ios_app_name | String | - * | ios_sdk_version | String | - * | android_last_seen_at | Date (UNIX Timestamp) | - * | android_app_version | String | - * | android_device | String | - * | android_app_name | String | - * | andoid_sdk_version | String | - * | segment_id | String | - * | tag_id | String | - * | custom_attributes.{attribute_name} | String | - * - * ### Accepted Operators - * - * {% admonition type="warning" name="Searching based on `created_at`" %} - * You cannot use the `<=` or `>=` operators to search by `created_at`. - * {% /admonition %} - * - * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). - * - * | Operator | Valid Types | Description | - * | :------- | :------------------------------- | :--------------------------------------------------------------- | - * | = | All | Equals | - * | != | All | Doesn't Equal | - * | IN | All | In
Shortcut for `OR` queries
Values must be in Array | - * | NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | - * | > | Integer
Date (UNIX Timestamp) | Greater than | - * | < | Integer
Date (UNIX Timestamp) | Lower than | - * | ~ | String | Contains | - * | !~ | String | Doesn't Contain | - * | ^ | String | Starts With | - * | $ | String | Ends With | - * - * @param {Intercom.unstable.SearchRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.searchContacts({ - * query: { - * operator: "AND", - * value: [{ - * field: "created_at", - * operator: ">", - * value: "1306054154" - * }] - * }, - * pagination: { - * per_page: 5 - * } - * }) - */ - public searchContacts( - request: Intercom.unstable.SearchRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__searchContacts(request, requestOptions)); - } - - private async __searchContacts( - request: Intercom.unstable.SearchRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.ContactList, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/search"); - } - - /** - * You can fetch a list of all contacts (ie. users or leads) in your workspace. - * {% admonition type="warning" name="Pagination" %} - * You can use pagination to limit the number of results returned. The default is `50` results per page. - * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. - * {% /admonition %} - * - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.listContacts() - */ - public listContacts( - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listContacts(requestOptions)); - } - - private async __listContacts( - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.ContactList, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts"); - } - - /** - * You can create a new contact (ie. user or lead). - * - * @param {Intercom.CreateContactRequestTwo} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.createContact({ - * "email": "joebloggs@intercom.io" - * }) - */ - public createContact( - request?: Intercom.CreateContactRequestTwo, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createContact(request, requestOptions)); - } - - private async __createContact( - request?: Intercom.CreateContactRequestTwo, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.CreateContactResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts"); - } - - /** - * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. - * - * @param {Intercom.unstable.ShowContactByExternalIdRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.showContactByExternalId({ - * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27" - * }) - */ - public showContactByExternalId( - request: Intercom.unstable.ShowContactByExternalIdRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showContactByExternalId(request, requestOptions)); - } - - private async __showContactByExternalId( - request: Intercom.unstable.ShowContactByExternalIdRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { external_id: externalId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/find_by_external_id/${core.url.encodePathParam(externalId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ShowContactByExternalIdResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/find_by_external_id/{external_id}", - ); - } - - /** - * You can archive a single contact. - * - * @param {Intercom.unstable.ArchiveContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.contacts.archiveContact({ - * id: "63a07ddf05a32042dffac965" - * }) - */ - public archiveContact( - request: Intercom.unstable.ArchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__archiveContact(request, requestOptions)); - } - - private async __archiveContact( - request: Intercom.unstable.ArchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/archive`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.ContactArchived, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/archive"); - } - - /** - * You can unarchive a single contact. - * - * @param {Intercom.unstable.UnarchiveContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.contacts.unarchiveContact({ - * id: "63a07ddf05a32042dffac965" - * }) - */ - public unarchiveContact( - request: Intercom.unstable.UnarchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__unarchiveContact(request, requestOptions)); - } - - private async __unarchiveContact( - request: Intercom.unstable.UnarchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/unarchive`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.ContactUnarchived, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/unarchive"); - } - - /** - * Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) - * - * @param {Intercom.unstable.BlockContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.contacts.blockContact({ - * id: "63a07ddf05a32042dffac965" - * }) - */ - public blockContact( - request: Intercom.unstable.BlockContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__blockContact(request, requestOptions)); - } - - private async __blockContact( - request: Intercom.unstable.BlockContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/block`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.ContactBlocked, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/block"); - } -} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/MergeContactsRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/MergeContactsRequest.ts deleted file mode 100644 index 520d7f83..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/MergeContactsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * from: "6762f0d51bb69f9f2193bb7f", - * into: "6762f0d51bb69f9f2193bb80" - * } - */ -export interface MergeContactsRequest { - /** The unique identifier for the contact to merge away from. Must be a lead. */ - from?: string; - /** The unique identifier for the contact to merge into. Must be a user. */ - into?: string; -} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts deleted file mode 100644 index d6f2b0d8..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27" - * } - */ -export interface ShowContactByExternalIdRequest { - /** The external ID of the user that you want to retrieve */ - external_id: string; -} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/index.ts b/src/api/resources/unstable/resources/contacts/client/requests/index.ts deleted file mode 100644 index faea767c..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export type { ArchiveContactRequest } from "./ArchiveContactRequest.js"; -export type { BlockContactRequest } from "./BlockContactRequest.js"; -export type { DeleteContactRequest } from "./DeleteContactRequest.js"; -export type { ListCompaniesForAContactRequest } from "./ListCompaniesForAContactRequest.js"; -export type { ListSegmentsForAContactRequest } from "./ListSegmentsForAContactRequest.js"; -export type { ListSubscriptionsForAContactRequest } from "./ListSubscriptionsForAContactRequest.js"; -export type { ListTagsForAContactRequest } from "./ListTagsForAContactRequest.js"; -export type { MergeContactsRequest } from "./MergeContactsRequest.js"; -export type { ShowContactByExternalIdRequest } from "./ShowContactByExternalIdRequest.js"; -export type { ShowContactRequest } from "./ShowContactRequest.js"; -export type { UnarchiveContactRequest } from "./UnarchiveContactRequest.js"; -export type { UpdateContactRequest } from "./UpdateContactRequest.js"; diff --git a/src/api/resources/unstable/resources/contacts/types/Contact.ts b/src/api/resources/unstable/resources/contacts/types/Contact.ts deleted file mode 100644 index cb4e3927..00000000 --- a/src/api/resources/unstable/resources/contacts/types/Contact.ts +++ /dev/null @@ -1,104 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Contacts represent your leads and users in Intercom. - */ -export interface Contact { - /** The type of object. */ - type?: string; - /** The unique identifier for the contact which is given by Intercom. */ - id?: string; - /** The unique identifier for the contact which is provided by the Client. */ - external_id?: string; - /** The id of the workspace which the contact belongs to. */ - workspace_id?: string; - /** The role of the contact. */ - role?: string; - /** The contact's email. */ - email?: string; - /** The contact's email domain. */ - email_domain?: string; - /** The contacts phone. */ - phone?: string; - /** The contacts phone number normalized to the E164 format */ - formatted_phone?: string; - /** The contacts name. */ - name?: string; - /** The id of an admin that has been assigned account ownership of the contact. */ - owner_id?: number; - /** Whether the contact has had an email sent to them hard bounce. */ - has_hard_bounced?: boolean; - /** Whether the contact has marked an email sent to them as spam. */ - marked_email_as_spam?: boolean; - /** Whether the contact is unsubscribed from emails. */ - unsubscribed_from_emails?: boolean; - /** (UNIX timestamp) The time when the contact was created. */ - created_at?: number; - /** (UNIX timestamp) The time when the contact was last updated. */ - updated_at?: number; - /** (UNIX timestamp) The time specified for when a contact signed up. */ - signed_up_at?: number; - /** (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). */ - last_seen_at?: number; - /** (UNIX timestamp) The time when the contact last messaged in. */ - last_replied_at?: number; - /** (UNIX timestamp) The time when the contact was last messaged. */ - last_contacted_at?: number; - /** (UNIX timestamp) The time when the contact last opened an email. */ - last_email_opened_at?: number; - /** (UNIX timestamp) The time when the contact last clicked a link in an email. */ - last_email_clicked_at?: number; - /** A preferred language setting for the contact, used by Intercom as the language of Fin and the Messenger even if their browser has a different setting. Supports ISO 639-1 two-letter language codes. If an unsupported code is supplied, the field will be set to null. */ - language_override?: string; - /** The name of the browser which the contact is using. */ - browser?: string; - /** The version of the browser which the contact is using. */ - browser_version?: string; - /** The language set by the browser which the contact is using. */ - browser_language?: string; - /** The operating system which the contact is using. */ - os?: string; - /** The name of the Android app which the contact is using. */ - android_app_name?: string; - /** The version of the Android app which the contact is using. */ - android_app_version?: string; - /** The Android device which the contact is using. */ - android_device?: string; - /** The version of the Android OS which the contact is using. */ - android_os_version?: string; - /** The version of the Android SDK which the contact is using. */ - android_sdk_version?: string; - /** (UNIX timestamp) The time when the contact was last seen on an Android device. */ - android_last_seen_at?: number; - /** The name of the iOS app which the contact is using. */ - ios_app_name?: string; - /** The version of the iOS app which the contact is using. */ - ios_app_version?: string; - /** The iOS device which the contact is using. */ - ios_device?: string; - /** The version of iOS which the contact is using. */ - ios_os_version?: string; - /** The version of the iOS SDK which the contact is using. */ - ios_sdk_version?: string; - /** (UNIX timestamp) The last time the contact used the iOS app. */ - ios_last_seen_at?: number; - /** The custom attributes which are set for the contact. */ - custom_attributes?: Record; - avatar?: Contact.Avatar; - tags?: Intercom.unstable.ContactTags; - notes?: Intercom.unstable.ContactNotes; - companies?: Intercom.unstable.ContactCompanies; - location?: Intercom.unstable.ContactLocation; - social_profiles?: Intercom.unstable.ContactSocialProfiles; -} - -export namespace Contact { - export interface Avatar { - /** The type of object */ - type?: string; - /** An image URL containing the avatar of a contact. */ - image_url?: string; - } -} diff --git a/src/api/resources/unstable/resources/contacts/types/CreateContactResponse.ts b/src/api/resources/unstable/resources/contacts/types/CreateContactResponse.ts deleted file mode 100644 index e7bb8739..00000000 --- a/src/api/resources/unstable/resources/contacts/types/CreateContactResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export interface CreateContactResponse extends Intercom.unstable.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/unstable/resources/contacts/types/MergeContactResponse.ts b/src/api/resources/unstable/resources/contacts/types/MergeContactResponse.ts deleted file mode 100644 index 6a253944..00000000 --- a/src/api/resources/unstable/resources/contacts/types/MergeContactResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export interface MergeContactResponse extends Intercom.unstable.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/unstable/resources/contacts/types/ShowContactByExternalIdResponse.ts b/src/api/resources/unstable/resources/contacts/types/ShowContactByExternalIdResponse.ts deleted file mode 100644 index 2e8b3f12..00000000 --- a/src/api/resources/unstable/resources/contacts/types/ShowContactByExternalIdResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export interface ShowContactByExternalIdResponse extends Intercom.unstable.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/unstable/resources/contacts/types/ShowContactResponse.ts b/src/api/resources/unstable/resources/contacts/types/ShowContactResponse.ts deleted file mode 100644 index e8ffabcc..00000000 --- a/src/api/resources/unstable/resources/contacts/types/ShowContactResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export interface ShowContactResponse extends Intercom.unstable.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/unstable/resources/contacts/types/UpdateContactResponse.ts b/src/api/resources/unstable/resources/contacts/types/UpdateContactResponse.ts deleted file mode 100644 index c67687b2..00000000 --- a/src/api/resources/unstable/resources/contacts/types/UpdateContactResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export interface UpdateContactResponse extends Intercom.unstable.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/unstable/resources/contacts/types/index.ts b/src/api/resources/unstable/resources/contacts/types/index.ts deleted file mode 100644 index bf8c1f71..00000000 --- a/src/api/resources/unstable/resources/contacts/types/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./Contact.js"; -export * from "./CreateContactResponse.js"; -export * from "./MergeContactResponse.js"; -export * from "./ShowContactByExternalIdResponse.js"; -export * from "./ShowContactResponse.js"; -export * from "./UpdateContactResponse.js"; diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ListConversationsRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/ListConversationsRequest.ts deleted file mode 100644 index 4908f563..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/ListConversationsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * per_page: 1, - * starting_after: "starting_after" - * } - */ -export interface ListConversationsRequest { - /** How many results per page */ - per_page?: number; - /** String used to get the next page of conversations. */ - starting_after?: string; -} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/RetrieveConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/RetrieveConversationRequest.ts deleted file mode 100644 index 1d207c59..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/RetrieveConversationRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: 1, - * display_as: "plaintext", - * include_translations: true - * } - */ -export interface RetrieveConversationRequest { - /** The id of the conversation to target */ - id: number; - /** Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. */ - display_as?: string; - /** If set to true, conversation parts will be translated to the detected language of the conversation. */ - include_translations?: boolean; -} diff --git a/src/api/resources/unstable/resources/conversations/types/Conversation.ts b/src/api/resources/unstable/resources/conversations/types/Conversation.ts deleted file mode 100644 index d53ea2a2..00000000 --- a/src/api/resources/unstable/resources/conversations/types/Conversation.ts +++ /dev/null @@ -1,69 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. - */ -export interface Conversation { - /** Always conversation. */ - type?: string; - /** The id representing the conversation. */ - id?: string; - /** The title given to the conversation. */ - title?: string; - /** The time the conversation was created. */ - created_at?: number; - /** The last time the conversation was updated. */ - updated_at?: number; - /** The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. */ - waiting_since?: number; - /** If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. */ - snoozed_until?: number; - /** Indicates whether a conversation is open (true) or closed (false). */ - open?: boolean; - /** Can be set to "open", "closed" or "snoozed". */ - state?: Conversation.State; - /** Indicates whether a conversation has been read. */ - read?: boolean; - /** If marked as priority, it will return priority or else not_priority. */ - priority?: Conversation.Priority; - /** The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null. */ - admin_assignee_id?: number; - /** The id of the team assigned to the conversation. If it's not assigned to a team it will return null. */ - team_assignee_id?: string; - /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. */ - company_id?: string; - /** The company associated with the conversation. */ - company?: Intercom.unstable.Company; - tags?: Intercom.unstable.Tags; - conversation_rating?: Intercom.unstable.ConversationRating; - source?: Intercom.unstable.ConversationSource; - contacts?: Intercom.unstable.ConversationContacts; - teammates?: Intercom.unstable.ConversationTeammates; - custom_attributes?: Intercom.unstable.CustomAttributes; - first_contact_reply?: Intercom.unstable.ConversationFirstContactReply; - sla_applied?: Intercom.unstable.SlaApplied; - statistics?: Intercom.unstable.ConversationStatistics; - conversation_parts?: Intercom.unstable.ConversationParts; - linked_objects?: Intercom.unstable.LinkedObjectList; - /** Indicates whether the AI Agent participated in the conversation. */ - ai_agent_participated?: boolean; - ai_agent?: Intercom.unstable.AiAgent; -} - -export namespace Conversation { - /** Can be set to "open", "closed" or "snoozed". */ - export const State = { - Open: "open", - Closed: "closed", - Snoozed: "snoozed", - } as const; - export type State = (typeof State)[keyof typeof State]; - /** If marked as priority, it will return priority or else not_priority. */ - export const Priority = { - Priority: "priority", - NotPriority: "not_priority", - } as const; - export type Priority = (typeof Priority)[keyof typeof Priority]; -} diff --git a/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts b/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts deleted file mode 100644 index ec011db3..00000000 --- a/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export type ManageConversationRequestBody = - | Intercom.unstable.ManageConversationRequestBody.Close - | Intercom.unstable.ManageConversationRequestBody.Snoozed - | Intercom.unstable.ManageConversationRequestBody.Open - | Intercom.unstable.ManageConversationRequestBody.Assignment; - -export namespace ManageConversationRequestBody { - export interface Close extends Intercom.unstable.CloseConversationRequest { - message_type: "close"; - } - - export interface Snoozed extends Intercom.unstable.SnoozeConversationRequest { - message_type: "snoozed"; - } - - export interface Open extends Intercom.unstable.OpenConversationRequest { - message_type: "open"; - } - - export interface Assignment extends Intercom.unstable.AssignConversationRequest { - message_type: "assignment"; - } -} diff --git a/src/api/resources/unstable/resources/conversations/types/index.ts b/src/api/resources/unstable/resources/conversations/types/index.ts deleted file mode 100644 index 7f9a27b5..00000000 --- a/src/api/resources/unstable/resources/conversations/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Conversation.js"; -export * from "./ManageConversationRequestBody.js"; diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts b/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts deleted file mode 100644 index fdb99c2e..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts +++ /dev/null @@ -1,434 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace CustomChannelEventsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class CustomChannelEventsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CustomChannelEventsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.unstable.CustomChannelBaseEvent} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * @throws {@link Intercom.unstable.UnprocessableEntityError} - * - * @example - * await client.unstable.customChannelEvents.notifyNewConversation({ - * event_id: "evt_12345", - * external_conversation_id: "conv_67890", - * contact: { - * type: "user", - * external_id: "user_001", - * name: "Jane Doe", - * email: "jane.doe@example.com" - * } - * }) - */ - public notifyNewConversation( - request: Intercom.unstable.CustomChannelBaseEvent, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyNewConversation(request, requestOptions)); - } - - private async __notifyNewConversation( - request: Intercom.unstable.CustomChannelBaseEvent, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_new_conversation", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.unstable.UnprocessableEntityError( - _response.error.body as unknown, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_new_conversation", - ); - } - - /** - * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.unstable.NotifyNewMessageRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * @throws {@link Intercom.unstable.UnprocessableEntityError} - * - * @example - * await client.unstable.customChannelEvents.notifyNewMessage({ - * event_id: "evt_54321", - * external_conversation_id: "conv_98765", - * contact: { - * type: "user", - * external_id: "user_002", - * name: "John Smith", - * email: "john.smith@example.com" - * }, - * body: "Hello, I need help with my order." - * }) - */ - public notifyNewMessage( - request: Intercom.unstable.NotifyNewMessageRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyNewMessage(request, requestOptions)); - } - - private async __notifyNewMessage( - request: Intercom.unstable.NotifyNewMessageRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_new_message", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.unstable.UnprocessableEntityError( - _response.error.body as unknown, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_new_message", - ); - } - - /** - * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.unstable.NotifyQuickReplySelectedRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * @throws {@link Intercom.unstable.UnprocessableEntityError} - * - * @example - * await client.unstable.customChannelEvents.notifyQuickReplySelected({ - * event_id: "evt_67890", - * external_conversation_id: "conv_13579", - * contact: { - * type: "user", - * external_id: "user_003", - * name: "Alice Example", - * email: "alice@example.com" - * }, - * quick_reply_option_id: "1234" - * }) - */ - public notifyQuickReplySelected( - request: Intercom.unstable.NotifyQuickReplySelectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyQuickReplySelected(request, requestOptions)); - } - - private async __notifyQuickReplySelected( - request: Intercom.unstable.NotifyQuickReplySelectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_quick_reply_selected", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.unstable.UnprocessableEntityError( - _response.error.body as unknown, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_quick_reply_selected", - ); - } - - /** - * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.unstable.NotifyAttributeCollectedRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * @throws {@link Intercom.unstable.UnprocessableEntityError} - * - * @example - * await client.unstable.customChannelEvents.notifyAttributeCollected({ - * event_id: "evt_24680", - * external_conversation_id: "conv_11223", - * contact: { - * type: "user", - * external_id: "user_004", - * name: "Bob Example", - * email: "bob@example.com" - * }, - * attribute: { - * id: "shipping_address", - * value: "123 Main St, Springfield" - * } - * }) - */ - public notifyAttributeCollected( - request: Intercom.unstable.NotifyAttributeCollectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyAttributeCollected(request, requestOptions)); - } - - private async __notifyAttributeCollected( - request: Intercom.unstable.NotifyAttributeCollectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_attribute_collected", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.unstable.UnauthorizedError( - _response.error.body as Intercom.unstable.Error_, - _response.rawResponse, - ); - case 404: - throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new Intercom.unstable.UnprocessableEntityError( - _response.error.body as unknown, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_attribute_collected", - ); - } -} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts deleted file mode 100644 index f0ad7f82..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @example - * { - * event_id: "evt_24680", - * external_conversation_id: "conv_11223", - * contact: { - * type: "user", - * external_id: "user_004", - * name: "Bob Example", - * email: "bob@example.com" - * }, - * attribute: { - * id: "shipping_address", - * value: "123 Main St, Springfield" - * } - * } - */ -export interface NotifyAttributeCollectedRequest extends Intercom.unstable.CustomChannelBaseEvent { - attribute: Intercom.unstable.CustomChannelAttribute; -} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts deleted file mode 100644 index 8a4f252a..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @example - * { - * event_id: "evt_54321", - * external_conversation_id: "conv_98765", - * contact: { - * type: "user", - * external_id: "user_002", - * name: "John Smith", - * email: "john.smith@example.com" - * }, - * body: "Hello, I need help with my order." - * } - */ -export interface NotifyNewMessageRequest extends Intercom.unstable.CustomChannelBaseEvent { - /** The message content sent by the user. */ - body: string; -} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts deleted file mode 100644 index 049df316..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @example - * { - * event_id: "evt_67890", - * external_conversation_id: "conv_13579", - * contact: { - * type: "user", - * external_id: "user_003", - * name: "Alice Example", - * email: "alice@example.com" - * }, - * quick_reply_option_id: "1234" - * } - */ -export interface NotifyQuickReplySelectedRequest extends Intercom.unstable.CustomChannelBaseEvent { - /** Id of the selected quick reply option. */ - quick_reply_option_id: string; -} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/index.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/index.ts deleted file mode 100644 index 702922d9..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { NotifyAttributeCollectedRequest } from "./NotifyAttributeCollectedRequest.js"; -export type { NotifyNewMessageRequest } from "./NotifyNewMessageRequest.js"; -export type { NotifyQuickReplySelectedRequest } from "./NotifyQuickReplySelectedRequest.js"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts b/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts deleted file mode 100644 index 2d9d0fe3..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * custom_object_type_identifier: "Order", - * external_id: "external_id" - * } - */ -export interface GetCustomObjectInstancesByExternalIdRequest { - /** The unique identifier of the custom object type that defines the structure of the custom object instance. */ - custom_object_type_identifier: string; - external_id: string; -} diff --git a/src/api/resources/unstable/resources/customObjectInstances/types/index.ts b/src/api/resources/unstable/resources/customObjectInstances/types/index.ts deleted file mode 100644 index 861f9ce5..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./CustomObjectInstance.js"; diff --git a/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts b/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts deleted file mode 100644 index 06e53b91..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export const LisDataAttributesRequestModel = { - Contact: "contact", - Company: "company", - Conversation: "conversation", -} as const; -export type LisDataAttributesRequestModel = - (typeof LisDataAttributesRequestModel)[keyof typeof LisDataAttributesRequestModel]; diff --git a/src/api/resources/unstable/resources/dataAttributes/types/index.ts b/src/api/resources/unstable/resources/dataAttributes/types/index.ts deleted file mode 100644 index 7e5f4e72..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./DataAttribute.js"; -export * from "./LisDataAttributesRequestModel.js"; diff --git a/src/api/resources/unstable/resources/dataEvents/types/LisDataEventsRequestFilter.ts b/src/api/resources/unstable/resources/dataEvents/types/LisDataEventsRequestFilter.ts deleted file mode 100644 index 57f5d409..00000000 --- a/src/api/resources/unstable/resources/dataEvents/types/LisDataEventsRequestFilter.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type LisDataEventsRequestFilter = - | { - user_id: string; - } - | { - intercom_user_id: string; - } - | { - email: string; - }; diff --git a/src/api/resources/unstable/resources/dataEvents/types/index.ts b/src/api/resources/unstable/resources/dataEvents/types/index.ts deleted file mode 100644 index dbd381c1..00000000 --- a/src/api/resources/unstable/resources/dataEvents/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./DataEvent.js"; -export * from "./LisDataEventsRequestFilter.js"; diff --git a/src/api/resources/unstable/resources/dataExport/types/index.ts b/src/api/resources/unstable/resources/dataExport/types/index.ts deleted file mode 100644 index 881ccc6c..00000000 --- a/src/api/resources/unstable/resources/dataExport/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./DataExport.js"; diff --git a/src/api/resources/unstable/resources/emails/types/EmailList.ts b/src/api/resources/unstable/resources/emails/types/EmailList.ts deleted file mode 100644 index 41aa6d09..00000000 --- a/src/api/resources/unstable/resources/emails/types/EmailList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A list of email settings - */ -export interface EmailList { - /** The type of object */ - type?: string; - data?: Intercom.unstable.EmailSetting[]; -} diff --git a/src/api/resources/unstable/resources/emails/types/index.ts b/src/api/resources/unstable/resources/emails/types/index.ts deleted file mode 100644 index ffc91a1b..00000000 --- a/src/api/resources/unstable/resources/emails/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./EmailList.js"; -export * from "./EmailSetting.js"; diff --git a/src/api/resources/unstable/resources/export/types/PostExportReportingDataEnqueueResponse.ts b/src/api/resources/unstable/resources/export/types/PostExportReportingDataEnqueueResponse.ts deleted file mode 100644 index c15d988e..00000000 --- a/src/api/resources/unstable/resources/export/types/PostExportReportingDataEnqueueResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface PostExportReportingDataEnqueueResponse { - job_identifier?: string; - status?: string; - download_url?: string; - download_expires_at?: string; -} diff --git a/src/api/resources/unstable/resources/export/types/index.ts b/src/api/resources/unstable/resources/export/types/index.ts deleted file mode 100644 index 27e82ed3..00000000 --- a/src/api/resources/unstable/resources/export/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./GetExportReportingDataGetDatasetsResponse.js"; -export * from "./PostExportReportingDataEnqueueResponse.js"; diff --git a/src/api/resources/unstable/resources/helpCenter/types/Collection.ts b/src/api/resources/unstable/resources/helpCenter/types/Collection.ts deleted file mode 100644 index 475021d4..00000000 --- a/src/api/resources/unstable/resources/helpCenter/types/Collection.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Collections are top level containers for Articles within the Help Center. - */ -export interface Collection { - /** The unique identifier for the collection which is given by Intercom. */ - id?: string; - /** The id of the workspace which the collection belongs to. */ - workspace_id?: string; - /** The name of the collection. For multilingual collections, this will be the name of the default language's content. */ - name?: string; - /** The description of the collection. For multilingual help centers, this will be the description of the collection for the default language. */ - description?: string; - /** The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content. */ - created_at?: number; - /** The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content. */ - updated_at?: number; - /** The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language. */ - url?: string; - /** The icon of the collection. */ - icon?: string; - /** The order of the section in relation to others sections within a collection. Values go from `0` upwards. `0` is the default if there's no order. */ - order?: number; - /** The default locale of the help center. This field is only returned for multilingual help centers. */ - default_locale?: string; - translated_content?: Intercom.unstable.GroupTranslatedContent; - /** The id of the parent collection. If `null` then it is the first level collection. */ - parent_id?: string; - /** The id of the help center the collection is in. */ - help_center_id?: number; -} diff --git a/src/api/resources/unstable/resources/helpCenter/types/HelpCenter.ts b/src/api/resources/unstable/resources/helpCenter/types/HelpCenter.ts deleted file mode 100644 index 3715e87f..00000000 --- a/src/api/resources/unstable/resources/helpCenter/types/HelpCenter.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Help Centers contain collections - */ -export interface HelpCenter { - /** The unique identifier for the Help Center which is given by Intercom. */ - id?: string; - /** The id of the workspace which the Help Center belongs to. */ - workspace_id?: string; - /** The time when the Help Center was created. */ - created_at?: number; - /** The time when the Help Center was last updated. */ - updated_at?: number; - /** The identifier of the Help Center. This is used in the URL of the Help Center. */ - identifier?: string; - /** Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ - website_turned_on?: boolean; - /** The display name of the Help Center only seen by teammates. */ - display_name?: string; - /** The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. */ - url?: string; - /** Custom domain configured for the help center */ - custom_domain?: string; -} diff --git a/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts b/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts deleted file mode 100644 index 75bc4786..00000000 --- a/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A list of Help Centers belonging to the App - */ -export interface HelpCenterList { - /** The type of the object - `list`. */ - type?: "list"; - /** An array of Help Center objects */ - data?: Intercom.unstable.HelpCenter[]; -} diff --git a/src/api/resources/unstable/resources/helpCenter/types/index.ts b/src/api/resources/unstable/resources/helpCenter/types/index.ts deleted file mode 100644 index 097e7b49..00000000 --- a/src/api/resources/unstable/resources/helpCenter/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./Collection.js"; -export * from "./HelpCenter.js"; -export * from "./HelpCenterList.js"; diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts b/src/api/resources/unstable/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts deleted file mode 100644 index 6f80cf05..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * folder_id: "folder_id" - * } - */ -export interface SearchInternalArticlesRequest { - /** The ID of the folder to search in. */ - folder_id?: string; -} diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts b/src/api/resources/unstable/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts deleted file mode 100644 index ffd0c32d..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

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

New gifts in store for the jolly season

" - * } - */ -export interface UpdateInternalArticleRequestBody { - /** The unique identifier for the internal article which is given by Intercom. */ - id: number; - /** The title of the article. */ - title?: string; - /** The content of the article. */ - body?: string; - /** The id of the author of the article. */ - author_id?: number; - /** The id of the author of the article. */ - owner_id?: number; -} diff --git a/src/api/resources/unstable/resources/internalArticles/types/InternalArticleSearchResponse.ts b/src/api/resources/unstable/resources/internalArticles/types/InternalArticleSearchResponse.ts deleted file mode 100644 index b7790005..00000000 --- a/src/api/resources/unstable/resources/internalArticles/types/InternalArticleSearchResponse.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * The results of an Internal Article search - */ -export interface InternalArticleSearchResponse { - /** The type of the object - `list`. */ - type?: "list"; - /** The total number of Internal Articles matching the search query */ - total_count?: number; - /** An object containing the results of the search. */ - data?: InternalArticleSearchResponse.Data; - pages?: Intercom.unstable.CursorPages; -} - -export namespace InternalArticleSearchResponse { - /** - * An object containing the results of the search. - */ - export interface Data { - /** An array of Internal Article objects */ - internal_articles?: Intercom.unstable.InternalArticle[]; - } -} diff --git a/src/api/resources/unstable/resources/internalArticles/types/index.ts b/src/api/resources/unstable/resources/internalArticles/types/index.ts deleted file mode 100644 index aedeb96e..00000000 --- a/src/api/resources/unstable/resources/internalArticles/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./InternalArticleListItem.js"; -export * from "./InternalArticleSearchResponse.js"; diff --git a/src/api/resources/unstable/resources/jobs/types/index.ts b/src/api/resources/unstable/resources/jobs/types/index.ts deleted file mode 100644 index c4ca9992..00000000 --- a/src/api/resources/unstable/resources/jobs/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Jobs.js"; diff --git a/src/api/resources/unstable/resources/macros/types/MacroList.ts b/src/api/resources/unstable/resources/macros/types/MacroList.ts deleted file mode 100644 index 0694b02f..00000000 --- a/src/api/resources/unstable/resources/macros/types/MacroList.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A paginated list of macros (saved replies) in the workspace. - */ -export interface MacroList { - /** Always list */ - type?: "list"; - /** The list of macro objects */ - data?: (Intercom.unstable.Macro | undefined)[]; - /** Pagination information */ - pages?: MacroList.Pages; -} - -export namespace MacroList { - /** - * Pagination information - */ - export interface Pages { - /** The type of pagination */ - type?: "pages"; - /** Number of results per page */ - per_page?: number; - /** Cursor for the next page */ - next?: Pages.Next; - } - - export namespace Pages { - /** - * Cursor for the next page - */ - export interface Next { - /** Base64-encoded cursor containing [updated_at, id] for pagination */ - starting_after?: string; - } - } -} diff --git a/src/api/resources/unstable/resources/macros/types/index.ts b/src/api/resources/unstable/resources/macros/types/index.ts deleted file mode 100644 index 46516f7b..00000000 --- a/src/api/resources/unstable/resources/macros/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Macro.js"; -export * from "./MacroList.js"; diff --git a/src/api/resources/unstable/resources/messages/client/requests/index.ts b/src/api/resources/unstable/resources/messages/client/requests/index.ts deleted file mode 100644 index 3571c87e..00000000 --- a/src/api/resources/unstable/resources/messages/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { GetWhatsAppMessageStatusRequest } from "./GetWhatsAppMessageStatusRequest.js"; diff --git a/src/api/resources/unstable/resources/messages/types/index.ts b/src/api/resources/unstable/resources/messages/types/index.ts deleted file mode 100644 index e16d36b7..00000000 --- a/src/api/resources/unstable/resources/messages/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Message.js"; diff --git a/src/api/resources/unstable/resources/news/types/Newsfeed.ts b/src/api/resources/unstable/resources/news/types/Newsfeed.ts deleted file mode 100644 index a42f6306..00000000 --- a/src/api/resources/unstable/resources/news/types/Newsfeed.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A newsfeed is a collection of news items, targeted to a specific audience. - * - * Newsfeeds currently cannot be edited through the API, please refer to [this article](https://www.intercom.com/help/en/articles/6362267-getting-started-with-news) to set up your newsfeeds in Intercom. - */ -export interface Newsfeed { - /** The unique identifier for the newsfeed which is given by Intercom. */ - id?: string; - /** The type of object. */ - type?: "newsfeed"; - /** The name of the newsfeed. This name will never be visible to your users. */ - name?: string; - /** Timestamp for when the newsfeed was created. */ - created_at?: number; - /** Timestamp for when the newsfeed was last updated. */ - updated_at?: number; -} diff --git a/src/api/resources/unstable/resources/news/types/NewsfeedAssignment.ts b/src/api/resources/unstable/resources/news/types/NewsfeedAssignment.ts deleted file mode 100644 index 064483c9..00000000 --- a/src/api/resources/unstable/resources/news/types/NewsfeedAssignment.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Assigns a news item to a newsfeed. - */ -export interface NewsfeedAssignment { - /** The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). */ - newsfeed_id?: number; - /** Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". */ - published_at?: number; -} diff --git a/src/api/resources/unstable/resources/news/types/index.ts b/src/api/resources/unstable/resources/news/types/index.ts deleted file mode 100644 index fe7a29c8..00000000 --- a/src/api/resources/unstable/resources/news/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./Newsfeed.js"; -export * from "./NewsfeedAssignment.js"; -export * from "./NewsItem.js"; diff --git a/src/api/resources/unstable/resources/notes/types/CompanyNote.ts b/src/api/resources/unstable/resources/notes/types/CompanyNote.ts deleted file mode 100644 index d63295c5..00000000 --- a/src/api/resources/unstable/resources/notes/types/CompanyNote.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Notes allow you to annotate and comment on companies. - */ -export interface CompanyNote { - /** String representing the object's type. Always has the value `note`. */ - type?: string; - /** The id of the note. */ - id?: string; - /** The time the note was created. */ - created_at?: number; - /** Represents the company that the note was created about. */ - company?: CompanyNote.Company; - /** Optional. Represents the Admin that created the note. */ - author?: Intercom.unstable.Admin; - /** The body text of the note. */ - body?: string; -} - -export namespace CompanyNote { - /** - * Represents the company that the note was created about. - */ - export interface Company { - /** String representing the object's type. Always has the value `company`. */ - type?: string; - /** The id of the company. */ - id?: string; - } -} diff --git a/src/api/resources/unstable/resources/notes/types/Note.ts b/src/api/resources/unstable/resources/notes/types/Note.ts deleted file mode 100644 index 571bce49..00000000 --- a/src/api/resources/unstable/resources/notes/types/Note.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Notes allow you to annotate and comment on your contacts. - */ -export interface Note { - /** String representing the object's type. Always has the value `note`. */ - type?: string; - /** The id of the note. */ - id?: string; - /** The time the note was created. */ - created_at?: number; - /** Represents the contact that the note was created about. */ - contact?: Note.Contact; - /** Optional. Represents the Admin that created the note. */ - author?: Intercom.unstable.Admin; - /** The body text of the note. */ - body?: string; -} - -export namespace Note { - /** - * Represents the contact that the note was created about. - */ - export interface Contact { - /** String representing the object's type. Always has the value `contact`. */ - type?: string; - /** The id of the contact. */ - id?: string; - } -} diff --git a/src/api/resources/unstable/resources/notes/types/index.ts b/src/api/resources/unstable/resources/notes/types/index.ts deleted file mode 100644 index 0e6d3d17..00000000 --- a/src/api/resources/unstable/resources/notes/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./CompanyNote.js"; -export * from "./Note.js"; diff --git a/src/api/resources/unstable/resources/segments/types/index.ts b/src/api/resources/unstable/resources/segments/types/index.ts deleted file mode 100644 index a934b01a..00000000 --- a/src/api/resources/unstable/resources/segments/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Segment.js"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts b/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts deleted file mode 100644 index b6a27359..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./SubscriptionType.js"; diff --git a/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts b/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts deleted file mode 100644 index 9f3ab1dc..00000000 --- a/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export type CreateTagRequestBody = - | Intercom.unstable.CreateOrUpdateTagRequest - | Intercom.unstable.TagCompanyRequest - | Intercom.unstable.UntagCompanyRequest - | Intercom.unstable.TagMultipleUsersRequest; diff --git a/src/api/resources/unstable/resources/tags/types/Tag.ts b/src/api/resources/unstable/resources/tags/types/Tag.ts deleted file mode 100644 index f62cbefb..00000000 --- a/src/api/resources/unstable/resources/tags/types/Tag.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A tag allows you to label your contacts, companies, and conversations and list them using that tag. - */ -export interface Tag { - /** value is "tag" */ - type?: string; - /** The id of the tag */ - id?: string; - /** The name of the tag */ - name?: string; - /** The time when the tag was applied to the object */ - applied_at?: number; - applied_by?: Intercom.unstable.Reference; -} diff --git a/src/api/resources/unstable/resources/tags/types/TagBasic.ts b/src/api/resources/unstable/resources/tags/types/TagBasic.ts deleted file mode 100644 index 8e8b815d..00000000 --- a/src/api/resources/unstable/resources/tags/types/TagBasic.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A tag allows you to label your contacts, companies, and conversations and list them using that tag. - */ -export interface TagBasic { - /** value is "tag" */ - type?: string; - /** The id of the tag */ - id?: string; - /** The name of the tag */ - name?: string; -} diff --git a/src/api/resources/unstable/resources/tags/types/index.ts b/src/api/resources/unstable/resources/tags/types/index.ts deleted file mode 100644 index f1b106ee..00000000 --- a/src/api/resources/unstable/resources/tags/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./CreateTagRequestBody.js"; -export * from "./Tag.js"; -export * from "./TagBasic.js"; diff --git a/src/api/resources/unstable/resources/teams/client/requests/index.ts b/src/api/resources/unstable/resources/teams/client/requests/index.ts deleted file mode 100644 index 6497a22a..00000000 --- a/src/api/resources/unstable/resources/teams/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { RetrieveTeamRequest } from "./RetrieveTeamRequest.js"; diff --git a/src/api/resources/unstable/resources/teams/types/index.ts b/src/api/resources/unstable/resources/teams/types/index.ts deleted file mode 100644 index bc100e99..00000000 --- a/src/api/resources/unstable/resources/teams/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Team.js"; diff --git a/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts b/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts deleted file mode 100644 index 8ea2c5e7..00000000 --- a/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "id" - * } - */ -export interface DeleteTicketRequest { - /** The unique identifier for the ticket which is given by Intercom. */ - id: string; -} diff --git a/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts b/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts deleted file mode 100644 index cdad7f2d..00000000 --- a/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response when a ticket is deleted. - */ -export interface DeleteTicketResponse { - /** The unique identifier for the ticket. */ - id?: string; - /** always ticket */ - object?: "ticket"; - /** Whether the ticket is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/resources/tickets/types/ReplyTicketRequestBody.ts b/src/api/resources/unstable/resources/tickets/types/ReplyTicketRequestBody.ts deleted file mode 100644 index cc0d3384..00000000 --- a/src/api/resources/unstable/resources/tickets/types/ReplyTicketRequestBody.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export type ReplyTicketRequestBody = - | Intercom.unstable.ContactReplyTicketRequest - | Intercom.unstable.AdminReplyTicketRequest; diff --git a/src/api/resources/unstable/resources/tickets/types/Ticket.ts b/src/api/resources/unstable/resources/tickets/types/Ticket.ts deleted file mode 100644 index 1da56448..00000000 --- a/src/api/resources/unstable/resources/tickets/types/Ticket.ts +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Tickets are how you track requests from your users. - */ -export interface Ticket { - /** Always ticket */ - type?: "ticket"; - /** The unique identifier for the ticket which is given by Intercom. */ - id?: string; - /** The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. */ - ticket_id?: string; - /** Category of the Ticket. */ - category?: Ticket.Category; - ticket_attributes?: Intercom.unstable.TicketCustomAttributes; - ticket_state?: Intercom.unstable.TicketState; - ticket_type?: Intercom.unstable.TicketType; - contacts?: Intercom.unstable.TicketContacts; - /** The id representing the admin assigned to the ticket. */ - admin_assignee_id?: string; - /** The id representing the team assigned to the ticket. */ - team_assignee_id?: string; - /** The time the ticket was created as a UTC Unix timestamp. */ - created_at?: number; - /** The last time the ticket was updated as a UTC Unix timestamp. */ - updated_at?: number; - /** Whether or not the ticket is open. If false, the ticket is closed. */ - open?: boolean; - /** The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed. */ - snoozed_until?: number; - linked_objects?: Intercom.unstable.LinkedObjectList; - ticket_parts?: Intercom.unstable.TicketParts; - /** Whether or not the ticket is shared with the customer. */ - is_shared?: boolean; -} - -export namespace Ticket { - /** Category of the Ticket. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts b/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts deleted file mode 100644 index f85afa9f..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * The list of contacts affected by a ticket. - */ -export interface TicketContacts { - /** always contact.list */ - type?: "contact.list"; - /** The list of contacts affected by this ticket. */ - contacts?: Intercom.unstable.ContactReference[]; -} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketPart.ts b/src/api/resources/unstable/resources/tickets/types/TicketPart.ts deleted file mode 100644 index 6ab9ce04..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketPart.ts +++ /dev/null @@ -1,109 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A Ticket Part represents a message in the ticket. - */ -export interface TicketPart { - /** Always ticket_part */ - type?: string; - /** The id representing the ticket part. */ - id?: string; - /** The type of ticket part. */ - part_type?: string; - /** The message body, which may contain HTML. */ - body?: string; - /** The previous state of the ticket. */ - previous_ticket_state?: TicketPart.PreviousTicketState; - /** The state of the ticket. */ - ticket_state?: TicketPart.TicketState; - /** The time the ticket part was created. */ - created_at?: number; - /** The last time the ticket part was updated. */ - updated_at?: number; - /** The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.) */ - assigned_to?: Intercom.unstable.Reference; - author?: Intercom.unstable.TicketPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.unstable.PartAttachment[]; - /** The external id of the ticket part */ - external_id?: string; - /** Whether or not the ticket part has been redacted. */ - redacted?: boolean; - /** The app package code if this part was created via API. Note this field won't show if the part was not created via API. */ - app_package_code?: string; - /** The updated attribute data of the ticket part. Only present for attribute update parts. */ - updated_attribute_data?: TicketPart.UpdatedAttributeData; -} - -export namespace TicketPart { - /** The previous state of the ticket. */ - export const PreviousTicketState = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type PreviousTicketState = (typeof PreviousTicketState)[keyof typeof PreviousTicketState]; - /** The state of the ticket. */ - export const TicketState = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type TicketState = (typeof TicketState)[keyof typeof TicketState]; - - /** - * The updated attribute data of the ticket part. Only present for attribute update parts. - */ - export interface UpdatedAttributeData { - /** Information about the attribute that was updated. */ - attribute: UpdatedAttributeData.Attribute; - /** The new value of the attribute. */ - value: UpdatedAttributeData.Value; - } - - export namespace UpdatedAttributeData { - /** - * Information about the attribute that was updated. - */ - export interface Attribute { - /** The type of the object. Always 'attribute'. */ - type: "attribute"; - /** The unique identifier of the attribute. */ - id: string; - /** The human-readable name of the attribute. */ - label: string; - } - - /** - * The new value of the attribute. - */ - export interface Value { - /** The type of the object. Always 'value'. */ - type: "value"; - id: Value.Id; - label: Value.Label; - } - - export namespace Value { - export type Id = - /** - * The value for text/number/decimal/boolean/date attributes, or the ID of the list option for list attributes. */ - | string - | undefined - /** - * Array of file IDs for file attributes. */ - | number[]; - export type Label = - /** - * The display value for text/number/decimal/boolean/date/list attributes. */ - | string - /** - * Array of file names for file attributes. */ - | string[]; - } - } -} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketState.ts b/src/api/resources/unstable/resources/tickets/types/TicketState.ts deleted file mode 100644 index beef89c7..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketState.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A ticket state, used to define the state of a ticket. - */ -export interface TicketState { - /** String representing the object's type. Always has the value `ticket_state`. */ - type?: string; - /** The id of the ticket state */ - id?: string; - /** The category of the ticket state */ - category?: TicketState.Category; - /** The state the ticket is currently in, in a human readable form - visible in Intercom */ - internal_label?: string; - /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ - external_label?: string; -} - -export namespace TicketState { - /** The category of the ticket state */ - export const Category = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts b/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts deleted file mode 100644 index 1281034c..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts +++ /dev/null @@ -1,44 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A ticket state, used to define the state of a ticket. - */ -export interface TicketStateDetailed { - /** String representing the object's type. Always has the value `ticket_state`. */ - type?: string; - /** The id of the ticket state */ - id?: string; - /** The category of the ticket state */ - category?: TicketStateDetailed.Category; - /** The state the ticket is currently in, in a human readable form - visible in Intercom */ - internal_label?: string; - /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ - external_label?: string; - /** Whether the ticket state is archived */ - archived?: boolean; - /** A list of ticket types associated with a given ticket state. */ - ticket_types?: TicketStateDetailed.TicketTypes; -} - -export namespace TicketStateDetailed { - /** The category of the ticket state */ - export const Category = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; - - /** - * A list of ticket types associated with a given ticket state. - */ - export interface TicketTypes { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of ticket type attributes associated with a given ticket type. */ - data?: (Intercom.unstable.TicketType | undefined)[]; - } -} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketType.ts b/src/api/resources/unstable/resources/tickets/types/TicketType.ts deleted file mode 100644 index bdb7bae4..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketType.ts +++ /dev/null @@ -1,52 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A ticket type, used to define the data fields to be captured in a ticket. - */ -export interface TicketType { - /** String representing the object's type. Always has the value `ticket_type`. */ - type?: string; - /** The id representing the ticket type. */ - id?: string; - /** Category of the Ticket Type. */ - category?: TicketType.Category; - /** The name of the ticket type */ - name?: string; - /** The description of the ticket type */ - description?: string; - /** The icon of the ticket type */ - icon?: string; - /** The id of the workspace that the ticket type belongs to. */ - workspace_id?: string; - ticket_type_attributes?: Intercom.unstable.TicketTypeAttributeList; - /** A list of ticket states associated with a given ticket type. */ - ticket_states?: TicketType.TicketStates; - /** Whether the ticket type is archived or not. */ - archived?: boolean; - /** The date and time the ticket type was created. */ - created_at?: number; - /** The date and time the ticket type was last updated. */ - updated_at?: number; -} - -export namespace TicketType { - /** Category of the Ticket Type. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; - - /** - * A list of ticket states associated with a given ticket type. - */ - export interface TicketStates { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of ticket states associated with a given ticket type. */ - data?: (Intercom.unstable.TicketState | undefined)[]; - } -} diff --git a/src/api/resources/unstable/resources/tickets/types/index.ts b/src/api/resources/unstable/resources/tickets/types/index.ts deleted file mode 100644 index 5cad94df..00000000 --- a/src/api/resources/unstable/resources/tickets/types/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from "./DeleteTicketResponse.js"; -export * from "./ReplyTicketRequestBody.js"; -export * from "./Ticket.js"; -export * from "./TicketContacts.js"; -export * from "./TicketPart.js"; -export * from "./TicketState.js"; -export * from "./TicketStateDetailed.js"; -export * from "./TicketType.js"; diff --git a/src/api/resources/unstable/types/ActivityLog.ts b/src/api/resources/unstable/types/ActivityLog.ts deleted file mode 100644 index e510cac9..00000000 --- a/src/api/resources/unstable/types/ActivityLog.ts +++ /dev/null @@ -1,107 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Activities performed by Admins. - */ -export interface ActivityLog { - /** The id representing the activity. */ - id?: string; - /** Details about the Admin involved in the activity. */ - performed_by?: ActivityLog.PerformedBy; - metadata?: Intercom.unstable.ActivityLogMetadata; - /** The time the activity was created. */ - created_at?: number; - activity_type?: ActivityLog.ActivityType; - /** A sentence or two describing the activity. */ - activity_description?: string; -} - -export namespace ActivityLog { - /** - * Details about the Admin involved in the activity. - */ - export interface PerformedBy { - /** String representing the object's type. Always has the value `admin`. */ - type?: string; - /** The id representing the admin. */ - id?: string; - /** The email of the admin. */ - email?: string; - /** The IP address of the admin. */ - ip?: string; - } - - export const ActivityType = { - AdminConversationAssignmentLimitChange: "admin_conversation_assignment_limit_change", - AdminTicketAssignmentLimitChange: "admin_ticket_assignment_limit_change", - AdminAwayModeChange: "admin_away_mode_change", - AdminDeletion: "admin_deletion", - AdminDeprovisioned: "admin_deprovisioned", - AdminImpersonationEnd: "admin_impersonation_end", - AdminImpersonationStart: "admin_impersonation_start", - AdminInviteChange: "admin_invite_change", - AdminInviteCreation: "admin_invite_creation", - AdminInviteDeletion: "admin_invite_deletion", - AdminLoginFailure: "admin_login_failure", - AdminLoginSuccess: "admin_login_success", - AdminLogout: "admin_logout", - AdminPasswordResetRequest: "admin_password_reset_request", - AdminPasswordResetSuccess: "admin_password_reset_success", - AdminPermissionChange: "admin_permission_change", - AdminProvisioned: "admin_provisioned", - AdminTwoFactorAuthChange: "admin_two_factor_auth_change", - AdminUnauthorizedSignInMethod: "admin_unauthorized_sign_in_method", - AppAdminJoin: "app_admin_join", - AppAuthenticationMethodChange: "app_authentication_method_change", - AppDataDeletion: "app_data_deletion", - AppDataExport: "app_data_export", - AppGoogleSsoDomainChange: "app_google_sso_domain_change", - AppIdentityVerificationChange: "app_identity_verification_change", - AppNameChange: "app_name_change", - AppOutboundAddressChange: "app_outbound_address_change", - AppPackageInstallation: "app_package_installation", - AppPackageTokenRegeneration: "app_package_token_regeneration", - AppPackageUninstallation: "app_package_uninstallation", - AppTeamCreation: "app_team_creation", - AppTeamDeletion: "app_team_deletion", - AppTeamMembershipModification: "app_team_membership_modification", - AppTimezoneChange: "app_timezone_change", - AppWebhookCreation: "app_webhook_creation", - AppWebhookDeletion: "app_webhook_deletion", - ArticlesInMessengerEnabledChange: "articles_in_messenger_enabled_change", - BulkDelete: "bulk_delete", - BulkExport: "bulk_export", - CampaignDeletion: "campaign_deletion", - CampaignStateChange: "campaign_state_change", - ConversationPartDeletion: "conversation_part_deletion", - ConversationTopicChange: "conversation_topic_change", - ConversationTopicCreation: "conversation_topic_creation", - ConversationTopicDeletion: "conversation_topic_deletion", - HelpCenterSettingsChange: "help_center_settings_change", - InboundConversationsChange: "inbound_conversations_change", - InboxAccessChange: "inbox_access_change", - MessageDeletion: "message_deletion", - MessageStateChange: "message_state_change", - MessengerLookAndFeelChange: "messenger_look_and_feel_change", - MessengerSearchRequiredChange: "messenger_search_required_change", - MessengerSpacesChange: "messenger_spaces_change", - OfficeHoursChange: "office_hours_change", - RoleChange: "role_change", - RoleCreation: "role_creation", - RoleDeletion: "role_deletion", - RulesetActivationTitlePreview: "ruleset_activation_title_preview", - RulesetCreation: "ruleset_creation", - RulesetDeletion: "ruleset_deletion", - SearchBrowseEnabledChange: "search_browse_enabled_change", - SearchBrowseRequiredChange: "search_browse_required_change", - SeatChange: "seat_change", - SeatRevoke: "seat_revoke", - SecuritySettingsChange: "security_settings_change", - TemporaryExpectationChange: "temporary_expectation_change", - UpfrontEmailCollectionChange: "upfront_email_collection_change", - WelcomeMessageChange: "welcome_message_change", - } as const; - export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType]; -} diff --git a/src/api/resources/unstable/types/ActivityLogList.ts b/src/api/resources/unstable/types/ActivityLogList.ts deleted file mode 100644 index f570390b..00000000 --- a/src/api/resources/unstable/types/ActivityLogList.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A paginated list of activity logs. - */ -export interface ActivityLogList { - /** String representing the object's type. Always has the value `activity_log.list`. */ - type?: string; - pages?: Intercom.unstable.CursorPages; - /** An array of activity logs */ - activity_logs?: (Intercom.unstable.ActivityLog | undefined)[]; -} diff --git a/src/api/resources/unstable/types/ActivityLogMetadata.ts b/src/api/resources/unstable/types/ActivityLogMetadata.ts deleted file mode 100644 index cbd7324e..00000000 --- a/src/api/resources/unstable/types/ActivityLogMetadata.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Additional data provided about Admin activity. - */ -export interface ActivityLogMetadata { - /** The way the admin signed in. */ - sign_in_method?: string; - /** The unique identifier for the contact which is provided by the Client. */ - external_id?: string; - /** The away mode status which is set to true when away and false when returned. */ - away_mode?: boolean; - /** The reason the Admin is away. */ - away_status_reason?: string; - /** Indicates if conversations should be reassigned while an Admin is away. */ - reassign_conversations?: boolean; - /** The action that initiated the status change. */ - source?: string; - /** Indicates if the status was changed automatically or manually. */ - auto_changed?: string; - /** The ID of the Admin who initiated the activity. */ - update_by?: number; - /** The name of the Admin who initiated the activity. */ - update_by_name?: string; - /** The conversation assignment limit value for an admin. */ - conversation_assignment_limit?: number; - /** The ticket assignment limit value for an admin. */ - ticket_assignment_limit?: number; -} diff --git a/src/api/resources/unstable/types/AddressableList.ts b/src/api/resources/unstable/types/AddressableList.ts deleted file mode 100644 index cbda5a63..00000000 --- a/src/api/resources/unstable/types/AddressableList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A list used to access other resources from a parent model. - */ -export interface AddressableList { - /** The addressable object type */ - type?: string; - /** The id of the addressable object */ - id?: string; - /** Url to get more company resources for this contact */ - url?: string; -} diff --git a/src/api/resources/unstable/types/AdminList.ts b/src/api/resources/unstable/types/AdminList.ts deleted file mode 100644 index 01507d8d..00000000 --- a/src/api/resources/unstable/types/AdminList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of admins associated with a given workspace. - */ -export interface AdminList { - /** String representing the object's type. Always has the value `admin.list`. */ - type?: string; - /** A list of admins associated with a given workspace. */ - admins?: (Intercom.unstable.Admin | undefined)[]; -} diff --git a/src/api/resources/unstable/types/AdminPriorityLevel.ts b/src/api/resources/unstable/types/AdminPriorityLevel.ts deleted file mode 100644 index 1127dadf..00000000 --- a/src/api/resources/unstable/types/AdminPriorityLevel.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Admin priority levels for the team - */ -export interface AdminPriorityLevel { - /** The primary admin ids for the team */ - primary_admin_ids?: number[]; - /** The secondary admin ids for the team */ - secondary_admin_ids?: number[]; -} diff --git a/src/api/resources/unstable/types/AdminReplyConversationRequest.ts b/src/api/resources/unstable/types/AdminReplyConversationRequest.ts deleted file mode 100644 index cf90c85b..00000000 --- a/src/api/resources/unstable/types/AdminReplyConversationRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Payload of the request to reply on behalf of an admin - */ -export interface AdminReplyConversationRequest { - message_type: AdminReplyConversationRequest.MessageType; - type: "admin"; - /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ - body?: string; - /** The id of the admin who is authoring the comment. */ - admin_id: string; - /** The time the reply was created. If not provided, the current time will be used. */ - created_at?: number; - /** The quick reply options to display to the end user. Must be present for quick_reply message types. */ - reply_options?: Intercom.unstable.QuickReplyOption[]; - /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ - attachment_urls?: string[]; - /** A list of files that will be added as attachments. You can include up to 10 files */ - attachment_files?: Intercom.unstable.ConversationAttachmentFiles[]; -} - -export namespace AdminReplyConversationRequest { - export const MessageType = { - Comment: "comment", - Note: "note", - QuickReply: "quick_reply", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; -} diff --git a/src/api/resources/unstable/types/AdminReplyTicketRequest.ts b/src/api/resources/unstable/types/AdminReplyTicketRequest.ts deleted file mode 100644 index 3e2ac1ed..00000000 --- a/src/api/resources/unstable/types/AdminReplyTicketRequest.ts +++ /dev/null @@ -1,38 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to reply on behalf of an admin - */ -export interface AdminReplyTicketRequest { - message_type: AdminReplyTicketRequest.MessageType; - type: "admin"; - /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ - body?: string; - /** The id of the admin who is authoring the comment. */ - admin_id: string; - /** The time the reply was created. If not provided, the current time will be used. */ - created_at?: number; - /** The quick reply options to display. Must be present for quick_reply message types. */ - reply_options?: AdminReplyTicketRequest.ReplyOptions.Item[]; - /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ - attachment_urls?: string[]; -} - -export namespace AdminReplyTicketRequest { - export const MessageType = { - Comment: "comment", - Note: "note", - QuickReply: "quick_reply", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; - export type ReplyOptions = ReplyOptions.Item[]; - - export namespace ReplyOptions { - export interface Item { - /** The text to display in this quick reply option. */ - text: string; - /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment ticket part that is created when a user clicks on this reply option. */ - uuid: string; - } - } -} diff --git a/src/api/resources/unstable/types/AdminWithApp.ts b/src/api/resources/unstable/types/AdminWithApp.ts deleted file mode 100644 index 37c0c32c..00000000 --- a/src/api/resources/unstable/types/AdminWithApp.ts +++ /dev/null @@ -1,45 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Admins are the teammate accounts that have access to a workspace - */ -export interface AdminWithApp { - /** String representing the object's type. Always has the value `admin`. */ - type?: string; - /** The id representing the admin. */ - id?: string; - /** The name of the admin. */ - name?: string; - /** The email of the admin. */ - email?: string; - /** The job title of the admin. */ - job_title?: string; - /** Identifies if this admin is currently set in away mode. */ - away_mode_enabled?: boolean; - /** Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ - away_mode_reassign?: boolean; - /** Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ - has_inbox_seat?: boolean; - /** This is a list of ids of the teams that this admin is part of. */ - team_ids?: number[]; - /** This object represents the avatar associated with the admin. */ - avatar?: AdminWithApp.Avatar; - /** Identifies if this admin's email is verified. */ - email_verified?: boolean; - /** App that the admin belongs to. */ - app?: Intercom.unstable.App; -} - -export namespace AdminWithApp { - /** - * This object represents the avatar associated with the admin. - */ - export interface Avatar { - /** This is a string that identifies the type of the object. It will always have the value `avatar`. */ - type?: string; - /** This object represents the avatar associated with the admin. */ - image_url?: string; - } -} diff --git a/src/api/resources/unstable/types/AiCallResponse.ts b/src/api/resources/unstable/types/AiCallResponse.ts deleted file mode 100644 index 6f90c177..00000000 --- a/src/api/resources/unstable/types/AiCallResponse.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response containing information about a Fin Voice call - */ -export interface AiCallResponse { - /** The unique identifier for the external reference */ - id?: number; - /** The workspace identifier */ - app_id?: number; - /** Phone number in E.164 format for the call */ - user_phone_number?: string; - /** Status of the call. Can be "registered", "in-progress", or a resolution state */ - status?: string; - /** The Intercom call identifier, if the call has been matched */ - intercom_call_id?: string; - /** The external call identifier from the call provider */ - external_call_id?: string; - /** The Intercom conversation identifier, if a conversation has been created */ - intercom_conversation_id?: string; - /** Array of transcript entries for the call */ - call_transcript?: Record[]; - /** Summary of the call conversation, truncated to 256 characters. Empty string if no summary available. */ - call_summary?: string; - /** Array of intent classifications for the call */ - intent?: Record[]; -} diff --git a/src/api/resources/unstable/types/App.ts b/src/api/resources/unstable/types/App.ts deleted file mode 100644 index 67ce2d3c..00000000 --- a/src/api/resources/unstable/types/App.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * App is a workspace on Intercom - */ -export interface App { - /** */ - type?: string; - /** The id of the app. */ - id_code?: string; - /** The name of the app. */ - name?: string; - /** The Intercom region the app is located in. */ - region?: string; - /** The timezone of the region where the app is located. */ - timezone?: string; - /** When the app was created. */ - created_at?: number; - /** Whether or not the app uses identity verification. */ - identity_verification?: boolean; -} diff --git a/src/api/resources/unstable/types/ArticleContent.ts b/src/api/resources/unstable/types/ArticleContent.ts deleted file mode 100644 index bccb5af5..00000000 --- a/src/api/resources/unstable/types/ArticleContent.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The Content of an Article. - */ -export interface ArticleContent { - /** The type of object - `article_content` . */ - type?: "article_content"; - /** The title of the article. */ - title?: string; - /** The description of the article. */ - description?: string; - /** The body of the article. */ - body?: string; - /** The ID of the author of the article. */ - author_id?: number; - /** Whether the article is `published` or is a `draft` . */ - state?: ArticleContent.State; - /** The time when the article was created (seconds). */ - created_at?: number; - /** The time when the article was last updated (seconds). */ - updated_at?: number; - /** The URL of the article. */ - url?: string; -} - -export namespace ArticleContent { - /** Whether the article is `published` or is a `draft` . */ - export const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/types/ArticleList.ts b/src/api/resources/unstable/types/ArticleList.ts deleted file mode 100644 index 67d409ef..00000000 --- a/src/api/resources/unstable/types/ArticleList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of articles for the App. - */ -export interface ArticleList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.unstable.CursorPages; - /** A count of the total number of articles. */ - total_count?: number; - /** An array of Article objects */ - data?: Intercom.unstable.ArticleListItem[]; -} diff --git a/src/api/resources/unstable/types/ArticleStatistics.ts b/src/api/resources/unstable/types/ArticleStatistics.ts deleted file mode 100644 index 16f14f48..00000000 --- a/src/api/resources/unstable/types/ArticleStatistics.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The statistics of an article. - */ -export interface ArticleStatistics { - /** The type of object - `article_statistics`. */ - type?: "article_statistics"; - /** The number of total views the article has received. */ - views?: number; - /** The number of conversations started from the article. */ - conversions?: number; - /** The number of total reactions the article has received. */ - reactions?: number; - /** The percentage of happy reactions the article has received against other types of reaction. */ - happy_reaction_percentage?: number; - /** The percentage of neutral reactions the article has received against other types of reaction. */ - neutral_reaction_percentage?: number; - /** The percentage of sad reactions the article has received against other types of reaction. */ - sad_reaction_percentage?: number; -} diff --git a/src/api/resources/unstable/types/ArticleTranslatedContent.ts b/src/api/resources/unstable/types/ArticleTranslatedContent.ts deleted file mode 100644 index 2e625936..00000000 --- a/src/api/resources/unstable/types/ArticleTranslatedContent.ts +++ /dev/null @@ -1,85 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The Translated Content of an Article. The keys are the locale codes and the values are the translated content of the article. - */ -export interface ArticleTranslatedContent { - /** The type of object - article_translated_content. */ - type?: "article_translated_content"; - /** The content of the article in Arabic */ - ar?: Intercom.unstable.ArticleContent; - /** The content of the article in Bulgarian */ - bg?: Intercom.unstable.ArticleContent; - /** The content of the article in Bosnian */ - bs?: Intercom.unstable.ArticleContent; - /** The content of the article in Catalan */ - ca?: Intercom.unstable.ArticleContent; - /** The content of the article in Czech */ - cs?: Intercom.unstable.ArticleContent; - /** The content of the article in Danish */ - da?: Intercom.unstable.ArticleContent; - /** The content of the article in German */ - de?: Intercom.unstable.ArticleContent; - /** The content of the article in Greek */ - el?: Intercom.unstable.ArticleContent; - /** The content of the article in English */ - en?: Intercom.unstable.ArticleContent; - /** The content of the article in Spanish */ - es?: Intercom.unstable.ArticleContent; - /** The content of the article in Estonian */ - et?: Intercom.unstable.ArticleContent; - /** The content of the article in Finnish */ - fi?: Intercom.unstable.ArticleContent; - /** The content of the article in French */ - fr?: Intercom.unstable.ArticleContent; - /** The content of the article in Hebrew */ - he?: Intercom.unstable.ArticleContent; - /** The content of the article in Croatian */ - hr?: Intercom.unstable.ArticleContent; - /** The content of the article in Hungarian */ - hu?: Intercom.unstable.ArticleContent; - /** The content of the article in Indonesian */ - id?: Intercom.unstable.ArticleContent; - /** The content of the article in Italian */ - it?: Intercom.unstable.ArticleContent; - /** The content of the article in Japanese */ - ja?: Intercom.unstable.ArticleContent; - /** The content of the article in Korean */ - ko?: Intercom.unstable.ArticleContent; - /** The content of the article in Lithuanian */ - lt?: Intercom.unstable.ArticleContent; - /** The content of the article in Latvian */ - lv?: Intercom.unstable.ArticleContent; - /** The content of the article in Mongolian */ - mn?: Intercom.unstable.ArticleContent; - /** The content of the article in Norwegian */ - nb?: Intercom.unstable.ArticleContent; - /** The content of the article in Dutch */ - nl?: Intercom.unstable.ArticleContent; - /** The content of the article in Polish */ - pl?: Intercom.unstable.ArticleContent; - /** The content of the article in Portuguese (Portugal) */ - pt?: Intercom.unstable.ArticleContent; - /** The content of the article in Romanian */ - ro?: Intercom.unstable.ArticleContent; - /** The content of the article in Russian */ - ru?: Intercom.unstable.ArticleContent; - /** The content of the article in Slovenian */ - sl?: Intercom.unstable.ArticleContent; - /** The content of the article in Serbian */ - sr?: Intercom.unstable.ArticleContent; - /** The content of the article in Swedish */ - sv?: Intercom.unstable.ArticleContent; - /** The content of the article in Turkish */ - tr?: Intercom.unstable.ArticleContent; - /** The content of the article in Vietnamese */ - vi?: Intercom.unstable.ArticleContent; - /** The content of the article in Portuguese (Brazil) */ - "pt-BR"?: Intercom.unstable.ArticleContent; - /** The content of the article in Chinese (China) */ - "zh-CN"?: Intercom.unstable.ArticleContent; - /** The content of the article in Chinese (Taiwan) */ - "zh-TW"?: Intercom.unstable.ArticleContent; -} diff --git a/src/api/resources/unstable/types/AssignConversationRequest.ts b/src/api/resources/unstable/types/AssignConversationRequest.ts deleted file mode 100644 index 0e2e8ba8..00000000 --- a/src/api/resources/unstable/types/AssignConversationRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to assign a conversation - */ -export interface AssignConversationRequest { - type: AssignConversationRequest.Type; - /** The id of the admin who is performing the action. */ - admin_id: string; - /** The `id` of the `admin` or `team` which will be assigned the conversation. A conversation can be assigned both an admin and a team.\nSet `0` if you want this assign to no admin or team (ie. Unassigned). */ - assignee_id: string; - /** Optionally you can send a response in the conversation when it is assigned. */ - body?: string; -} - -export namespace AssignConversationRequest { - export const Type = { - Admin: "admin", - Team: "team", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/AwayStatusReason.ts b/src/api/resources/unstable/types/AwayStatusReason.ts deleted file mode 100644 index 01eaf720..00000000 --- a/src/api/resources/unstable/types/AwayStatusReason.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface AwayStatusReason { - type?: string; - /** The unique identifier for the away status reason */ - id?: string; - /** The display text for the away status reason */ - label?: string; - /** The emoji associated with the status reason */ - emoji?: string; - /** The display order of the status reason */ - order?: number; - /** Whether the status reason has been soft deleted */ - deleted?: boolean; - /** The Unix timestamp when the status reason was created */ - created_at?: number; - /** The Unix timestamp when the status reason was last updated */ - updated_at?: number; -} diff --git a/src/api/resources/unstable/types/CallList.ts b/src/api/resources/unstable/types/CallList.ts deleted file mode 100644 index bd332337..00000000 --- a/src/api/resources/unstable/types/CallList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A paginated list of calls. - */ -export interface CallList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of calls. */ - data?: Intercom.unstable.Call[]; - /** Total number of items available. */ - total_count?: number; - pages?: Intercom.unstable.CursorPages; -} diff --git a/src/api/resources/unstable/types/CloseConversationRequest.ts b/src/api/resources/unstable/types/CloseConversationRequest.ts deleted file mode 100644 index 0c75f0c3..00000000 --- a/src/api/resources/unstable/types/CloseConversationRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to close a conversation - */ -export interface CloseConversationRequest { - type: "admin"; - /** The id of the admin who is performing the action. */ - admin_id: string; - /** Optionally you can leave a message in the conversation to provide additional context to the user and other teammates. */ - body?: string; -} diff --git a/src/api/resources/unstable/types/CollectionList.ts b/src/api/resources/unstable/types/CollectionList.ts deleted file mode 100644 index 455ae28a..00000000 --- a/src/api/resources/unstable/types/CollectionList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of Collections for the App. - */ -export interface CollectionList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.unstable.CursorPages; - /** A count of the total number of collections. */ - total_count?: number; - /** An array of collection objects */ - data?: Intercom.unstable.Collection[]; -} diff --git a/src/api/resources/unstable/types/CompanyAttachedContacts.ts b/src/api/resources/unstable/types/CompanyAttachedContacts.ts deleted file mode 100644 index d23643b4..00000000 --- a/src/api/resources/unstable/types/CompanyAttachedContacts.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of Contact Objects - */ -export interface CompanyAttachedContacts { - /** The type of object - `list` */ - type?: "list"; - /** An array containing Contact Objects */ - data?: Intercom.unstable.Contact[]; - /** The total number of contacts */ - total_count?: number; - pages?: Intercom.unstable.CursorPages; -} diff --git a/src/api/resources/unstable/types/CompanyAttachedSegments.ts b/src/api/resources/unstable/types/CompanyAttachedSegments.ts deleted file mode 100644 index 73ace745..00000000 --- a/src/api/resources/unstable/types/CompanyAttachedSegments.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of Segment Objects - */ -export interface CompanyAttachedSegments { - /** The type of object - `list` */ - type?: "list"; - /** An array containing Segment Objects */ - data?: Intercom.unstable.Segment[]; -} diff --git a/src/api/resources/unstable/types/CompanyData.ts b/src/api/resources/unstable/types/CompanyData.ts deleted file mode 100644 index 29d3a559..00000000 --- a/src/api/resources/unstable/types/CompanyData.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An object containing data about the companies that a contact is associated with. - */ -export interface CompanyData { - /** The unique identifier for the company which is given by Intercom. */ - id?: string; - /** The type of the object. Always company. */ - type?: "company"; - /** The relative URL of the company. */ - url?: string; -} diff --git a/src/api/resources/unstable/types/CompanyList.ts b/src/api/resources/unstable/types/CompanyList.ts deleted file mode 100644 index 670df0a5..00000000 --- a/src/api/resources/unstable/types/CompanyList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of companies for the App. - */ -export interface CompanyList { - /** The type of object - `list`. */ - type?: "list"; - pages?: Intercom.unstable.CursorPages; - /** The total number of companies. */ - total_count?: number; - /** An array containing Company Objects. */ - data?: Intercom.unstable.Company[]; -} diff --git a/src/api/resources/unstable/types/CompanyScroll.ts b/src/api/resources/unstable/types/CompanyScroll.ts deleted file mode 100644 index 4f876c99..00000000 --- a/src/api/resources/unstable/types/CompanyScroll.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies. - */ -export interface CompanyScroll { - /** The type of object - `list` */ - type?: "list"; - data?: Intercom.unstable.Company[]; - pages?: Intercom.unstable.CursorPages; - /** The total number of companies */ - total_count?: number; - /** The scroll parameter to use in the next request to fetch the next page of results. */ - scroll_param?: string; -} diff --git a/src/api/resources/unstable/types/ContactArchived.ts b/src/api/resources/unstable/types/ContactArchived.ts deleted file mode 100644 index b99dc919..00000000 --- a/src/api/resources/unstable/types/ContactArchived.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * archived contact object - */ -export interface ContactArchived extends Intercom.unstable.ContactReference { - /** Whether the contact is archived or not. */ - archived?: boolean; -} diff --git a/src/api/resources/unstable/types/ContactAttachedCompanies.ts b/src/api/resources/unstable/types/ContactAttachedCompanies.ts deleted file mode 100644 index c9afae62..00000000 --- a/src/api/resources/unstable/types/ContactAttachedCompanies.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of Company Objects - */ -export interface ContactAttachedCompanies { - /** The type of object */ - type?: "list"; - /** An array containing Company Objects */ - companies?: Intercom.unstable.Company[]; - /** The total number of companies associated to this contact */ - total_count?: number; - pages?: Intercom.unstable.PagesLink; -} diff --git a/src/api/resources/unstable/types/ContactBlocked.ts b/src/api/resources/unstable/types/ContactBlocked.ts deleted file mode 100644 index 0d31658f..00000000 --- a/src/api/resources/unstable/types/ContactBlocked.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * blocked contact object - */ -export interface ContactBlocked extends Intercom.unstable.ContactReference { - /** Always true. */ - blocked?: boolean; -} diff --git a/src/api/resources/unstable/types/ContactCompanies.ts b/src/api/resources/unstable/types/ContactCompanies.ts deleted file mode 100644 index c78c8889..00000000 --- a/src/api/resources/unstable/types/ContactCompanies.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * An object with metadata about companies attached to a contact . Up to 10 will be displayed here. Use the url to get more. - */ -export interface ContactCompanies { - /** An array of company data objects attached to the contact. */ - data?: Intercom.unstable.CompanyData[]; - /** Url to get more company resources for this contact */ - url?: string; - /** Integer representing the total number of companies attached to this contact */ - total_count?: number; - /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ - has_more?: boolean; -} diff --git a/src/api/resources/unstable/types/ContactDeleted.ts b/src/api/resources/unstable/types/ContactDeleted.ts deleted file mode 100644 index c5a47283..00000000 --- a/src/api/resources/unstable/types/ContactDeleted.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * deleted contact object - */ -export interface ContactDeleted extends Intercom.unstable.ContactReference { - /** Whether the contact is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/types/ContactList.ts b/src/api/resources/unstable/types/ContactList.ts deleted file mode 100644 index 5ef1b342..00000000 --- a/src/api/resources/unstable/types/ContactList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Contacts are your users in Intercom. - */ -export interface ContactList { - /** Always list */ - type?: "list"; - /** The list of contact objects */ - data?: Intercom.unstable.Contact[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.unstable.CursorPages; -} diff --git a/src/api/resources/unstable/types/ContactLocation.ts b/src/api/resources/unstable/types/ContactLocation.ts deleted file mode 100644 index 73f32530..00000000 --- a/src/api/resources/unstable/types/ContactLocation.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An object containing location meta data about a Intercom contact. - */ -export interface ContactLocation { - /** Always location */ - type?: string; - /** The country that the contact is located in */ - country?: string; - /** The overal region that the contact is located in */ - region?: string; - /** The city that the contact is located in */ - city?: string; -} diff --git a/src/api/resources/unstable/types/ContactNotes.ts b/src/api/resources/unstable/types/ContactNotes.ts deleted file mode 100644 index 88338f22..00000000 --- a/src/api/resources/unstable/types/ContactNotes.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * An object containing notes meta data about the notes that a contact has. Up to 10 will be displayed here. Use the url to get more. - */ -export interface ContactNotes { - /** This object represents the notes attached to a contact. */ - data?: Intercom.unstable.AddressableList[]; - /** Url to get more company resources for this contact */ - url?: string; - /** Int representing the total number of companyies attached to this contact */ - total_count?: number; - /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ - has_more?: boolean; -} diff --git a/src/api/resources/unstable/types/ContactReference.ts b/src/api/resources/unstable/types/ContactReference.ts deleted file mode 100644 index 6ff6080e..00000000 --- a/src/api/resources/unstable/types/ContactReference.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * reference to contact object - */ -export interface ContactReference { - /** always contact */ - type?: "contact"; - /** The unique identifier for the contact which is given by Intercom. */ - id?: string; - /** The unique identifier for the contact which is provided by the Client. */ - external_id?: string; -} diff --git a/src/api/resources/unstable/types/ContactReplyBaseRequest.ts b/src/api/resources/unstable/types/ContactReplyBaseRequest.ts deleted file mode 100644 index e6ebd102..00000000 --- a/src/api/resources/unstable/types/ContactReplyBaseRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface ContactReplyBaseRequest { - message_type: "comment"; - type: "user"; - /** The text body of the comment. */ - body: string; - /** The time the reply was created. If not provided, the current time will be used. */ - created_at?: number; - /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ - attachment_urls?: string[]; - /** The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. */ - reply_options?: ContactReplyBaseRequest.ReplyOptions.Item[]; -} - -export namespace ContactReplyBaseRequest { - export type ReplyOptions = ReplyOptions.Item[]; - - export namespace ReplyOptions { - export interface Item { - /** The text of the chosen reply option. */ - text: string; - /** The unique identifier for the quick reply option selected. */ - uuid: string; - } - } -} diff --git a/src/api/resources/unstable/types/ContactReplyConversationRequest.ts b/src/api/resources/unstable/types/ContactReplyConversationRequest.ts deleted file mode 100644 index eb27b919..00000000 --- a/src/api/resources/unstable/types/ContactReplyConversationRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type ContactReplyConversationRequest = - | Intercom.unstable.ContactReplyIntercomUserIdRequest - | Intercom.unstable.ContactReplyEmailRequest - | Intercom.unstable.ContactReplyUserIdRequest; diff --git a/src/api/resources/unstable/types/ContactReplyEmailRequest.ts b/src/api/resources/unstable/types/ContactReplyEmailRequest.ts deleted file mode 100644 index 31f73734..00000000 --- a/src/api/resources/unstable/types/ContactReplyEmailRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `email` - */ -export interface ContactReplyEmailRequest extends Intercom.unstable.ContactReplyBaseRequest { - /** The email you have defined for the user. */ - email: string; - /** A list of files that will be added as attachments. */ - attachment_files?: Intercom.unstable.ConversationAttachmentFiles[]; -} diff --git a/src/api/resources/unstable/types/ContactReplyIntercomUserIdRequest.ts b/src/api/resources/unstable/types/ContactReplyIntercomUserIdRequest.ts deleted file mode 100644 index edd5a8fd..00000000 --- a/src/api/resources/unstable/types/ContactReplyIntercomUserIdRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `intercom_user_id` - */ -export interface ContactReplyIntercomUserIdRequest extends Intercom.unstable.ContactReplyBaseRequest { - /** The identifier for the contact as given by Intercom. */ - intercom_user_id: string; - /** A list of files that will be added as attachments. */ - attachment_files?: Intercom.unstable.ConversationAttachmentFiles[]; -} diff --git a/src/api/resources/unstable/types/ContactReplyTicketEmailRequest.ts b/src/api/resources/unstable/types/ContactReplyTicketEmailRequest.ts deleted file mode 100644 index bad5a71c..00000000 --- a/src/api/resources/unstable/types/ContactReplyTicketEmailRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `email` - */ -export interface ContactReplyTicketEmailRequest extends Intercom.unstable.ContactReplyBaseRequest { - /** The email you have defined for the user. */ - email: string; -} diff --git a/src/api/resources/unstable/types/ContactReplyTicketIntercomUserIdRequest.ts b/src/api/resources/unstable/types/ContactReplyTicketIntercomUserIdRequest.ts deleted file mode 100644 index 70a2d6e2..00000000 --- a/src/api/resources/unstable/types/ContactReplyTicketIntercomUserIdRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `intercom_user_id` - */ -export interface ContactReplyTicketIntercomUserIdRequest extends Intercom.unstable.ContactReplyBaseRequest { - /** The identifier for the contact as given by Intercom. */ - intercom_user_id: string; -} diff --git a/src/api/resources/unstable/types/ContactReplyTicketRequest.ts b/src/api/resources/unstable/types/ContactReplyTicketRequest.ts deleted file mode 100644 index 523c59ef..00000000 --- a/src/api/resources/unstable/types/ContactReplyTicketRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type ContactReplyTicketRequest = - | Intercom.unstable.ContactReplyTicketIntercomUserIdRequest - | Intercom.unstable.ContactReplyTicketUserIdRequest - | Intercom.unstable.ContactReplyTicketEmailRequest; diff --git a/src/api/resources/unstable/types/ContactReplyTicketUserIdRequest.ts b/src/api/resources/unstable/types/ContactReplyTicketUserIdRequest.ts deleted file mode 100644 index 51ec38dc..00000000 --- a/src/api/resources/unstable/types/ContactReplyTicketUserIdRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `user_id` - */ -export interface ContactReplyTicketUserIdRequest extends Intercom.unstable.ContactReplyBaseRequest { - /** The external_id you have defined for the contact. */ - user_id: string; -} diff --git a/src/api/resources/unstable/types/ContactReplyUserIdRequest.ts b/src/api/resources/unstable/types/ContactReplyUserIdRequest.ts deleted file mode 100644 index 6870f212..00000000 --- a/src/api/resources/unstable/types/ContactReplyUserIdRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `user_id` - */ -export interface ContactReplyUserIdRequest extends Intercom.unstable.ContactReplyBaseRequest { - /** The external_id you have defined for the contact. */ - user_id: string; - /** A list of files that will be added as attachments. You can include up to 10 files. */ - attachment_files?: Intercom.unstable.ConversationAttachmentFiles[]; -} diff --git a/src/api/resources/unstable/types/ContactSegments.ts b/src/api/resources/unstable/types/ContactSegments.ts deleted file mode 100644 index 370cfde9..00000000 --- a/src/api/resources/unstable/types/ContactSegments.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of segments objects attached to a specific contact. - */ -export interface ContactSegments { - /** The type of the object */ - type?: "list"; - /** Segment objects associated with the contact. */ - data?: Intercom.unstable.Segment[]; -} diff --git a/src/api/resources/unstable/types/ContactSocialProfiles.ts b/src/api/resources/unstable/types/ContactSocialProfiles.ts deleted file mode 100644 index dd46662b..00000000 --- a/src/api/resources/unstable/types/ContactSocialProfiles.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * An object containing social profiles that a contact has. - */ -export interface ContactSocialProfiles { - /** A list of social profiles objects associated with the contact. */ - data?: Intercom.unstable.SocialProfile[]; -} diff --git a/src/api/resources/unstable/types/ContactSubscriptionTypes.ts b/src/api/resources/unstable/types/ContactSubscriptionTypes.ts deleted file mode 100644 index b478bc44..00000000 --- a/src/api/resources/unstable/types/ContactSubscriptionTypes.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * An object containing Subscription Types meta data about the SubscriptionTypes that a contact has. - */ -export interface ContactSubscriptionTypes { - /** This object represents the subscriptions attached to a contact. */ - data?: Intercom.unstable.AddressableList[]; - /** Url to get more subscription type resources for this contact */ - url?: string; - /** Int representing the total number of subscription types attached to this contact */ - total_count?: number; - /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ - has_more?: boolean; -} diff --git a/src/api/resources/unstable/types/ContactTags.ts b/src/api/resources/unstable/types/ContactTags.ts deleted file mode 100644 index 2ed6d4e7..00000000 --- a/src/api/resources/unstable/types/ContactTags.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * An object containing tags meta data about the tags that a contact has. Up to 10 will be displayed here. Use the url to get more. - */ -export interface ContactTags { - /** This object represents the tags attached to a contact. */ - data?: Intercom.unstable.AddressableList[]; - /** url to get more tag resources for this contact */ - url?: string; - /** Int representing the total number of tags attached to this contact */ - total_count?: number; - /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ - has_more?: boolean; -} diff --git a/src/api/resources/unstable/types/ContactUnarchived.ts b/src/api/resources/unstable/types/ContactUnarchived.ts deleted file mode 100644 index e5b151a1..00000000 --- a/src/api/resources/unstable/types/ContactUnarchived.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * unarchived contact object - */ -export interface ContactUnarchived extends Intercom.unstable.ContactReference { - /** Whether the contact is archived or not. */ - archived?: boolean; -} diff --git a/src/api/resources/unstable/types/ContentSourcesList.ts b/src/api/resources/unstable/types/ContentSourcesList.ts deleted file mode 100644 index aee5ab31..00000000 --- a/src/api/resources/unstable/types/ContentSourcesList.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContentSourcesList { - type?: "content_source.list"; - /** The total number of content sources used by AI Agent in the conversation. */ - total_count?: number; - /** The content sources used by AI Agent in the conversation. */ - content_sources?: Intercom.unstable.ContentSource[]; -} diff --git a/src/api/resources/unstable/types/ConversationAttachmentFiles.ts b/src/api/resources/unstable/types/ConversationAttachmentFiles.ts deleted file mode 100644 index f1a0b3e5..00000000 --- a/src/api/resources/unstable/types/ConversationAttachmentFiles.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Properties of the attachment files in a conversation part - */ -export interface ConversationAttachmentFiles { - /** The content type of the file */ - content_type?: string; - /** The base64 encoded file data. */ - data?: string; - /** The name of the file. */ - name?: string; -} diff --git a/src/api/resources/unstable/types/ConversationAttributeUpdatedByAdmin.ts b/src/api/resources/unstable/types/ConversationAttributeUpdatedByAdmin.ts deleted file mode 100644 index 997b2ea3..00000000 --- a/src/api/resources/unstable/types/ConversationAttributeUpdatedByAdmin.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about Custom Data Attributes (CDAs) that were modified by an admin (operator) for conversation part type conversation_attribute_updated_by_admin. - */ -export interface ConversationAttributeUpdatedByAdmin { - attribute?: ConversationAttributeUpdatedByAdmin.Attribute; - value?: ConversationAttributeUpdatedByAdmin.Value; -} - -export namespace ConversationAttributeUpdatedByAdmin { - export interface Attribute { - /** Name of the CDA updated */ - name?: string; - } - - export interface Value { - /** Current value of the CDA updated */ - name?: string; - /** Previous value of the CDA */ - previous?: string; - } -} diff --git a/src/api/resources/unstable/types/ConversationAttributeUpdatedByUser.ts b/src/api/resources/unstable/types/ConversationAttributeUpdatedByUser.ts deleted file mode 100644 index c0f19e67..00000000 --- a/src/api/resources/unstable/types/ConversationAttributeUpdatedByUser.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about Custom Data Attributes (CDAs) that were modified by a user for conversation part type conversation_attribute_updated_by_user. - */ -export interface ConversationAttributeUpdatedByUser { - attribute?: ConversationAttributeUpdatedByUser.Attribute; - value?: ConversationAttributeUpdatedByUser.Value; -} - -export namespace ConversationAttributeUpdatedByUser { - export interface Attribute { - /** Name of the CDA updated */ - name?: string; - } - - export interface Value { - /** Current value of the CDA updated */ - name?: string; - /** Previous value of the CDA (null for older events) */ - previous?: string; - } -} diff --git a/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts b/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts deleted file mode 100644 index e9e75f32..00000000 --- a/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about the workflow that was triggered and any Custom Data Attributes (CDAs) that were modified during the workflow execution for conversation part type conversation_attribute_updated_by_workflow. - */ -export interface ConversationAttributeUpdatedByWorkflow { - workflow?: ConversationAttributeUpdatedByWorkflow.Workflow; - attribute?: ConversationAttributeUpdatedByWorkflow.Attribute; - value?: ConversationAttributeUpdatedByWorkflow.Value; -} - -export namespace ConversationAttributeUpdatedByWorkflow { - export interface Workflow { - /** Name of the workflow */ - name?: string; - } - - export interface Attribute { - /** Name of the CDA updated */ - name?: string; - } - - export interface Value { - /** Value of the CDA updated */ - name?: string; - } -} diff --git a/src/api/resources/unstable/types/ConversationContacts.ts b/src/api/resources/unstable/types/ConversationContacts.ts deleted file mode 100644 index eb49d28f..00000000 --- a/src/api/resources/unstable/types/ConversationContacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. - */ -export interface ConversationContacts { - /** */ - type?: "contact.list"; - /** The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. */ - contacts?: Intercom.unstable.ContactReference[]; -} diff --git a/src/api/resources/unstable/types/ConversationDeleted.ts b/src/api/resources/unstable/types/ConversationDeleted.ts deleted file mode 100644 index e61823b9..00000000 --- a/src/api/resources/unstable/types/ConversationDeleted.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * deleted conversation object - */ -export interface ConversationDeleted { - /** The unique identifier for the conversation. */ - id?: string; - /** always conversation */ - object?: "conversation"; - /** Whether the conversation is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/types/ConversationFirstContactReply.ts b/src/api/resources/unstable/types/ConversationFirstContactReply.ts deleted file mode 100644 index 2085bd1e..00000000 --- a/src/api/resources/unstable/types/ConversationFirstContactReply.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An object containing information on the first users message. For a contact initiated message this will represent the users original message. - */ -export interface ConversationFirstContactReply { - /** */ - created_at?: number; - /** */ - type?: string; - /** */ - url?: string; -} diff --git a/src/api/resources/unstable/types/ConversationList.ts b/src/api/resources/unstable/types/ConversationList.ts deleted file mode 100644 index 9a0a768e..00000000 --- a/src/api/resources/unstable/types/ConversationList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. - */ -export interface ConversationList { - /** Always conversation.list */ - type?: "conversation.list"; - /** The list of conversation objects */ - conversations?: Intercom.unstable.Conversation[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.unstable.CursorPages; -} diff --git a/src/api/resources/unstable/types/ConversationPart.ts b/src/api/resources/unstable/types/ConversationPart.ts deleted file mode 100644 index 0d55a965..00000000 --- a/src/api/resources/unstable/types/ConversationPart.ts +++ /dev/null @@ -1,51 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A Conversation Part represents a message in the conversation. - */ -export interface ConversationPart { - /** Always conversation_part */ - type?: string; - /** The id representing the conversation part. */ - id?: string; - /** The type of conversation part. */ - part_type?: string; - /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ - body?: string; - /** The time the conversation part was created. */ - created_at?: number; - /** The last time the conversation part was updated. */ - updated_at?: number; - /** The time the user was notified with the conversation part. */ - notified_at?: number; - /** The id of the admin that was assigned the conversation by this conversation_part (null if there has been no change in assignment.) */ - assigned_to?: Intercom.unstable.Reference; - author?: Intercom.unstable.ConversationPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.unstable.PartAttachment[]; - /** The external id of the conversation part */ - external_id?: string; - /** Whether or not the conversation part has been redacted. */ - redacted?: boolean; - email_message_metadata?: Intercom.unstable.EmailMessageMetadata; - metadata?: Intercom.unstable.ConversationPartMetadata; - /** Indicates the current state of conversation when the conversation part was created. */ - state?: ConversationPart.State; - /** A list of tags objects associated with the conversation part. */ - tags?: Intercom.unstable.TagBasic[]; - event_details?: Intercom.unstable.EventDetails; - /** The app package code if this part was created via API. null if the part was not created via API. */ - app_package_code?: string; -} - -export namespace ConversationPart { - /** Indicates the current state of conversation when the conversation part was created. */ - export const State = { - Open: "open", - Closed: "closed", - Snoozed: "snoozed", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/types/ConversationPartAuthor.ts b/src/api/resources/unstable/types/ConversationPartAuthor.ts deleted file mode 100644 index 3a17d751..00000000 --- a/src/api/resources/unstable/types/ConversationPartAuthor.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The object who initiated the conversation, which can be a Contact, Admin or Team. Bots and campaigns send messages on behalf of Admins or Teams. For Twitter, this will be blank. - */ -export interface ConversationPartAuthor { - /** The type of the author */ - type?: string; - /** The id of the author */ - id?: string; - /** The name of the author */ - name?: string; - /** The email of the author */ - email?: string; - /** If this conversation part was sent by the AI Agent */ - from_ai_agent?: boolean; - /** If this conversation part body was generated by the AI Agent */ - is_ai_answer?: boolean; -} diff --git a/src/api/resources/unstable/types/ConversationPartMetadata.ts b/src/api/resources/unstable/types/ConversationPartMetadata.ts deleted file mode 100644 index 73de6365..00000000 --- a/src/api/resources/unstable/types/ConversationPartMetadata.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Metadata for a conversation part - */ -export interface ConversationPartMetadata { - /** The quick reply options sent by the Admin or bot, presented in this conversation part. */ - quick_reply_options?: ConversationPartMetadata.QuickReplyOptions.Item[]; - /** The unique identifier for the quick reply option that was clicked by the end user. */ - quick_reply_uuid?: string; -} - -export namespace ConversationPartMetadata { - export type QuickReplyOptions = QuickReplyOptions.Item[]; - - export namespace QuickReplyOptions { - export interface Item extends Intercom.unstable.QuickReplyOption { - /** The translations for the quick reply option. */ - translations?: Record; - } - } -} diff --git a/src/api/resources/unstable/types/ConversationParts.ts b/src/api/resources/unstable/types/ConversationParts.ts deleted file mode 100644 index a1e3f943..00000000 --- a/src/api/resources/unstable/types/ConversationParts.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. - */ -export interface ConversationParts { - /** */ - type?: "conversation_part.list"; - /** A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. */ - conversation_parts?: Intercom.unstable.ConversationPart[]; - /** */ - total_count?: number; -} diff --git a/src/api/resources/unstable/types/ConversationRating.ts b/src/api/resources/unstable/types/ConversationRating.ts deleted file mode 100644 index 1edf63c5..00000000 --- a/src/api/resources/unstable/types/ConversationRating.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The Conversation Rating object which contains information on the rating and/or remark added by a Contact and the Admin assigned to the conversation. - */ -export interface ConversationRating { - /** The rating, between 1 and 5, for the conversation. */ - rating?: number; - /** An optional field to add a remark to correspond to the number rating */ - remark?: string; - /** The time the rating was requested in the conversation being rated. */ - created_at?: number; - /** The time the rating was last updated. */ - updated_at?: number; - contact?: Intercom.unstable.ContactReference; - teammate?: Intercom.unstable.Reference; -} diff --git a/src/api/resources/unstable/types/ConversationResponseTime.ts b/src/api/resources/unstable/types/ConversationResponseTime.ts deleted file mode 100644 index 8c503679..00000000 --- a/src/api/resources/unstable/types/ConversationResponseTime.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Details of first response time of assigned team in seconds. - */ -export interface ConversationResponseTime { - /** Id of the assigned team. */ - team_id?: number; - /** Name of the assigned Team, null if team does not exist, Unassigned if no team is assigned. */ - team_name?: string; - /** First response time of assigned team in seconds. */ - response_time?: number; -} diff --git a/src/api/resources/unstable/types/ConversationSlaAppliedByRule.ts b/src/api/resources/unstable/types/ConversationSlaAppliedByRule.ts deleted file mode 100644 index 8340e44f..00000000 --- a/src/api/resources/unstable/types/ConversationSlaAppliedByRule.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about SLA applied by modern Operator workflows for conversation part type conversation_sla_applied_by_rule. - */ -export interface ConversationSlaAppliedByRule { - /** Name of the SLA that was applied */ - sla_name?: string; - /** Target times configured for the SLA (in seconds) */ - sla_definition?: ConversationSlaAppliedByRule.SlaDefinition; -} - -export namespace ConversationSlaAppliedByRule { - /** - * Target times configured for the SLA (in seconds) - */ - export interface SlaDefinition { - /** First response time target in seconds */ - first_reply_time?: number; - /** Next reply time target in seconds */ - next_reply_time?: number; - /** Resolution time target in seconds */ - resolution_time?: number; - /** Time to close target in seconds */ - time_to_close?: number; - } -} diff --git a/src/api/resources/unstable/types/ConversationSlaAppliedByWorkflow.ts b/src/api/resources/unstable/types/ConversationSlaAppliedByWorkflow.ts deleted file mode 100644 index 29b5464d..00000000 --- a/src/api/resources/unstable/types/ConversationSlaAppliedByWorkflow.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about SLA applied by legacy Inbox Rules for conversation part type conversation_sla_applied_by_workflow. - */ -export interface ConversationSlaAppliedByWorkflow { - /** Name of the SLA that was applied */ - sla_name?: string; - /** Target times configured for the SLA (in seconds) */ - sla_definition?: ConversationSlaAppliedByWorkflow.SlaDefinition; -} - -export namespace ConversationSlaAppliedByWorkflow { - /** - * Target times configured for the SLA (in seconds) - */ - export interface SlaDefinition { - /** First response time target in seconds */ - first_reply_time?: number; - /** Next reply time target in seconds */ - next_reply_time?: number; - /** Resolution time target in seconds */ - resolution_time?: number; - /** Time to close target in seconds */ - time_to_close?: number; - } -} diff --git a/src/api/resources/unstable/types/ConversationSlaPaused.ts b/src/api/resources/unstable/types/ConversationSlaPaused.ts deleted file mode 100644 index eb842828..00000000 --- a/src/api/resources/unstable/types/ConversationSlaPaused.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains SLA status at the moment of pausing for conversation part type conversation_sla_paused. - */ -export interface ConversationSlaPaused { - /** Name of the SLA being paused */ - sla_name?: string; - /** Overall SLA status at pause time */ - current_sla_status?: ConversationSlaPaused.CurrentSlaStatus; - /** Status of all SLA targets at pause time */ - sla_states?: Record; -} - -export namespace ConversationSlaPaused { - /** Overall SLA status at pause time */ - export const CurrentSlaStatus = { - Active: "active", - Hit: "hit", - Missed: "missed", - Canceled: "canceled", - } as const; - export type CurrentSlaStatus = (typeof CurrentSlaStatus)[keyof typeof CurrentSlaStatus]; - - export namespace SlaStates { - export interface Value { - /** Status of this specific target (always paused) */ - status?: "paused"; - /** Time remaining when paused */ - seconds_remaining?: number; - } - } -} diff --git a/src/api/resources/unstable/types/ConversationSlaRemoved.ts b/src/api/resources/unstable/types/ConversationSlaRemoved.ts deleted file mode 100644 index c0007356..00000000 --- a/src/api/resources/unstable/types/ConversationSlaRemoved.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains basic SLA information when removed for conversation part type conversation_sla_removed. - */ -export interface ConversationSlaRemoved { - /** Name of the SLA that was removed */ - sla_name?: string; -} diff --git a/src/api/resources/unstable/types/ConversationSlaTargetMissed.ts b/src/api/resources/unstable/types/ConversationSlaTargetMissed.ts deleted file mode 100644 index bec5f996..00000000 --- a/src/api/resources/unstable/types/ConversationSlaTargetMissed.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains complete status of all SLA targets when a breach occurs for conversation part type conversation_sla_target_missed. - */ -export interface ConversationSlaTargetMissed { - /** Name of the SLA */ - sla_name?: string; - /** Which specific target was missed */ - sla_target_type?: ConversationSlaTargetMissed.SlaTargetType; - /** Overall SLA status */ - current_sla_status?: ConversationSlaTargetMissed.CurrentSlaStatus; - /** Status of all SLA targets at the time of breach */ - sla_states?: Record; -} - -export namespace ConversationSlaTargetMissed { - /** Which specific target was missed */ - export const SlaTargetType = { - FirstReplyTime: "first_reply_time", - NextReplyTime: "next_reply_time", - ResolutionTime: "resolution_time", - TimeToClose: "time_to_close", - } as const; - export type SlaTargetType = (typeof SlaTargetType)[keyof typeof SlaTargetType]; - /** Overall SLA status */ - export const CurrentSlaStatus = { - Hit: "hit", - Missed: "missed", - Active: "active", - Paused: "paused", - Canceled: "canceled", - } as const; - export type CurrentSlaStatus = (typeof CurrentSlaStatus)[keyof typeof CurrentSlaStatus]; - - export namespace SlaStates { - export interface Value { - /** Status of this specific target */ - status?: Value.Status; - /** Time remaining for active/paused targets (null for hit/missed) */ - seconds_remaining?: number; - } - - export namespace Value { - /** Status of this specific target */ - export const Status = { - Hit: "hit", - Missed: "missed", - Active: "active", - Paused: "paused", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; - } - } -} diff --git a/src/api/resources/unstable/types/ConversationSlaUnpaused.ts b/src/api/resources/unstable/types/ConversationSlaUnpaused.ts deleted file mode 100644 index e7045d0f..00000000 --- a/src/api/resources/unstable/types/ConversationSlaUnpaused.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains basic SLA information when unpaused for conversation part type conversation_sla_unpaused. - */ -export interface ConversationSlaUnpaused { - /** Name of the SLA being unpaused */ - sla_name?: string; -} diff --git a/src/api/resources/unstable/types/ConversationSource.ts b/src/api/resources/unstable/types/ConversationSource.ts deleted file mode 100644 index 3987bf3f..00000000 --- a/src/api/resources/unstable/types/ConversationSource.ts +++ /dev/null @@ -1,43 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The type of the conversation part that started this conversation. Can be Contact, Admin, Campaign, Automated or Operator initiated. - */ -export interface ConversationSource { - /** This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ - type?: ConversationSource.Type; - /** The id representing the message. */ - id?: string; - /** The conversation's initiation type. Possible values are customer_initiated, campaigns_initiated (legacy campaigns), operator_initiated (Custom bot), automated (Series and other outbounds with dynamic audience message) and admin_initiated (fixed audience message, ticket initiated by an admin, group email). */ - delivered_as?: string; - /** Optional. The message subject. For Twitter, this will show a generic message regarding why the subject is obscured. */ - subject?: string; - /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ - body?: string; - author?: Intercom.unstable.ConversationPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.unstable.PartAttachment[]; - /** The URL where the conversation was started. For Twitter, Email, and Bots, this will be blank. */ - url?: string; - /** Whether or not the source message has been redacted. Only applicable for contact initiated messages. */ - redacted?: boolean; -} - -export namespace ConversationSource { - /** This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ - export const Type = { - Conversation: "conversation", - Email: "email", - Facebook: "facebook", - Instagram: "instagram", - PhoneCall: "phone_call", - PhoneSwitch: "phone_switch", - Push: "push", - Sms: "sms", - Twitter: "twitter", - Whatsapp: "whatsapp", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/ConversationStatistics.ts b/src/api/resources/unstable/types/ConversationStatistics.ts deleted file mode 100644 index 8491c58f..00000000 --- a/src/api/resources/unstable/types/ConversationStatistics.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A Statistics object containing all information required for reporting, with timestamps and calculated metrics. - */ -export interface ConversationStatistics { - /** */ - type?: string; - /** Duration until last assignment before first admin reply. In seconds. */ - time_to_assignment?: number; - /** Duration until first admin reply. Subtracts out of business hours. In seconds. */ - time_to_admin_reply?: number; - /** Duration until conversation was closed first time. Subtracts out of business hours. In seconds. */ - time_to_first_close?: number; - /** Duration until conversation was closed last time. Subtracts out of business hours. In seconds. */ - time_to_last_close?: number; - /** Median based on all admin replies after a contact reply. Subtracts out of business hours. In seconds. */ - median_time_to_reply?: number; - /** Time of first text conversation part from a contact. */ - first_contact_reply_at?: number; - /** Time of first assignment after first_contact_reply_at. */ - first_assignment_at?: number; - /** Time of first admin reply after first_contact_reply_at. */ - first_admin_reply_at?: number; - /** Time of first close after first_contact_reply_at. */ - first_close_at?: number; - /** Time of last assignment after first_contact_reply_at. */ - last_assignment_at?: number; - /** Time of first admin reply since most recent assignment. */ - last_assignment_admin_reply_at?: number; - /** Time of the last conversation part from a contact. */ - last_contact_reply_at?: number; - /** Time of the last conversation part from an admin. */ - last_admin_reply_at?: number; - /** Time of the last conversation close. */ - last_close_at?: number; - /** The last admin who closed the conversation. Returns a reference to an Admin object. */ - last_closed_by_id?: string; - /** Number of reopens after first_contact_reply_at. */ - count_reopens?: number; - /** Number of assignments after first_contact_reply_at. */ - count_assignments?: number; - /** Total number of conversation parts. */ - count_conversation_parts?: number; - /** An array of conversation response time objects */ - assigned_team_first_response_time_by_team?: Intercom.unstable.ConversationResponseTime[]; - /** An array of conversation response time objects within office hours */ - assigned_team_first_response_time_in_office_hours?: Intercom.unstable.ConversationResponseTime[]; - /** Time from conversation assignment to conversation close in seconds. */ - handling_time?: number; - /** Adjusted handling time for conversation in seconds. This is the active handling time excluding idle periods when teammates are not actively working on the conversation. */ - adjusted_handling_time?: number; -} diff --git a/src/api/resources/unstable/types/ConversationTagsUpdated.ts b/src/api/resources/unstable/types/ConversationTagsUpdated.ts deleted file mode 100644 index 556dd3e0..00000000 --- a/src/api/resources/unstable/types/ConversationTagsUpdated.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about tags that were added or removed from a conversation for conversation part type conversation_tags_updated. - */ -export interface ConversationTagsUpdated { - /** Array of tag names that were added */ - tags_added?: string[]; - /** Array of tag names that were removed */ - tags_removed?: string[]; -} diff --git a/src/api/resources/unstable/types/ConversationTeammates.ts b/src/api/resources/unstable/types/ConversationTeammates.ts deleted file mode 100644 index 3932494d..00000000 --- a/src/api/resources/unstable/types/ConversationTeammates.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The list of teammates who participated in the conversation (wrote at least one conversation part). - */ -export interface ConversationTeammates { - /** The type of the object - `admin.list`. */ - type?: string; - /** The list of teammates who participated in the conversation (wrote at least one conversation part). */ - teammates?: Intercom.unstable.Reference[]; -} diff --git a/src/api/resources/unstable/types/CreateArticleRequest.ts b/src/api/resources/unstable/types/CreateArticleRequest.ts deleted file mode 100644 index fae9a9e6..00000000 --- a/src/api/resources/unstable/types/CreateArticleRequest.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * You can create an Article - */ -export interface CreateArticleRequest { - /** The title of the article.For multilingual articles, this will be the title of the default language's content. */ - title: string; - /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ - description?: string; - /** The content of the article. For multilingual articles, this will be the body of the default language's content. */ - body?: string; - /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ - author_id: number; - /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ - state?: CreateArticleRequest.State; - /** The id of the article's parent collection or section. An article without this field stands alone. */ - parent_id?: number; - /** The type of parent, which can either be a `collection` or `section`. */ - parent_type?: string; - translated_content?: Intercom.unstable.ArticleTranslatedContent; -} - -export namespace CreateArticleRequest { - /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ - export const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/types/CreateDataAttributeRequest.ts b/src/api/resources/unstable/types/CreateDataAttributeRequest.ts deleted file mode 100644 index e2abd5d2..00000000 --- a/src/api/resources/unstable/types/CreateDataAttributeRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type CreateDataAttributeRequest = - | { - data_type?: "options" | undefined; - options: { - value?: string | undefined; - }[]; - } - | { - data_type?: ("string" | "integer" | "float" | "boolean" | "datetime" | "date") | undefined; - }; diff --git a/src/api/resources/unstable/types/CreateInternalArticleRequest.ts b/src/api/resources/unstable/types/CreateInternalArticleRequest.ts deleted file mode 100644 index f971e918..00000000 --- a/src/api/resources/unstable/types/CreateInternalArticleRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create an Internal Article - */ -export interface CreateInternalArticleRequest { - /** The title of the article. */ - title: string; - /** The content of the article. */ - body?: string; - /** The id of the author of the article. */ - author_id: number; - /** The id of the owner of the article. */ - owner_id: number; -} diff --git a/src/api/resources/unstable/types/CreateMessageRequest.ts b/src/api/resources/unstable/types/CreateMessageRequest.ts deleted file mode 100644 index b9bc1f58..00000000 --- a/src/api/resources/unstable/types/CreateMessageRequest.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create a message - */ -export type CreateMessageRequest = unknown | undefined; diff --git a/src/api/resources/unstable/types/CreateOrUpdateCompanyRequest.ts b/src/api/resources/unstable/types/CreateOrUpdateCompanyRequest.ts deleted file mode 100644 index 9a465e5c..00000000 --- a/src/api/resources/unstable/types/CreateOrUpdateCompanyRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create or update a Company - */ -export interface CreateOrUpdateCompanyRequest { - /** The name of the Company */ - name?: string; - /** The company id you have defined for the company. Can't be updated */ - company_id?: string; - /** The name of the plan you have associated with the company. */ - plan?: string; - /** The number of employees in this company. */ - size?: number; - /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ - website?: string; - /** The industry that this company operates in. */ - industry?: string; - /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ - custom_attributes?: Record; - /** The time the company was created by you. */ - remote_created_at?: number; - /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ - monthly_spend?: number; -} diff --git a/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts b/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts deleted file mode 100644 index 7dfd1b3f..00000000 --- a/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create or update an existing tag. - */ -export interface CreateOrUpdateTagRequest { - /** The name of the tag, which will be created if not found, or the new name for the tag if this is an update request. Names are case insensitive. */ - name: string; - /** The id of tag to updates. */ - id?: string; -} diff --git a/src/api/resources/unstable/types/CreatePhoneSwitchRequest.ts b/src/api/resources/unstable/types/CreatePhoneSwitchRequest.ts deleted file mode 100644 index 825757f8..00000000 --- a/src/api/resources/unstable/types/CreatePhoneSwitchRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * You can create an phone switch - */ -export interface CreatePhoneSwitchRequest { - /** Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. */ - phone: string; - custom_attributes?: Intercom.unstable.CustomAttributes; -} diff --git a/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts b/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts deleted file mode 100644 index 31c13aad..00000000 --- a/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type CreateTicketReplyWithCommentRequest = - | Intercom.unstable.ContactReplyTicketRequest - | Intercom.unstable.AdminReplyTicketRequest; diff --git a/src/api/resources/unstable/types/CreateTicketRequestBody.ts b/src/api/resources/unstable/types/CreateTicketRequestBody.ts deleted file mode 100644 index 9ec9fb5c..00000000 --- a/src/api/resources/unstable/types/CreateTicketRequestBody.ts +++ /dev/null @@ -1,48 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create a Ticket - */ -export interface CreateTicketRequestBody { - /** The ID of the type of ticket you want to create */ - ticket_type_id: string; - /** The list of contacts (users or leads) affected by this ticket. Currently only one is allowed */ - contacts: CreateTicketRequestBody.Contacts.Item[]; - /** - * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: - * - conversation | back-office ticket - * - customer tickets | non-shared back-office ticket - * - conversation | tracker ticket - * - customer ticket | tracker ticket - */ - conversation_to_link_id?: string; - /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom */ - company_id?: string; - /** The time the ticket was created. If not provided, the current time will be used. */ - created_at?: number; - assignment?: CreateTicketRequestBody.Assignment; -} - -export namespace CreateTicketRequestBody { - export type Contacts = Contacts.Item[]; - - export namespace Contacts { - export type Item = - | { - id: string; - } - | { - external_id: string; - } - | { - email: string; - }; - } - - export interface Assignment { - /** The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. */ - admin_assignee_id?: string; - /** The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned. */ - team_assignee_id?: string; - } -} diff --git a/src/api/resources/unstable/types/CreateTicketTypeRequest.ts b/src/api/resources/unstable/types/CreateTicketTypeRequest.ts deleted file mode 100644 index eebc72da..00000000 --- a/src/api/resources/unstable/types/CreateTicketTypeRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The request payload for creating a ticket type. - * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) - */ -export interface CreateTicketTypeRequest { - /** The name of the ticket type. */ - name: string; - /** The description of the ticket type. */ - description?: string; - /** Category of the Ticket Type. */ - category?: CreateTicketTypeRequest.Category; - /** The icon of the ticket type. */ - icon?: string; - /** Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute. */ - is_internal?: boolean; -} - -export namespace CreateTicketTypeRequest { - /** Category of the Ticket Type. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/unstable/types/CursorPages.ts b/src/api/resources/unstable/types/CursorPages.ts deleted file mode 100644 index 28a01ed3..00000000 --- a/src/api/resources/unstable/types/CursorPages.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Cursor-based pagination is a technique used in the Intercom API to navigate through large amounts of data. - * A "cursor" or pointer is used to keep track of the current position in the result set, allowing the API to return the data in small chunks or "pages" as needed. - */ -export interface CursorPages { - /** the type of object `pages`. */ - type?: "pages"; - /** The current page */ - page?: number; - next?: Intercom.unstable.StartingAfterPaging; - /** Number of results per page */ - per_page?: number; - /** Total number of pages */ - total_pages?: number; -} diff --git a/src/api/resources/unstable/types/CustomActionFinished.ts b/src/api/resources/unstable/types/CustomActionFinished.ts deleted file mode 100644 index 54471392..00000000 --- a/src/api/resources/unstable/types/CustomActionFinished.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about final status of the completed action for conversation part type custom_action_finished. - */ -export interface CustomActionFinished { - action?: CustomActionFinished.Action; -} - -export namespace CustomActionFinished { - export interface Action { - /** Name of the action */ - name?: string; - /** Status of the action */ - result?: Action.Result; - } - - export namespace Action { - /** Status of the action */ - export const Result = { - Success: "success", - Failed: "failed", - } as const; - export type Result = (typeof Result)[keyof typeof Result]; - } -} diff --git a/src/api/resources/unstable/types/CustomActionStarted.ts b/src/api/resources/unstable/types/CustomActionStarted.ts deleted file mode 100644 index 18114f6c..00000000 --- a/src/api/resources/unstable/types/CustomActionStarted.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about name of the action that was initiated for conversation part type custom_action_started. - */ -export interface CustomActionStarted { - action?: CustomActionStarted.Action; -} - -export namespace CustomActionStarted { - export interface Action { - /** Name of the action */ - name?: string; - } -} diff --git a/src/api/resources/unstable/types/CustomAttributes.ts b/src/api/resources/unstable/types/CustomAttributes.ts deleted file mode 100644 index c2086e14..00000000 --- a/src/api/resources/unstable/types/CustomAttributes.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * An object containing the different custom attributes associated to the conversation as key-value pairs. For relationship attributes the value will be a list of custom object instance models. - */ -export type CustomAttributes = Record; - -export namespace CustomAttributes { - export type Value = string | number | Intercom.unstable.Datetime | Intercom.unstable.CustomObjectInstanceList; -} diff --git a/src/api/resources/unstable/types/CustomChannelAttribute.ts b/src/api/resources/unstable/types/CustomChannelAttribute.ts deleted file mode 100644 index 9afa1dd6..00000000 --- a/src/api/resources/unstable/types/CustomChannelAttribute.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface CustomChannelAttribute { - /** Identifier for the attribute being collected. */ - id: string; - /** Value provided by the user for the attribute. */ - value: string; -} diff --git a/src/api/resources/unstable/types/CustomChannelBaseEvent.ts b/src/api/resources/unstable/types/CustomChannelBaseEvent.ts deleted file mode 100644 index 6a638105..00000000 --- a/src/api/resources/unstable/types/CustomChannelBaseEvent.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface CustomChannelBaseEvent { - /** Unique identifier for the event. */ - event_id: string; - /** Identifier for the conversation in your application. */ - external_conversation_id: string; - contact: Intercom.unstable.CustomChannelContact; -} diff --git a/src/api/resources/unstable/types/CustomChannelContact.ts b/src/api/resources/unstable/types/CustomChannelContact.ts deleted file mode 100644 index 7d11a83c..00000000 --- a/src/api/resources/unstable/types/CustomChannelContact.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface CustomChannelContact { - /** Type of contact, must be "user" or "lead". */ - type: CustomChannelContact.Type; - /** External identifier for the contact. Intercom will take care of the mapping of your external_id with our internal ones so you don't have to worry about it. */ - external_id: string; - /** Name of the contact. Required for user type. */ - name?: string; - /** Email address of the contact. Required for user type. */ - email?: string; -} - -export namespace CustomChannelContact { - /** Type of contact, must be "user" or "lead". */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts b/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts deleted file mode 100644 index 238b883d..00000000 --- a/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface CustomChannelNotificationResponse { - /** The external conversation ID provided in the notification request */ - external_conversation_id: string; - /** The Intercom conversation ID mapped to the external conversation ID */ - conversation_id: string; - /** The external contact ID provided in the notification request */ - external_contact_id: string; - /** The Intercom contact ID mapped to the external contact ID */ - contact_id: string; -} diff --git a/src/api/resources/unstable/types/CustomObjectInstanceDeleted.ts b/src/api/resources/unstable/types/CustomObjectInstanceDeleted.ts deleted file mode 100644 index 4c14eba9..00000000 --- a/src/api/resources/unstable/types/CustomObjectInstanceDeleted.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * deleted custom object instance object - */ -export interface CustomObjectInstanceDeleted { - /** The unique identifier of the Custom Object type that defines the structure of the Custom Object instance. */ - object?: string; - /** The Intercom defined id representing the Custom Object instance. */ - id?: string; - /** Whether the Custom Object instance is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/types/CustomObjectInstanceList.ts b/src/api/resources/unstable/types/CustomObjectInstanceList.ts deleted file mode 100644 index 98e68588..00000000 --- a/src/api/resources/unstable/types/CustomObjectInstanceList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The list of associated custom object instances for a given reference attribute on the parent object. - */ -export interface CustomObjectInstanceList { - type?: string; - /** The list of associated custom object instances for a given reference attribute on the parent object. */ - instances?: (Intercom.unstable.CustomObjectInstance | undefined)[]; -} diff --git a/src/api/resources/unstable/types/CustomerRequest.ts b/src/api/resources/unstable/types/CustomerRequest.ts deleted file mode 100644 index d86d11c7..00000000 --- a/src/api/resources/unstable/types/CustomerRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type CustomerRequest = - | { - intercom_user_id: string; - } - | { - user_id: string; - } - | { - email: string; - }; diff --git a/src/api/resources/unstable/types/DataAttributeList.ts b/src/api/resources/unstable/types/DataAttributeList.ts deleted file mode 100644 index f8b6055b..00000000 --- a/src/api/resources/unstable/types/DataAttributeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of all data attributes belonging to a workspace for contacts, companies or conversations. - */ -export interface DataAttributeList { - /** The type of the object */ - type?: "list"; - /** A list of data attributes */ - data?: Intercom.unstable.DataAttribute[]; -} diff --git a/src/api/resources/unstable/types/DataEventList.ts b/src/api/resources/unstable/types/DataEventList.ts deleted file mode 100644 index 1fa73fc8..00000000 --- a/src/api/resources/unstable/types/DataEventList.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of data events for the App. - */ -export interface DataEventList { - /** The type of the object */ - type?: "event.list"; - /** A list of data events */ - events?: Intercom.unstable.DataEvent[]; - /** Pagination */ - pages?: DataEventList.Pages; -} - -export namespace DataEventList { - /** - * Pagination - */ - export interface Pages { - next?: string; - since?: string; - } -} diff --git a/src/api/resources/unstable/types/DataEventSummary.ts b/src/api/resources/unstable/types/DataEventSummary.ts deleted file mode 100644 index 0badccff..00000000 --- a/src/api/resources/unstable/types/DataEventSummary.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a summary of data events for the App. - */ -export interface DataEventSummary { - /** The type of the object */ - type?: "event.summary"; - /** The email address of the user */ - email?: string; - /** The Intercom user ID of the user */ - intercom_user_id?: string; - /** The user ID of the user */ - user_id?: string; - /** A summary of data events */ - events?: (Intercom.unstable.DataEventSummaryItem | undefined)[]; -} diff --git a/src/api/resources/unstable/types/DataEventSummaryItem.ts b/src/api/resources/unstable/types/DataEventSummaryItem.ts deleted file mode 100644 index 9f0d9192..00000000 --- a/src/api/resources/unstable/types/DataEventSummaryItem.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * This will return a summary of a data event for the App. - */ -export interface DataEventSummaryItem { - /** The name of the event */ - name?: string; - /** The first time the event was sent */ - first?: string; - /** The last time the event was sent */ - last?: string; - /** The number of times the event was sent */ - count?: number; - /** The description of the event */ - description?: string; -} diff --git a/src/api/resources/unstable/types/DataExportCsv.ts b/src/api/resources/unstable/types/DataExportCsv.ts deleted file mode 100644 index 8c268f7e..00000000 --- a/src/api/resources/unstable/types/DataExportCsv.ts +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A CSV output file - */ -export interface DataExportCsv { - /** The user_id of the user who was sent the message. */ - user_id?: string; - /** The external_user_id of the user who was sent the message */ - user_external_id?: string; - /** The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. */ - company_id?: string; - /** The users email who was sent the message. */ - email?: string; - /** The full name of the user receiving the message */ - name?: string; - /** The id of the message. */ - ruleset_id?: string; - /** The specific content that was received. In an A/B test each version has its own Content ID. */ - content_id?: string; - /** Email, Chat, Post etc. */ - content_type?: string; - /** The title of the content you see in your Intercom workspace. */ - content_title?: string; - /** As you edit content we record new versions. This ID can help you determine which version of a piece of content that was received. */ - ruleset_version_id?: string; - /** ID for this receipt. Will be included with any related stats in other files to identify this specific delivery of a message. */ - receipt_id?: string; - /** Timestamp for when the receipt was recorded. */ - received_at?: number; - /** The id of the series that this content is part of. Will return -1 if not part of a series. */ - series_id?: string; - /** The title of the series that this content is part of. */ - series_title?: string; - /** The id of the series node that this ruleset is associated with. Each block in a series has a corresponding node_id. */ - node_id?: string; - /** The first time a user replied to this message if the content was able to receive replies. */ - first_reply?: number; - /** The first time a user completed this message if the content was able to be completed e.g. Tours, Surveys. */ - first_completion?: number; - /** The first time the series this message was a part of was completed by the user. */ - first_series_completion?: number; - /** The first time the series this message was a part of was disengaged by the user. */ - first_series_disengagement?: number; - /** The first time the series this message was a part of was exited by the user. */ - first_series_exit?: number; - /** The first time the user met this messages associated goal if one exists. */ - first_goal_success?: number; - /** The first time the user opened this message. */ - first_open?: number; - /** The first time the series the user clicked on a link within this message. */ - first_click?: number; - /** The first time the series the user dismissed this message. */ - first_dismisall?: number; - /** The first time the user unsubscribed from this message. */ - first_unsubscribe?: number; - /** The first time this message hard bounced for this user */ - first_hard_bounce?: number; -} diff --git a/src/api/resources/unstable/types/Datetime.ts b/src/api/resources/unstable/types/Datetime.ts deleted file mode 100644 index 63964732..00000000 --- a/src/api/resources/unstable/types/Datetime.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type Datetime = - /** - * A date and time following the ISO8601 notation. */ - | string - /** - * A date and time as UNIX timestamp notation. */ - | number; diff --git a/src/api/resources/unstable/types/DeletedArticleObject.ts b/src/api/resources/unstable/types/DeletedArticleObject.ts deleted file mode 100644 index 5667114c..00000000 --- a/src/api/resources/unstable/types/DeletedArticleObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedArticleObject { - /** The unique identifier for the article which you provided in the URL. */ - id?: string; - /** The type of object which was deleted. - article */ - object?: "article"; - /** Whether the article was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/types/DeletedCollectionObject.ts b/src/api/resources/unstable/types/DeletedCollectionObject.ts deleted file mode 100644 index 4d03d936..00000000 --- a/src/api/resources/unstable/types/DeletedCollectionObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedCollectionObject { - /** The unique identifier for the collection which you provided in the URL. */ - id?: string; - /** The type of object which was deleted. - `collection` */ - object?: "collection"; - /** Whether the collection was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/types/DeletedCompanyObject.ts b/src/api/resources/unstable/types/DeletedCompanyObject.ts deleted file mode 100644 index b5ee6cf6..00000000 --- a/src/api/resources/unstable/types/DeletedCompanyObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedCompanyObject { - /** The unique identifier for the company which is given by Intercom. */ - id?: string; - /** The type of object which was deleted. - `company` */ - object?: "company"; - /** Whether the company was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/types/DeletedInternalArticleObject.ts b/src/api/resources/unstable/types/DeletedInternalArticleObject.ts deleted file mode 100644 index 47d5060b..00000000 --- a/src/api/resources/unstable/types/DeletedInternalArticleObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedInternalArticleObject { - /** The unique identifier for the internal article which you provided in the URL. */ - id?: string; - /** The type of object which was deleted. - internal_article */ - object?: "internal_article"; - /** Whether the internal article was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/types/DeletedObject.ts b/src/api/resources/unstable/types/DeletedObject.ts deleted file mode 100644 index a22b393b..00000000 --- a/src/api/resources/unstable/types/DeletedObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedObject { - /** The unique identifier for the news item which you provided in the URL. */ - id?: string; - /** The type of object which was deleted - news-item. */ - object?: "news-item"; - /** Whether the news item was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/resources/unstable/types/EmailAddressHeader.ts b/src/api/resources/unstable/types/EmailAddressHeader.ts deleted file mode 100644 index 7e8d234d..00000000 --- a/src/api/resources/unstable/types/EmailAddressHeader.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains data for an email address header for a conversation part that was sent as an email. - */ -export interface EmailAddressHeader { - /** The type of email address header */ - type?: string; - /** The email address */ - email_address?: string; - /** The name associated with the email address */ - name?: string; -} diff --git a/src/api/resources/unstable/types/EmailMessageMetadata.ts b/src/api/resources/unstable/types/EmailMessageMetadata.ts deleted file mode 100644 index 022108cf..00000000 --- a/src/api/resources/unstable/types/EmailMessageMetadata.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Contains metadata if the message was sent as an email - */ -export interface EmailMessageMetadata { - /** The subject of the email */ - subject?: string; - /** A list of an email address headers. */ - email_address_headers?: Intercom.unstable.EmailAddressHeader[]; - /** The unique identifier for the email message as specified in the Message-ID header */ - message_id?: string; -} diff --git a/src/api/resources/unstable/types/Error_.ts b/src/api/resources/unstable/types/Error_.ts deleted file mode 100644 index 91e726ed..00000000 --- a/src/api/resources/unstable/types/Error_.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The API will return an Error List for a failed request, which will contain one or more Error objects. - */ -export interface Error_ { - /** The type is error.list */ - type: string; - /** */ - request_id?: string; - /** An array of one or more error objects */ - errors: Error_.Errors.Item[]; -} - -export namespace Error_ { - export type Errors = Errors.Item[]; - - export namespace Errors { - export interface Item { - /** A string indicating the kind of error, used to further qualify the HTTP response code */ - code: string; - /** Optional. Human readable description of the error. */ - message?: string; - /** Optional. Used to identify a particular field or query parameter that was in error. */ - field?: string; - } - } -} diff --git a/src/api/resources/unstable/types/EventDetails.ts b/src/api/resources/unstable/types/EventDetails.ts deleted file mode 100644 index 422603dc..00000000 --- a/src/api/resources/unstable/types/EventDetails.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type EventDetails = - | Intercom.unstable.ConversationAttributeUpdatedByWorkflow - | Intercom.unstable.ConversationAttributeUpdatedByAdmin - | Intercom.unstable.ConversationAttributeUpdatedByUser - | Intercom.unstable.CustomActionStarted - | Intercom.unstable.CustomActionFinished - | Intercom.unstable.OperatorWorkflowEvent - | Intercom.unstable.ConversationTagsUpdated - | Intercom.unstable.Snoozed - | Intercom.unstable.PriorityChanged - | Intercom.unstable.ConversationSlaAppliedByRule - | Intercom.unstable.ConversationSlaAppliedByWorkflow - | Intercom.unstable.ConversationSlaTargetMissed - | Intercom.unstable.ConversationSlaPaused - | Intercom.unstable.ConversationSlaUnpaused - | Intercom.unstable.ConversationSlaRemoved; diff --git a/src/api/resources/unstable/types/FileAttribute.ts b/src/api/resources/unstable/types/FileAttribute.ts deleted file mode 100644 index b8fab036..00000000 --- a/src/api/resources/unstable/types/FileAttribute.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The value describing a file upload set for a custom attribute - */ -export interface FileAttribute { - type?: string; - /** The name of the file */ - name?: string; - /** The url of the file. This is a temporary URL and will expire after 30 minutes. */ - url?: string; - /** The type of file */ - content_type?: string; - /** The size of the file in bytes */ - filesize?: number; - /** The width of the file in pixels, if applicable */ - width?: number; - /** The height of the file in pixels, if applicable */ - height?: number; -} diff --git a/src/api/resources/unstable/types/GroupContent.ts b/src/api/resources/unstable/types/GroupContent.ts deleted file mode 100644 index 68c5b320..00000000 --- a/src/api/resources/unstable/types/GroupContent.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The Content of a Group. - */ -export interface GroupContent { - /** The type of object - `group_content` . */ - type?: "group_content"; - /** The name of the collection or section. */ - name?: string; - /** The description of the collection. Only available for collections. */ - description?: string; -} diff --git a/src/api/resources/unstable/types/GroupTranslatedContent.ts b/src/api/resources/unstable/types/GroupTranslatedContent.ts deleted file mode 100644 index c7b9933b..00000000 --- a/src/api/resources/unstable/types/GroupTranslatedContent.ts +++ /dev/null @@ -1,85 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The Translated Content of an Group. The keys are the locale codes and the values are the translated content of the Group. - */ -export interface GroupTranslatedContent { - /** The type of object - group_translated_content. */ - type?: "group_translated_content"; - /** The content of the group in Arabic */ - ar?: Intercom.unstable.GroupContent; - /** The content of the group in Bulgarian */ - bg?: Intercom.unstable.GroupContent; - /** The content of the group in Bosnian */ - bs?: Intercom.unstable.GroupContent; - /** The content of the group in Catalan */ - ca?: Intercom.unstable.GroupContent; - /** The content of the group in Czech */ - cs?: Intercom.unstable.GroupContent; - /** The content of the group in Danish */ - da?: Intercom.unstable.GroupContent; - /** The content of the group in German */ - de?: Intercom.unstable.GroupContent; - /** The content of the group in Greek */ - el?: Intercom.unstable.GroupContent; - /** The content of the group in English */ - en?: Intercom.unstable.GroupContent; - /** The content of the group in Spanish */ - es?: Intercom.unstable.GroupContent; - /** The content of the group in Estonian */ - et?: Intercom.unstable.GroupContent; - /** The content of the group in Finnish */ - fi?: Intercom.unstable.GroupContent; - /** The content of the group in French */ - fr?: Intercom.unstable.GroupContent; - /** The content of the group in Hebrew */ - he?: Intercom.unstable.GroupContent; - /** The content of the group in Croatian */ - hr?: Intercom.unstable.GroupContent; - /** The content of the group in Hungarian */ - hu?: Intercom.unstable.GroupContent; - /** The content of the group in Indonesian */ - id?: Intercom.unstable.GroupContent; - /** The content of the group in Italian */ - it?: Intercom.unstable.GroupContent; - /** The content of the group in Japanese */ - ja?: Intercom.unstable.GroupContent; - /** The content of the group in Korean */ - ko?: Intercom.unstable.GroupContent; - /** The content of the group in Lithuanian */ - lt?: Intercom.unstable.GroupContent; - /** The content of the group in Latvian */ - lv?: Intercom.unstable.GroupContent; - /** The content of the group in Mongolian */ - mn?: Intercom.unstable.GroupContent; - /** The content of the group in Norwegian */ - nb?: Intercom.unstable.GroupContent; - /** The content of the group in Dutch */ - nl?: Intercom.unstable.GroupContent; - /** The content of the group in Polish */ - pl?: Intercom.unstable.GroupContent; - /** The content of the group in Portuguese (Portugal) */ - pt?: Intercom.unstable.GroupContent; - /** The content of the group in Romanian */ - ro?: Intercom.unstable.GroupContent; - /** The content of the group in Russian */ - ru?: Intercom.unstable.GroupContent; - /** The content of the group in Slovenian */ - sl?: Intercom.unstable.GroupContent; - /** The content of the group in Serbian */ - sr?: Intercom.unstable.GroupContent; - /** The content of the group in Swedish */ - sv?: Intercom.unstable.GroupContent; - /** The content of the group in Turkish */ - tr?: Intercom.unstable.GroupContent; - /** The content of the group in Vietnamese */ - vi?: Intercom.unstable.GroupContent; - /** The content of the group in Portuguese (Brazil) */ - "pt-BR"?: Intercom.unstable.GroupContent; - /** The content of the group in Chinese (China) */ - "zh-CN"?: Intercom.unstable.GroupContent; - /** The content of the group in Chinese (Taiwan) */ - "zh-TW"?: Intercom.unstable.GroupContent; -} diff --git a/src/api/resources/unstable/types/HandlingEvent.ts b/src/api/resources/unstable/types/HandlingEvent.ts deleted file mode 100644 index f6d3e9d6..00000000 --- a/src/api/resources/unstable/types/HandlingEvent.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A pause or resume event for a conversation - */ -export interface HandlingEvent { - teammate: Intercom.unstable.TeammateReference; - /** The type of handling event */ - type: HandlingEvent.Type; - /** ISO8601 timestamp when the event occurred */ - timestamp: string; - /** Optional reason for the event (e.g., "Paused", "Away") */ - reason?: string; -} - -export namespace HandlingEvent { - /** The type of handling event */ - export const Type = { - Paused: "paused", - Resumed: "resumed", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/HandlingEventList.ts b/src/api/resources/unstable/types/HandlingEventList.ts deleted file mode 100644 index 57dfe2d2..00000000 --- a/src/api/resources/unstable/types/HandlingEventList.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of handling events for a conversation - */ -export interface HandlingEventList { - /** Array of handling events */ - handling_events?: Intercom.unstable.HandlingEvent[]; -} diff --git a/src/api/resources/unstable/types/InternalArticleList.ts b/src/api/resources/unstable/types/InternalArticleList.ts deleted file mode 100644 index 5f5f6df8..00000000 --- a/src/api/resources/unstable/types/InternalArticleList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of internal articles for the App. - */ -export interface InternalArticleList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.unstable.CursorPages; - /** A count of the total number of internal articles. */ - total_count?: number; - /** An array of Internal Article objects */ - data?: Intercom.unstable.InternalArticleListItem[]; -} diff --git a/src/api/resources/unstable/types/LinkedObject.ts b/src/api/resources/unstable/types/LinkedObject.ts deleted file mode 100644 index 27fe77b5..00000000 --- a/src/api/resources/unstable/types/LinkedObject.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A linked conversation or ticket. - */ -export interface LinkedObject { - /** ticket or conversation */ - type?: LinkedObject.Type; - /** The ID of the linked object */ - id?: string; - /** Category of the Linked Ticket Object. */ - category?: LinkedObject.Category; -} - -export namespace LinkedObject { - /** ticket or conversation */ - export const Type = { - Ticket: "ticket", - Conversation: "conversation", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - /** Category of the Linked Ticket Object. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/unstable/types/LinkedObjectList.ts b/src/api/resources/unstable/types/LinkedObjectList.ts deleted file mode 100644 index b17171e1..00000000 --- a/src/api/resources/unstable/types/LinkedObjectList.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * An object containing metadata about linked conversations and linked tickets. Up to 1000 can be returned. - */ -export interface LinkedObjectList { - /** Always list. */ - type?: "list"; - /** The total number of linked objects. */ - total_count?: number; - /** Whether or not there are more linked objects than returned. */ - has_more?: boolean; - /** An array containing the linked conversations and linked tickets. */ - data?: Intercom.unstable.LinkedObject[]; -} diff --git a/src/api/resources/unstable/types/MultipleFilterSearchRequest.ts b/src/api/resources/unstable/types/MultipleFilterSearchRequest.ts deleted file mode 100644 index 4d834701..00000000 --- a/src/api/resources/unstable/types/MultipleFilterSearchRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Search using Intercoms Search APIs with more than one filter. - */ -export interface MultipleFilterSearchRequest { - /** An operator to allow boolean inspection between multiple fields. */ - operator?: MultipleFilterSearchRequest.Operator; - value?: MultipleFilterSearchRequest.Value; -} - -export namespace MultipleFilterSearchRequest { - /** An operator to allow boolean inspection between multiple fields. */ - export const Operator = { - And: "AND", - Or: "OR", - } as const; - export type Operator = (typeof Operator)[keyof typeof Operator]; - export type Value = - /** - * Add mutiple filters. */ - | Intercom.unstable.MultipleFilterSearchRequest[] - /** - * Add a single filter field. */ - | Intercom.unstable.SingleFilterSearchRequest[]; -} diff --git a/src/api/resources/unstable/types/NewsItemRequest.ts b/src/api/resources/unstable/types/NewsItemRequest.ts deleted file mode 100644 index 9735b4fc..00000000 --- a/src/api/resources/unstable/types/NewsItemRequest.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A News Item is a content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers. - */ -export interface NewsItemRequest { - /** The title of the news item. */ - title: string; - /** The news item body, which may contain HTML. */ - body?: string; - /** The id of the sender of the news item. Must be a teammate on the workspace. */ - sender_id: number; - /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ - state?: NewsItemRequest.State; - /** When set to `true`, the news item will appear in the messenger newsfeed without showing a notification badge. */ - deliver_silently?: boolean; - /** Label names displayed to users to categorize the news item. */ - labels?: string[]; - /** Ordered list of emoji reactions to the news item. When empty, reactions are disabled. */ - reactions?: (string | undefined)[]; - /** A list of newsfeed_assignments to assign to the specified newsfeed. */ - newsfeed_assignments?: Intercom.unstable.NewsfeedAssignment[]; -} - -export namespace NewsItemRequest { - /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ - export const State = { - Draft: "draft", - Live: "live", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/types/NotFoundErrorBody.ts b/src/api/resources/unstable/types/NotFoundErrorBody.ts deleted file mode 100644 index de9109f3..00000000 --- a/src/api/resources/unstable/types/NotFoundErrorBody.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface NotFoundErrorBody { - /** The type is error.list */ - type: string; - /** */ - request_id?: string; - /** An array of one or more error objects */ - errors: NotFoundErrorBody.Errors.Item[]; -} - -export namespace NotFoundErrorBody { - export type Errors = Errors.Item[]; - - export namespace Errors { - export interface Item { - /** ticket_not_found */ - code: string; - /** Ticket not found */ - message?: string; - } - } -} diff --git a/src/api/resources/unstable/types/NoteList.ts b/src/api/resources/unstable/types/NoteList.ts deleted file mode 100644 index 0f1e8fe4..00000000 --- a/src/api/resources/unstable/types/NoteList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A paginated list of notes associated with a contact or a company. - */ -export interface NoteList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** An array of notes. */ - data?: Intercom.unstable.Note[]; - /** A count of the total number of notes. */ - total_count?: number; - pages?: Intercom.unstable.CursorPages; -} diff --git a/src/api/resources/unstable/types/OpenConversationRequest.ts b/src/api/resources/unstable/types/OpenConversationRequest.ts deleted file mode 100644 index b3e63714..00000000 --- a/src/api/resources/unstable/types/OpenConversationRequest.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to open a conversation - */ -export interface OpenConversationRequest { - /** The id of the admin who is performing the action. */ - admin_id: string; -} diff --git a/src/api/resources/unstable/types/OperatorWorkflowEvent.ts b/src/api/resources/unstable/types/OperatorWorkflowEvent.ts deleted file mode 100644 index df8629d3..00000000 --- a/src/api/resources/unstable/types/OperatorWorkflowEvent.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about name of the workflow for conversation part type operator_workflow_event. - */ -export interface OperatorWorkflowEvent { - workflow?: OperatorWorkflowEvent.Workflow; - event?: OperatorWorkflowEvent.Event; -} - -export namespace OperatorWorkflowEvent { - export interface Workflow { - /** The name of the workflow */ - name?: string; - } - - export interface Event { - /** Type of the workflow event initiated */ - type?: string; - /** Result of the workflow event */ - result?: string; - } -} diff --git a/src/api/resources/unstable/types/PagesLink.ts b/src/api/resources/unstable/types/PagesLink.ts deleted file mode 100644 index 59d698ff..00000000 --- a/src/api/resources/unstable/types/PagesLink.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The majority of list resources in the API are paginated to allow clients to traverse data over multiple requests. - * - * Their responses are likely to contain a pages object that hosts pagination links which a client can use to paginate through the data without having to construct a query. The link relations for the pages field are as follows. - */ -export interface PagesLink { - type?: "pages"; - page?: number; - /** A link to the next page of results. A response that does not contain a next link does not have further data to fetch. */ - next?: string; - per_page?: number; - total_pages?: number; -} diff --git a/src/api/resources/unstable/types/PaginatedResponse.ts b/src/api/resources/unstable/types/PaginatedResponse.ts deleted file mode 100644 index 64972bf9..00000000 --- a/src/api/resources/unstable/types/PaginatedResponse.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Paginated Response - */ -export interface PaginatedResponse { - /** The type of object */ - type?: PaginatedResponse.Type; - pages?: Intercom.unstable.CursorPages; - /** A count of the total number of objects. */ - total_count?: number; - /** An array of Objects */ - data?: Intercom.unstable.PaginatedResponseDataItem[]; -} - -export namespace PaginatedResponse { - /** The type of object */ - export const Type = { - List: "list", - ConversationList: "conversation.list", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/PaginatedResponseDataItem.ts b/src/api/resources/unstable/types/PaginatedResponseDataItem.ts deleted file mode 100644 index 65655304..00000000 --- a/src/api/resources/unstable/types/PaginatedResponseDataItem.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type PaginatedResponseDataItem = - | Intercom.unstable.PaginatedResponseDataItem.NewsItem - | Intercom.unstable.PaginatedResponseDataItem.Newsfeed; - -export namespace PaginatedResponseDataItem { - export interface NewsItem extends Intercom.unstable.NewsItem { - type: "news-item"; - } - - export interface Newsfeed extends Intercom.unstable.Newsfeed { - type: "newsfeed"; - } -} diff --git a/src/api/resources/unstable/types/PartAttachment.ts b/src/api/resources/unstable/types/PartAttachment.ts deleted file mode 100644 index 3c01b778..00000000 --- a/src/api/resources/unstable/types/PartAttachment.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The file attached to a part - */ -export interface PartAttachment { - /** The type of attachment */ - type?: string; - /** The name of the attachment */ - name?: string; - /** The URL of the attachment */ - url?: string; - /** The content type of the attachment */ - content_type?: string; - /** The size of the attachment */ - filesize?: number; - /** The width of the attachment */ - width?: number; - /** The height of the attachment */ - height?: number; -} diff --git a/src/api/resources/unstable/types/PhoneSwitch.ts b/src/api/resources/unstable/types/PhoneSwitch.ts deleted file mode 100644 index 5fbeb892..00000000 --- a/src/api/resources/unstable/types/PhoneSwitch.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Phone Switch Response - */ -export interface PhoneSwitch { - /** */ - type?: "phone_call_redirect"; - /** Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. */ - phone?: string; -} diff --git a/src/api/resources/unstable/types/PriorityChanged.ts b/src/api/resources/unstable/types/PriorityChanged.ts deleted file mode 100644 index f09b55df..00000000 --- a/src/api/resources/unstable/types/PriorityChanged.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about priority changes for conversation part type priority_changed. - */ -export interface PriorityChanged { - /** Current priority state */ - current_priority?: PriorityChanged.CurrentPriority; - /** Previous priority state */ - previous_priority?: PriorityChanged.PreviousPriority; -} - -export namespace PriorityChanged { - /** Current priority state */ - export const CurrentPriority = { - Priority: "priority", - NotPriority: "not_priority", - } as const; - export type CurrentPriority = (typeof CurrentPriority)[keyof typeof CurrentPriority]; - /** Previous priority state */ - export const PreviousPriority = { - Priority: "priority", - NotPriority: "not_priority", - } as const; - export type PreviousPriority = (typeof PreviousPriority)[keyof typeof PreviousPriority]; -} diff --git a/src/api/resources/unstable/types/QuickReplyOption.ts b/src/api/resources/unstable/types/QuickReplyOption.ts deleted file mode 100644 index 8de2d400..00000000 --- a/src/api/resources/unstable/types/QuickReplyOption.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface QuickReplyOption { - /** The text to display in this quick reply option. */ - text: string; - /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment conversation part that is created when a user clicks on this reply option. */ - uuid: string; -} diff --git a/src/api/resources/unstable/types/Recipient.ts b/src/api/resources/unstable/types/Recipient.ts deleted file mode 100644 index 194d11d0..00000000 --- a/src/api/resources/unstable/types/Recipient.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A recipient of a message - */ -export interface Recipient { - /** The role associated to the contact - `user` or `lead`. */ - type: Recipient.Type; - /** The identifier for the contact which is given by Intercom. */ - id: string; -} - -export namespace Recipient { - /** The role associated to the contact - `user` or `lead`. */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/RedactConversationRequest.ts b/src/api/resources/unstable/types/RedactConversationRequest.ts deleted file mode 100644 index f4845e8e..00000000 --- a/src/api/resources/unstable/types/RedactConversationRequest.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type RedactConversationRequest = - /** - * Payload of the request to redact a conversation part */ - | Intercom.unstable.RedactConversationRequest.ConversationPart - /** - * Payload of the request to redact a conversation source */ - | Intercom.unstable.RedactConversationRequest.Source; - -export namespace RedactConversationRequest { - export interface ConversationPart { - type: "conversation_part"; - /** The id of the conversation. */ - conversation_id: string; - /** The id of the conversation_part. */ - conversation_part_id: string; - } - - export interface Source { - type: "source"; - /** The id of the conversation. */ - conversation_id: string; - /** The id of the source. */ - source_id: string; - } -} diff --git a/src/api/resources/unstable/types/Reference.ts b/src/api/resources/unstable/types/Reference.ts deleted file mode 100644 index 7c9c82a3..00000000 --- a/src/api/resources/unstable/types/Reference.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * reference to another object - */ -export interface Reference { - /** */ - type?: string; - /** */ - id?: string; -} diff --git a/src/api/resources/unstable/types/RegisterFinVoiceCallRequest.ts b/src/api/resources/unstable/types/RegisterFinVoiceCallRequest.ts deleted file mode 100644 index 2fd07f21..00000000 --- a/src/api/resources/unstable/types/RegisterFinVoiceCallRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Register a Fin Voice call with Intercom - */ -export interface RegisterFinVoiceCallRequest { - /** Phone number in E.164 format for the call */ - phone_number: string; - /** External call identifier from the call provider */ - call_id: string; - /** Source of the call. Can be "five9", "zoom_phone", or defaults to "aws_connect" */ - source?: RegisterFinVoiceCallRequest.Source; - /** Additional metadata about the call */ - data?: Record; -} - -export namespace RegisterFinVoiceCallRequest { - /** Source of the call. Can be "five9", "zoom_phone", or defaults to "aws_connect" */ - export const Source = { - Five9: "five9", - ZoomPhone: "zoom_phone", - AwsConnect: "aws_connect", - } as const; - export type Source = (typeof Source)[keyof typeof Source]; -} diff --git a/src/api/resources/unstable/types/ReplyConversationRequestBody.ts b/src/api/resources/unstable/types/ReplyConversationRequestBody.ts deleted file mode 100644 index 3f05df15..00000000 --- a/src/api/resources/unstable/types/ReplyConversationRequestBody.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type ReplyConversationRequestBody = - | Intercom.unstable.ContactReplyConversationRequest - | Intercom.unstable.AdminReplyConversationRequest; diff --git a/src/api/resources/unstable/types/SearchRequest.ts b/src/api/resources/unstable/types/SearchRequest.ts deleted file mode 100644 index 796d8fc5..00000000 --- a/src/api/resources/unstable/types/SearchRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Search using Intercoms Search APIs. - */ -export interface SearchRequest { - query: SearchRequest.Query; - pagination?: Intercom.unstable.StartingAfterPaging; -} - -export namespace SearchRequest { - export type Query = Intercom.unstable.SingleFilterSearchRequest | Intercom.unstable.MultipleFilterSearchRequest; -} diff --git a/src/api/resources/unstable/types/SegmentList.ts b/src/api/resources/unstable/types/SegmentList.ts deleted file mode 100644 index 7a3ae83b..00000000 --- a/src/api/resources/unstable/types/SegmentList.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of Segment Objects. The result may also have a pages object if the response is paginated. - */ -export interface SegmentList { - /** The type of the object */ - type?: "segment.list"; - /** A list of Segment objects */ - segments?: Intercom.unstable.Segment[]; - /** A pagination object, which may be empty, indicating no further pages to fetch. */ - pages?: Record; -} diff --git a/src/api/resources/unstable/types/SingleFilterSearchRequest.ts b/src/api/resources/unstable/types/SingleFilterSearchRequest.ts deleted file mode 100644 index 58808cb4..00000000 --- a/src/api/resources/unstable/types/SingleFilterSearchRequest.ts +++ /dev/null @@ -1,30 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Search using Intercoms Search APIs with a single filter. - */ -export interface SingleFilterSearchRequest { - /** The accepted field that you want to search on. */ - field?: string; - /** The accepted operators you can use to define how you want to search for the value. */ - operator?: SingleFilterSearchRequest.Operator; - /** The value that you want to search on. */ - value?: SingleFilterSearchRequest.Value; -} - -export namespace SingleFilterSearchRequest { - /** The accepted operators you can use to define how you want to search for the value. */ - export const Operator = { - EqualTo: "=", - NotEquals: "!=", - In: "IN", - Nin: "NIN", - LessThan: "<", - GreaterThan: ">", - } as const; - export type Operator = (typeof Operator)[keyof typeof Operator]; - /** - * The value that you want to search on. - */ - export type Value = string | number | (string | number)[]; -} diff --git a/src/api/resources/unstable/types/SlaApplied.ts b/src/api/resources/unstable/types/SlaApplied.ts deleted file mode 100644 index 3ea77f62..00000000 --- a/src/api/resources/unstable/types/SlaApplied.ts +++ /dev/null @@ -1,35 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The SLA Applied object contains the details for which SLA has been applied to this conversation. - * Important: if there are any canceled sla_events for the conversation - meaning an SLA has been manually removed from a conversation, the sla_status will always be returned as null. - */ -export interface SlaApplied { - /** object type */ - type?: string; - /** The name of the SLA as given by the teammate when it was created. */ - sla_name?: string; - /** - * SLA statuses: - * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. - * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. - * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. - */ - sla_status?: SlaApplied.SlaStatus; -} - -export namespace SlaApplied { - /** - * SLA statuses: - * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. - * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. - * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. - */ - export const SlaStatus = { - Hit: "hit", - Missed: "missed", - Cancelled: "cancelled", - Active: "active", - } as const; - export type SlaStatus = (typeof SlaStatus)[keyof typeof SlaStatus]; -} diff --git a/src/api/resources/unstable/types/SnoozeConversationRequest.ts b/src/api/resources/unstable/types/SnoozeConversationRequest.ts deleted file mode 100644 index 7e3e7061..00000000 --- a/src/api/resources/unstable/types/SnoozeConversationRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to snooze a conversation - */ -export interface SnoozeConversationRequest { - /** The id of the admin who is performing the action. */ - admin_id: string; - /** The time you want the conversation to reopen. */ - snoozed_until: number; -} diff --git a/src/api/resources/unstable/types/Snoozed.ts b/src/api/resources/unstable/types/Snoozed.ts deleted file mode 100644 index c8ea22fc..00000000 --- a/src/api/resources/unstable/types/Snoozed.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about conversation snooze timing for conversation part type snoozed. - */ -export interface Snoozed { - /** Human-readable description of snooze duration */ - until?: string; - /** ISO timestamp for custom snooze times (null for general snoozes) */ - custom_until_time?: string; -} diff --git a/src/api/resources/unstable/types/SocialProfile.ts b/src/api/resources/unstable/types/SocialProfile.ts deleted file mode 100644 index 5beba459..00000000 --- a/src/api/resources/unstable/types/SocialProfile.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A Social Profile allows you to label your contacts, companies, and conversations and list them using that Social Profile. - */ -export interface SocialProfile { - /** value is "social_profile" */ - type?: string; - /** The name of the Social media profile */ - name?: string; - /** The name of the Social media profile */ - url?: string; -} diff --git a/src/api/resources/unstable/types/StartingAfterPaging.ts b/src/api/resources/unstable/types/StartingAfterPaging.ts deleted file mode 100644 index 6fc82b73..00000000 --- a/src/api/resources/unstable/types/StartingAfterPaging.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface StartingAfterPaging { - /** The number of results to fetch per page. */ - per_page?: number; - /** The cursor to use in the next request to get the next page of results. */ - starting_after?: string; -} diff --git a/src/api/resources/unstable/types/SubscriptionTypeList.ts b/src/api/resources/unstable/types/SubscriptionTypeList.ts deleted file mode 100644 index 977b74d8..00000000 --- a/src/api/resources/unstable/types/SubscriptionTypeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of subscription type objects. - */ -export interface SubscriptionTypeList { - /** The type of the object */ - type?: "list"; - /** A list of subscription type objects associated with the workspace . */ - data?: Intercom.unstable.SubscriptionType[]; -} diff --git a/src/api/resources/unstable/types/TagCompanyRequest.ts b/src/api/resources/unstable/types/TagCompanyRequest.ts deleted file mode 100644 index 4f4affb5..00000000 --- a/src/api/resources/unstable/types/TagCompanyRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can tag a single company or a list of companies. - */ -export interface TagCompanyRequest { - /** The name of the tag, which will be created if not found. */ - name: string; - /** The id or company_id of the company can be passed as input parameters. */ - companies: TagCompanyRequest.Companies.Item[]; -} - -export namespace TagCompanyRequest { - export type Companies = Companies.Item[]; - - export namespace Companies { - export interface Item { - /** The Intercom defined id representing the company. */ - id?: string; - /** The company id you have defined for the company. */ - company_id?: string; - } - } -} diff --git a/src/api/resources/unstable/types/TagList.ts b/src/api/resources/unstable/types/TagList.ts deleted file mode 100644 index 5aba89c4..00000000 --- a/src/api/resources/unstable/types/TagList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of tags objects in the workspace. - */ -export interface TagList { - /** The type of the object */ - type?: "list"; - /** A list of tags objects associated with the workspace . */ - data?: Intercom.unstable.Tag[]; -} diff --git a/src/api/resources/unstable/types/TagMultipleUsersRequest.ts b/src/api/resources/unstable/types/TagMultipleUsersRequest.ts deleted file mode 100644 index fc697987..00000000 --- a/src/api/resources/unstable/types/TagMultipleUsersRequest.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can tag a list of users. - */ -export interface TagMultipleUsersRequest { - /** The name of the tag, which will be created if not found. */ - name: string; - users: TagMultipleUsersRequest.Users.Item[]; -} - -export namespace TagMultipleUsersRequest { - export type Users = Users.Item[]; - - export namespace Users { - export interface Item { - /** The Intercom defined id representing the user. */ - id?: string; - } - } -} diff --git a/src/api/resources/unstable/types/Tags.ts b/src/api/resources/unstable/types/Tags.ts deleted file mode 100644 index e968cf71..00000000 --- a/src/api/resources/unstable/types/Tags.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of tags objects associated with a conversation - */ -export interface Tags { - /** The type of the object */ - type?: "tag.list"; - /** A list of tags objects associated with the conversation. */ - tags?: Intercom.unstable.Tag[]; -} diff --git a/src/api/resources/unstable/types/TeamList.ts b/src/api/resources/unstable/types/TeamList.ts deleted file mode 100644 index c711e412..00000000 --- a/src/api/resources/unstable/types/TeamList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of team objects for the App. - */ -export interface TeamList { - /** The type of the object */ - type?: "team.list"; - /** A list of team objects */ - teams?: Intercom.unstable.Team[]; -} diff --git a/src/api/resources/unstable/types/TeamPriorityLevel.ts b/src/api/resources/unstable/types/TeamPriorityLevel.ts deleted file mode 100644 index 07d6bae5..00000000 --- a/src/api/resources/unstable/types/TeamPriorityLevel.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Admin priority levels for teams - */ -export interface TeamPriorityLevel { - /** The primary team ids for the team */ - primary_team_ids?: number[]; - /** The secondary team ids for the team */ - secondary_team_ids?: number[]; -} diff --git a/src/api/resources/unstable/types/TeammateReference.ts b/src/api/resources/unstable/types/TeammateReference.ts deleted file mode 100644 index 913ea0b2..00000000 --- a/src/api/resources/unstable/types/TeammateReference.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A reference to a teammate (admin, team, or bot) - */ -export interface TeammateReference { - /** The type of teammate */ - type: TeammateReference.Type; - /** The unique identifier of the teammate */ - id: number; - /** The display name of the teammate */ - name: string; - /** The email address of the teammate (optional for teams/bots) */ - email?: string; -} - -export namespace TeammateReference { - /** The type of teammate */ - export const Type = { - Admin: "admin", - Team: "team", - Bot: "bot", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/TicketCustomAttributes.ts b/src/api/resources/unstable/types/TicketCustomAttributes.ts deleted file mode 100644 index c3cb349e..00000000 --- a/src/api/resources/unstable/types/TicketCustomAttributes.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * An object containing the different attributes associated to the ticket as key-value pairs. For the default title and description attributes, the keys are `_default_title_` and `_default_description_`. - */ -export type TicketCustomAttributes = Record; - -export namespace TicketCustomAttributes { - export type Value = string | undefined | number | boolean | unknown[] | Intercom.unstable.FileAttribute; -} diff --git a/src/api/resources/unstable/types/TicketList.ts b/src/api/resources/unstable/types/TicketList.ts deleted file mode 100644 index b1545342..00000000 --- a/src/api/resources/unstable/types/TicketList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Tickets are how you track requests from your users. - */ -export interface TicketList { - /** Always ticket.list */ - type?: "ticket.list"; - /** The list of ticket objects */ - tickets?: (Intercom.unstable.Ticket | undefined)[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.unstable.CursorPages; -} diff --git a/src/api/resources/unstable/types/TicketPartAuthor.ts b/src/api/resources/unstable/types/TicketPartAuthor.ts deleted file mode 100644 index e0ea7ff3..00000000 --- a/src/api/resources/unstable/types/TicketPartAuthor.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The author that wrote or triggered the part. Can be a bot, admin, team or user. - */ -export interface TicketPartAuthor { - /** The type of the author */ - type?: TicketPartAuthor.Type; - /** The id of the author */ - id?: string; - /** The name of the author */ - name?: string; - /** The email of the author */ - email?: string; -} - -export namespace TicketPartAuthor { - /** The type of the author */ - export const Type = { - Admin: "admin", - Bot: "bot", - Team: "team", - User: "user", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/TicketParts.ts b/src/api/resources/unstable/types/TicketParts.ts deleted file mode 100644 index 95c99271..00000000 --- a/src/api/resources/unstable/types/TicketParts.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of Ticket Part objects for each note and event in the ticket. There is a limit of 500 parts. - */ -export interface TicketParts { - /** */ - type?: "ticket_part.list"; - /** A list of Ticket Part objects for each ticket. There is a limit of 500 parts. */ - ticket_parts?: Intercom.unstable.TicketPart[]; - /** */ - total_count?: number; -} diff --git a/src/api/resources/unstable/types/TicketReply.ts b/src/api/resources/unstable/types/TicketReply.ts deleted file mode 100644 index 1a648076..00000000 --- a/src/api/resources/unstable/types/TicketReply.ts +++ /dev/null @@ -1,36 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A Ticket Part representing a note, comment, or quick_reply on a ticket - */ -export interface TicketReply { - /** Always ticket_part */ - type?: "ticket_part"; - /** The id representing the part. */ - id?: string; - /** Type of the part */ - part_type?: TicketReply.PartType; - /** The message body, which may contain HTML. */ - body?: string; - /** The time the note was created. */ - created_at?: number; - /** The last time the note was updated. */ - updated_at?: number; - author?: Intercom.unstable.TicketPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.unstable.PartAttachment[]; - /** Whether or not the ticket part has been redacted. */ - redacted?: boolean; -} - -export namespace TicketReply { - /** Type of the part */ - export const PartType = { - Note: "note", - Comment: "comment", - QuickReply: "quick_reply", - } as const; - export type PartType = (typeof PartType)[keyof typeof PartType]; -} diff --git a/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts b/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts deleted file mode 100644 index 6f54ade8..00000000 --- a/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The attributes set on the ticket. When setting the default title and description attributes, the attribute keys that should be used are `_default_title_` and `_default_description_`. When setting ticket type attributes of the list attribute type, the key should be the attribute name and the value of the attribute should be the list item id, obtainable by [listing the ticket type](ref:get_ticket-types). For example, if the ticket type has an attribute called `priority` of type `list`, the key should be `priority` and the value of the attribute should be the guid of the list item (e.g. `de1825a0-0164-4070-8ca6-13e22462fa7e`). - */ -export type TicketRequestCustomAttributes = Record; - -export namespace TicketRequestCustomAttributes { - export type Value = string | undefined | number | boolean | unknown[]; -} diff --git a/src/api/resources/unstable/types/TicketStateList.ts b/src/api/resources/unstable/types/TicketStateList.ts deleted file mode 100644 index 51e43516..00000000 --- a/src/api/resources/unstable/types/TicketStateList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of ticket states associated with a given ticket type. - */ -export interface TicketStateList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of ticket states associated with a given ticket type. */ - data?: (Intercom.unstable.TicketStateDetailed | undefined)[]; -} diff --git a/src/api/resources/unstable/types/TicketTypeAttribute.ts b/src/api/resources/unstable/types/TicketTypeAttribute.ts deleted file mode 100644 index f634dd96..00000000 --- a/src/api/resources/unstable/types/TicketTypeAttribute.ts +++ /dev/null @@ -1,41 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Ticket type attribute, used to define each data field to be captured in a ticket. - */ -export interface TicketTypeAttribute { - /** String representing the object's type. Always has the value `ticket_type_attribute`. */ - type?: string; - /** The id representing the ticket type attribute. */ - id?: string; - /** The id of the workspace that the ticket type attribute belongs to. */ - workspace_id?: string; - /** The name of the ticket type attribute */ - name?: string; - /** The description of the ticket type attribute */ - description?: string; - /** The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ - data_type?: string; - /** Input options for the attribute */ - input_options?: Record; - /** The order of the attribute against other attributes */ - order?: number; - /** Whether the attribute is required or not for teammates. */ - required_to_create?: boolean; - /** Whether the attribute is required or not for contacts. */ - required_to_create_for_contacts?: boolean; - /** Whether the attribute is visible or not to teammates. */ - visible_on_create?: boolean; - /** Whether the attribute is visible or not to contacts. */ - visible_to_contacts?: boolean; - /** Whether the attribute is built in or not. */ - default?: boolean; - /** The id of the ticket type that the attribute belongs to. */ - ticket_type_id?: number; - /** Whether the ticket type attribute is archived or not. */ - archived?: boolean; - /** The date and time the ticket type attribute was created. */ - created_at?: number; - /** The date and time the ticket type attribute was last updated. */ - updated_at?: number; -} diff --git a/src/api/resources/unstable/types/TicketTypeAttributeList.ts b/src/api/resources/unstable/types/TicketTypeAttributeList.ts deleted file mode 100644 index 1466cda0..00000000 --- a/src/api/resources/unstable/types/TicketTypeAttributeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of attributes associated with a given ticket type. - */ -export interface TicketTypeAttributeList { - /** String representing the object's type. Always has the value `ticket_type_attributes.list`. */ - type?: string; - /** A list of ticket type attributes associated with a given ticket type. */ - ticket_type_attributes?: (Intercom.unstable.TicketTypeAttribute | undefined)[]; -} diff --git a/src/api/resources/unstable/types/TicketTypeList.ts b/src/api/resources/unstable/types/TicketTypeList.ts deleted file mode 100644 index 7b839c67..00000000 --- a/src/api/resources/unstable/types/TicketTypeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of ticket types associated with a given workspace. - */ -export interface TicketTypeList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of ticket_types associated with a given workspace. */ - data?: (Intercom.unstable.TicketType | undefined)[]; -} diff --git a/src/api/resources/unstable/types/Translation.ts b/src/api/resources/unstable/types/Translation.ts deleted file mode 100644 index 3d656a16..00000000 --- a/src/api/resources/unstable/types/Translation.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A translation object contains the localised details of a subscription type. - */ -export interface Translation { - /** The localised name of the subscription type. */ - name?: string; - /** The localised description of the subscription type. */ - description?: string; - /** The two character identifier for the language of the translation object. */ - locale?: string; -} diff --git a/src/api/resources/unstable/types/UntagCompanyRequest.ts b/src/api/resources/unstable/types/UntagCompanyRequest.ts deleted file mode 100644 index 09886bd1..00000000 --- a/src/api/resources/unstable/types/UntagCompanyRequest.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can tag a single company or a list of companies. - */ -export interface UntagCompanyRequest { - /** The name of the tag which will be untagged from the company */ - name: string; - /** The id or company_id of the company can be passed as input parameters. */ - companies: UntagCompanyRequest.Companies.Item[]; -} - -export namespace UntagCompanyRequest { - export type Companies = Companies.Item[]; - - export namespace Companies { - export interface Item { - /** The Intercom defined id representing the company. */ - id?: string; - /** The company id you have defined for the company. */ - company_id?: string; - /** Always set to true */ - untag?: boolean; - } - } -} diff --git a/src/api/resources/unstable/types/UpdateDataAttributeRequestBody.ts b/src/api/resources/unstable/types/UpdateDataAttributeRequestBody.ts deleted file mode 100644 index 6524ae99..00000000 --- a/src/api/resources/unstable/types/UpdateDataAttributeRequestBody.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type UpdateDataAttributeRequestBody = - | { - options: { - value?: string | undefined; - }[]; - } - | unknown; diff --git a/src/api/resources/unstable/types/Visitor.ts b/src/api/resources/unstable/types/Visitor.ts deleted file mode 100644 index 32dcf169..00000000 --- a/src/api/resources/unstable/types/Visitor.ts +++ /dev/null @@ -1,136 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Visitors are useful for representing anonymous people that have not yet been identified. They usually represent website visitors. Visitors are not visible in Intercom platform. The Visitors resource provides methods to fetch, update, convert and delete. - */ -export interface Visitor { - /** Value is 'visitor' */ - type?: string; - /** The Intercom defined id representing the Visitor. */ - id?: string; - /** Automatically generated identifier for the Visitor. */ - user_id?: string; - /** Identifies if this visitor is anonymous. */ - anonymous?: boolean; - /** The email of the visitor. */ - email?: string; - /** The phone number of the visitor. */ - phone?: string; - /** The name of the visitor. */ - name?: string; - /** The pseudonym of the visitor. */ - pseudonym?: string; - avatar?: Visitor.Avatar; - /** The id of the app the visitor is associated with. */ - app_id?: string; - companies?: Visitor.Companies; - location_data?: Visitor.LocationData; - /** The time the Lead last recorded making a request. */ - las_request_at?: number; - /** The time the Visitor was added to Intercom. */ - created_at?: number; - /** The time the Visitor was added to Intercom. */ - remote_created_at?: number; - /** The time the Visitor signed up for your product. */ - signed_up_at?: number; - /** The last time the Visitor was updated. */ - updated_at?: number; - /** The number of sessions the Visitor has had. */ - session_count?: number; - social_profiles?: Visitor.SocialProfiles; - /** The id of the admin that owns the Visitor. */ - owner_id?: string; - /** Whether the Visitor is unsubscribed from emails. */ - unsubscribed_from_emails?: boolean; - /** Identifies if this visitor has marked an email as spam. */ - marked_email_as_spam?: boolean; - /** Identifies if this visitor has had a hard bounce. */ - has_hard_bounced?: boolean; - tags?: Visitor.Tags; - segments?: Visitor.Segments; - /** The custom attributes you have set on the Visitor. */ - custom_attributes?: Record; - /** The referer of the visitor. */ - referrer?: string; - /** The utm_campaign of the visitor. */ - utm_campaign?: string; - /** The utm_content of the visitor. */ - utm_content?: string; - /** The utm_medium of the visitor. */ - utm_medium?: string; - /** The utm_source of the visitor. */ - utm_source?: string; - /** The utm_term of the visitor. */ - utm_term?: string; - /** Identifies if this visitor has do not track enabled. */ - do_not_track?: boolean; -} - -export namespace Visitor { - export interface Avatar { - /** */ - type?: string; - /** This object represents the avatar associated with the visitor. */ - image_url?: string; - } - - export interface Companies { - /** The type of the object */ - type?: "company.list"; - companies?: Intercom.unstable.Company[]; - } - - export interface LocationData { - /** */ - type?: string; - /** The city name of the visitor. */ - city_name?: string; - /** The continent code of the visitor. */ - continent_code?: string; - /** The country code of the visitor. */ - country_code?: string; - /** The country name of the visitor. */ - country_name?: string; - /** The postal code of the visitor. */ - postal_code?: string; - /** The region name of the visitor. */ - region_name?: string; - /** The timezone of the visitor. */ - timezone?: string; - } - - export interface SocialProfiles { - /** The type of the object */ - type?: "social_profile.list"; - social_profiles?: string[]; - } - - export interface Tags { - /** The type of the object */ - type?: "tag.list"; - tags?: Tags.Tags.Item[]; - } - - export namespace Tags { - export type Tags = Tags.Item[]; - - export namespace Tags { - export interface Item { - /** The type of the object */ - type?: "tag"; - /** The id of the tag. */ - id?: string; - /** The name of the tag. */ - name?: string; - } - } - } - - export interface Segments { - /** The type of the object */ - type?: "segment.list"; - segments?: string[]; - } -} diff --git a/src/api/resources/unstable/types/VisitorDeletedObject.ts b/src/api/resources/unstable/types/VisitorDeletedObject.ts deleted file mode 100644 index 6a3cc196..00000000 --- a/src/api/resources/unstable/types/VisitorDeletedObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface VisitorDeletedObject { - /** The unique identifier for the visitor which is given by Intercom. */ - id?: string; - /** The type of object which was deleted */ - type?: "visitor"; - /** Automatically generated identifier for the Visitor. */ - user_id?: string; -} diff --git a/src/api/resources/unstable/types/WhatsappMessageStatusList.ts b/src/api/resources/unstable/types/WhatsappMessageStatusList.ts deleted file mode 100644 index b1d0e8d8..00000000 --- a/src/api/resources/unstable/types/WhatsappMessageStatusList.ts +++ /dev/null @@ -1,67 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface WhatsappMessageStatusList { - type: "list"; - /** The provided ruleset ID */ - ruleset_id: string; - pages: WhatsappMessageStatusList.Pages; - /** Total number of events */ - total_count: number; - events: WhatsappMessageStatusList.Events.Item[]; -} - -export namespace WhatsappMessageStatusList { - export interface Pages { - type: "pages"; - /** Number of results per page */ - per_page: number; - /** Total number of pages */ - total_pages: number; - /** Information for fetching next page (null if no more pages) */ - next?: Pages.Next; - } - - export namespace Pages { - /** - * Information for fetching next page (null if no more pages) - */ - export interface Next { - /** Cursor for the next page */ - starting_after?: string; - } - } - - export type Events = Events.Item[]; - - export namespace Events { - export interface Item { - /** Event ID */ - id: string; - /** ID of the conversation */ - conversation_id: string; - /** Current status of the message */ - status: Item.Status; - /** Event type */ - type: "broadcast_outbound"; - /** Creation timestamp */ - created_at: number; - /** Last update timestamp */ - updated_at: number; - /** WhatsApp's message identifier */ - whatsapp_message_id: string; - /** Name of the WhatsApp template used */ - template_name?: string; - } - - export namespace Item { - /** Current status of the message */ - export const Status = { - Sent: "sent", - Delivered: "delivered", - Read: "read", - Failed: "failed", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; - } - } -} diff --git a/src/api/resources/unstable/types/WorkflowExport.ts b/src/api/resources/unstable/types/WorkflowExport.ts deleted file mode 100644 index 93531949..00000000 --- a/src/api/resources/unstable/types/WorkflowExport.ts +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A workflow export containing the complete workflow configuration. - */ -export interface WorkflowExport { - /** The version of the export format. */ - export_version?: string; - /** The timestamp when the export was generated. */ - exported_at?: string; - /** The workspace identifier. */ - app_id?: number; - /** The workflow configuration. */ - workflow?: WorkflowExport.Workflow; -} - -export namespace WorkflowExport { - /** - * The workflow configuration. - */ - export interface Workflow { - /** The unique identifier for the workflow. */ - id?: string; - /** The title of the workflow. */ - title?: string; - /** The description of the workflow. */ - description?: string; - /** The type of trigger that starts this workflow. */ - trigger_type?: string; - /** The current state of the workflow. */ - state?: Workflow.State; - /** The channels this workflow targets. */ - target_channels?: string[]; - /** The preferred devices for this workflow. */ - preferred_devices?: string[]; - /** When the workflow was created. */ - created_at?: string; - /** When the workflow was last updated. */ - updated_at?: string; - /** The targeting rules for this workflow. */ - targeting?: Record; - /** The current snapshot of workflow steps and configuration. */ - snapshot?: Record; - /** Custom attributes defined for this workflow. */ - attributes?: Record[]; - /** Rules embedded within the workflow steps. */ - embedded_rules?: Record[]; - } - - export namespace Workflow { - /** The current state of the workflow. */ - export const State = { - Live: "live", - Draft: "draft", - Paused: "paused", - } as const; - export type State = (typeof State)[keyof typeof State]; - } -} diff --git a/src/api/resources/unstable/types/index.ts b/src/api/resources/unstable/types/index.ts deleted file mode 100644 index 5b8c268e..00000000 --- a/src/api/resources/unstable/types/index.ts +++ /dev/null @@ -1,168 +0,0 @@ -export * from "./ActivityLog.js"; -export * from "./ActivityLogList.js"; -export * from "./ActivityLogMetadata.js"; -export * from "./AddressableList.js"; -export * from "./AdminList.js"; -export * from "./AdminPriorityLevel.js"; -export * from "./AdminReplyConversationRequest.js"; -export * from "./AdminReplyTicketRequest.js"; -export * from "./AdminWithApp.js"; -export * from "./AiCallResponse.js"; -export * from "./App.js"; -export * from "./ArticleContent.js"; -export * from "./ArticleList.js"; -export * from "./ArticleStatistics.js"; -export * from "./ArticleTranslatedContent.js"; -export * from "./AssignConversationRequest.js"; -export * from "./AwayStatusReason.js"; -export * from "./CallList.js"; -export * from "./CloseConversationRequest.js"; -export * from "./CollectionList.js"; -export * from "./CompanyAttachedContacts.js"; -export * from "./CompanyAttachedSegments.js"; -export * from "./CompanyData.js"; -export * from "./CompanyList.js"; -export * from "./CompanyScroll.js"; -export * from "./ContactArchived.js"; -export * from "./ContactAttachedCompanies.js"; -export * from "./ContactBlocked.js"; -export * from "./ContactCompanies.js"; -export * from "./ContactDeleted.js"; -export * from "./ContactList.js"; -export * from "./ContactLocation.js"; -export * from "./ContactNotes.js"; -export * from "./ContactReference.js"; -export * from "./ContactReplyBaseRequest.js"; -export * from "./ContactReplyConversationRequest.js"; -export * from "./ContactReplyEmailRequest.js"; -export * from "./ContactReplyIntercomUserIdRequest.js"; -export * from "./ContactReplyTicketEmailRequest.js"; -export * from "./ContactReplyTicketIntercomUserIdRequest.js"; -export * from "./ContactReplyTicketRequest.js"; -export * from "./ContactReplyTicketUserIdRequest.js"; -export * from "./ContactReplyUserIdRequest.js"; -export * from "./ContactSegments.js"; -export * from "./ContactSocialProfiles.js"; -export * from "./ContactSubscriptionTypes.js"; -export * from "./ContactTags.js"; -export * from "./ContactUnarchived.js"; -export * from "./ContentSourcesList.js"; -export * from "./ConversationAttachmentFiles.js"; -export * from "./ConversationAttributeUpdatedByAdmin.js"; -export * from "./ConversationAttributeUpdatedByUser.js"; -export * from "./ConversationAttributeUpdatedByWorkflow.js"; -export * from "./ConversationContacts.js"; -export * from "./ConversationDeleted.js"; -export * from "./ConversationFirstContactReply.js"; -export * from "./ConversationList.js"; -export * from "./ConversationPart.js"; -export * from "./ConversationPartAuthor.js"; -export * from "./ConversationPartMetadata.js"; -export * from "./ConversationParts.js"; -export * from "./ConversationRating.js"; -export * from "./ConversationResponseTime.js"; -export * from "./ConversationSlaAppliedByRule.js"; -export * from "./ConversationSlaAppliedByWorkflow.js"; -export * from "./ConversationSlaPaused.js"; -export * from "./ConversationSlaRemoved.js"; -export * from "./ConversationSlaTargetMissed.js"; -export * from "./ConversationSlaUnpaused.js"; -export * from "./ConversationSource.js"; -export * from "./ConversationStatistics.js"; -export * from "./ConversationTagsUpdated.js"; -export * from "./ConversationTeammates.js"; -export * from "./CreateArticleRequest.js"; -export * from "./CreateDataAttributeRequest.js"; -export * from "./CreateInternalArticleRequest.js"; -export * from "./CreateMessageRequest.js"; -export * from "./CreateOrUpdateCompanyRequest.js"; -export * from "./CreateOrUpdateTagRequest.js"; -export * from "./CreatePhoneSwitchRequest.js"; -export * from "./CreateTicketReplyWithCommentRequest.js"; -export * from "./CreateTicketRequestBody.js"; -export * from "./CreateTicketTypeRequest.js"; -export * from "./CursorPages.js"; -export * from "./CustomActionFinished.js"; -export * from "./CustomActionStarted.js"; -export * from "./CustomAttributes.js"; -export * from "./CustomChannelAttribute.js"; -export * from "./CustomChannelBaseEvent.js"; -export * from "./CustomChannelContact.js"; -export * from "./CustomChannelNotificationResponse.js"; -export * from "./CustomerRequest.js"; -export * from "./CustomObjectInstanceDeleted.js"; -export * from "./CustomObjectInstanceList.js"; -export * from "./DataAttributeList.js"; -export * from "./DataEventList.js"; -export * from "./DataEventSummary.js"; -export * from "./DataEventSummaryItem.js"; -export * from "./DataExportCsv.js"; -export * from "./Datetime.js"; -export * from "./DeletedArticleObject.js"; -export * from "./DeletedCollectionObject.js"; -export * from "./DeletedCompanyObject.js"; -export * from "./DeletedInternalArticleObject.js"; -export * from "./DeletedObject.js"; -export * from "./EmailAddressHeader.js"; -export * from "./EmailMessageMetadata.js"; -export * from "./Error_.js"; -export * from "./EventDetails.js"; -export * from "./FileAttribute.js"; -export * from "./GroupContent.js"; -export * from "./GroupTranslatedContent.js"; -export * from "./HandlingEvent.js"; -export * from "./HandlingEventList.js"; -export * from "./InternalArticleList.js"; -export * from "./LinkedObject.js"; -export * from "./LinkedObjectList.js"; -export * from "./MultipleFilterSearchRequest.js"; -export * from "./NewsItemRequest.js"; -export * from "./NoteList.js"; -export * from "./NotFoundErrorBody.js"; -export * from "./OpenConversationRequest.js"; -export * from "./OperatorWorkflowEvent.js"; -export * from "./PagesLink.js"; -export * from "./PaginatedResponse.js"; -export * from "./PaginatedResponseDataItem.js"; -export * from "./PartAttachment.js"; -export * from "./PhoneSwitch.js"; -export * from "./PriorityChanged.js"; -export * from "./QuickReplyOption.js"; -export * from "./Recipient.js"; -export * from "./RedactConversationRequest.js"; -export * from "./Reference.js"; -export * from "./RegisterFinVoiceCallRequest.js"; -export * from "./ReplyConversationRequestBody.js"; -export * from "./SearchRequest.js"; -export * from "./SegmentList.js"; -export * from "./SingleFilterSearchRequest.js"; -export * from "./SlaApplied.js"; -export * from "./SnoozeConversationRequest.js"; -export * from "./Snoozed.js"; -export * from "./SocialProfile.js"; -export * from "./StartingAfterPaging.js"; -export * from "./SubscriptionTypeList.js"; -export * from "./TagCompanyRequest.js"; -export * from "./TagList.js"; -export * from "./TagMultipleUsersRequest.js"; -export * from "./Tags.js"; -export * from "./TeamList.js"; -export * from "./TeammateReference.js"; -export * from "./TeamPriorityLevel.js"; -export * from "./TicketCustomAttributes.js"; -export * from "./TicketList.js"; -export * from "./TicketPartAuthor.js"; -export * from "./TicketParts.js"; -export * from "./TicketReply.js"; -export * from "./TicketRequestCustomAttributes.js"; -export * from "./TicketStateList.js"; -export * from "./TicketTypeAttribute.js"; -export * from "./TicketTypeAttributeList.js"; -export * from "./TicketTypeList.js"; -export * from "./Translation.js"; -export * from "./UntagCompanyRequest.js"; -export * from "./UpdateDataAttributeRequestBody.js"; -export * from "./Visitor.js"; -export * from "./VisitorDeletedObject.js"; -export * from "./WhatsappMessageStatusList.js"; -export * from "./WorkflowExport.js"; diff --git a/src/api/types/ActivityLog.ts b/src/api/types/ActivityLog.ts deleted file mode 100644 index eea2e6fd..00000000 --- a/src/api/types/ActivityLog.ts +++ /dev/null @@ -1,137 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Activities performed by Admins. - */ -export interface ActivityLog { - /** The id representing the activity. */ - id?: string; - /** Details about the Admin involved in the activity. */ - performed_by?: ActivityLog.PerformedBy; - metadata?: Intercom.ActivityLogMetadata; - /** The time the activity was created. */ - created_at?: number; - activity_type?: ActivityLog.ActivityType; - /** A sentence or two describing the activity. */ - activity_description?: string; -} - -export namespace ActivityLog { - /** - * Details about the Admin involved in the activity. - */ - export interface PerformedBy { - /** String representing the object's type. Always has the value `admin`. */ - type?: string; - /** The id representing the admin. */ - id?: string; - /** The email of the admin. */ - email?: string; - /** The IP address of the admin. */ - ip?: string; - } - - export const ActivityType = { - AdminConversationAssignmentLimitChange: "admin_conversation_assignment_limit_change", - AdminTicketAssignmentLimitChange: "admin_ticket_assignment_limit_change", - AdminAwayModeChange: "admin_away_mode_change", - AdminDeletion: "admin_deletion", - AdminDeprovisioned: "admin_deprovisioned", - AdminImpersonationEnd: "admin_impersonation_end", - AdminImpersonationStart: "admin_impersonation_start", - AdminImpersonationConsentApproved: "admin_impersonation_consent_approved", - AdminImpersonationConsentRevoked: "admin_impersonation_consent_revoked", - AdminInviteChange: "admin_invite_change", - AdminInviteCreation: "admin_invite_creation", - AdminInviteDeletion: "admin_invite_deletion", - AdminLoginFailure: "admin_login_failure", - AdminLoginSuccess: "admin_login_success", - AdminLogout: "admin_logout", - AdminPasswordResetRequest: "admin_password_reset_request", - AdminPasswordResetSuccess: "admin_password_reset_success", - AdminPermissionChange: "admin_permission_change", - AdminProvisioned: "admin_provisioned", - AdminTwoFactorAuthChange: "admin_two_factor_auth_change", - AdminUnauthorizedSignInMethod: "admin_unauthorized_sign_in_method", - AppAdminJoin: "app_admin_join", - AppAuthenticationMethodChange: "app_authentication_method_change", - AppDataDeletion: "app_data_deletion", - AppDataExport: "app_data_export", - AppGoogleSsoDomainChange: "app_google_sso_domain_change", - AppIdentityVerificationChange: "app_identity_verification_change", - AppNameChange: "app_name_change", - AppOutboundAddressChange: "app_outbound_address_change", - AppPackageInstallation: "app_package_installation", - AppPackageTokenRegeneration: "app_package_token_regeneration", - AppPackageUninstallation: "app_package_uninstallation", - AppTeamCreation: "app_team_creation", - AppTeamDeletion: "app_team_deletion", - AppTeamMembershipModification: "app_team_membership_modification", - AppTimezoneChange: "app_timezone_change", - AppWebhookCreation: "app_webhook_creation", - AppWebhookDeletion: "app_webhook_deletion", - ArticlesInMessengerEnabledChange: "articles_in_messenger_enabled_change", - AutomaticAwayModeSettingChange: "automatic_away_mode_setting_change", - BulkDelete: "bulk_delete", - BulkExport: "bulk_export", - CampaignDeletion: "campaign_deletion", - CampaignStateChange: "campaign_state_change", - ConversationPartDeletion: "conversation_part_deletion", - ConversationTopicChange: "conversation_topic_change", - ConversationTopicCreation: "conversation_topic_creation", - ConversationTopicDeletion: "conversation_topic_deletion", - CustomAuthenticationTokenCreation: "custom_authentication_token_creation", - HelpCenterSettingsChange: "help_center_settings_change", - InboundConversationsChange: "inbound_conversations_change", - InboxAccessChange: "inbox_access_change", - MacroCreation: "macro_creation", - MacroDeletion: "macro_deletion", - MacroUpdate: "macro_update", - MaliciousDomainsSettingChange: "malicious_domains_setting_change", - MessageDeletion: "message_deletion", - MessageStateChange: "message_state_change", - MessengerApiSecretCreation: "messenger_api_secret_creation", - MessengerApiSecretDeletion: "messenger_api_secret_deletion", - MessengerLookAndFeelChange: "messenger_look_and_feel_change", - MessengerSearchRequiredChange: "messenger_search_required_change", - MessengerSpacesChange: "messenger_spaces_change", - OauthTokenRevocation: "oauth_token_revocation", - OfficeHoursChange: "office_hours_change", - RoleChange: "role_change", - RoleCreation: "role_creation", - RoleDeletion: "role_deletion", - RulesetActivationTitlePreview: "ruleset_activation_title_preview", - RulesetCreation: "ruleset_creation", - RulesetDeletion: "ruleset_deletion", - SearchBrowseEnabledChange: "search_browse_enabled_change", - SearchBrowseRequiredChange: "search_browse_required_change", - SeatChange: "seat_change", - SeatRevoke: "seat_revoke", - SecuritySettingsChange: "security_settings_change", - SeriesCreation: "series_creation", - SeriesDeletion: "series_deletion", - SeriesSettingsUpdate: "series_settings_update", - SeriesStatusChange: "series_status_change", - SeriesUpdate: "series_update", - StripInboundEmailLinksChange: "strip_inbound_email_links_change", - TemporaryExpectationChange: "temporary_expectation_change", - TeamAssignmentLimitChange: "team_assignment_limit_change", - TrustedDomainsSettingChange: "trusted_domains_setting_change", - UnassignUnsnoozedAtCapacitySettingChange: "unassign_unsnoozed_at_capacity_setting_change", - UpfrontEmailCollectionChange: "upfront_email_collection_change", - AllowedAttachmentFiletypesSettingChange: "allowed_attachment_filetypes_setting_change", - AttachUploadsInlineSettingChange: "attach_uploads_inline_setting_change", - TeammateGifsSettingChange: "teammate_gifs_setting_change", - UserCameraAttachmentsSettingChange: "user_camera_attachments_setting_change", - UserConversationAttachmentsSettingChange: "user_conversation_attachments_setting_change", - UserFileAttachmentsSettingChange: "user_file_attachments_setting_change", - UserGifsSettingChange: "user_gifs_setting_change", - UserMediaAttachmentsSettingChange: "user_media_attachments_setting_change", - UserVoiceNotesSettingChange: "user_voice_notes_setting_change", - WelcomeMessageChange: "welcome_message_change", - WorkspaceDeletionRequest: "workspace_deletion_request", - } as const; - export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType]; -} diff --git a/src/api/types/ActivityLogList.ts b/src/api/types/ActivityLogList.ts deleted file mode 100644 index 6a1253cc..00000000 --- a/src/api/types/ActivityLogList.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A paginated list of activity logs. - */ -export interface ActivityLogList { - /** String representing the object's type. Always has the value `activity_log.list`. */ - type?: string; - pages?: Intercom.CursorPages; - /** An array of activity logs */ - activity_logs?: (Intercom.ActivityLog | undefined)[]; -} diff --git a/src/api/types/ActivityLogMetadata.ts b/src/api/types/ActivityLogMetadata.ts deleted file mode 100644 index ed4bfcf2..00000000 --- a/src/api/types/ActivityLogMetadata.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Additional data provided about Admin activity. - */ -export interface ActivityLogMetadata { - /** The way the admin signed in. */ - sign_in_method?: string; - /** The unique identifier for the contact which is provided by the Client. */ - external_id?: string; - /** The away mode status which is set to true when away and false when returned. */ - away_mode?: boolean; - /** The reason the Admin is away. */ - away_status_reason?: string; - /** Indicates if conversations should be reassigned while an Admin is away. */ - reassign_conversations?: boolean; - /** The action that initiated the status change. */ - source?: string; - /** Indicates if the status was changed automatically or manually. */ - auto_changed?: string; - /** The ID of the Admin who initiated the activity. */ - update_by?: number; - /** The name of the Admin who initiated the activity. */ - update_by_name?: string; - /** The conversation assignment limit value for an admin. */ - conversation_assignment_limit?: number; - /** The ticket assignment limit value for an admin. */ - ticket_assignment_limit?: number; - /** Details about the team whose assignment limit was changed. */ - team?: ActivityLogMetadata.Team; - /** The team assignment limit value (null if limit was removed). */ - team_assignment_limit?: number; - /** Indicates if the setting is enabled or disabled. */ - enabled?: boolean; - /** The ID of the impersonation consent. */ - consent_id?: number; - /** The timestamp when the impersonation consent expires. */ - expired_at?: string; - /** The state of settings or values before the change. Structure varies by activity type. */ - before?: Record; - /** The state of settings or values after the change. Structure varies by activity type. */ - after?: Record; -} - -export namespace ActivityLogMetadata { - /** - * Details about the team whose assignment limit was changed. - */ - export interface Team { - /** The ID of the team. */ - id?: number; - /** The name of the team. */ - name?: string; - } -} diff --git a/src/api/types/AddressableList.ts b/src/api/types/AddressableList.ts deleted file mode 100644 index cbda5a63..00000000 --- a/src/api/types/AddressableList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A list used to access other resources from a parent model. - */ -export interface AddressableList { - /** The addressable object type */ - type?: string; - /** The id of the addressable object */ - id?: string; - /** Url to get more company resources for this contact */ - url?: string; -} diff --git a/src/api/types/AdminList.ts b/src/api/types/AdminList.ts deleted file mode 100644 index c504537d..00000000 --- a/src/api/types/AdminList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of admins associated with a given workspace. - */ -export interface AdminList { - /** String representing the object's type. Always has the value `admin.list`. */ - type?: string; - /** A list of admins associated with a given workspace. */ - admins?: (Intercom.Admin | undefined)[]; -} diff --git a/src/api/types/AdminPriorityLevel.ts b/src/api/types/AdminPriorityLevel.ts deleted file mode 100644 index 1127dadf..00000000 --- a/src/api/types/AdminPriorityLevel.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Admin priority levels for the team - */ -export interface AdminPriorityLevel { - /** The primary admin ids for the team */ - primary_admin_ids?: number[]; - /** The secondary admin ids for the team */ - secondary_admin_ids?: number[]; -} diff --git a/src/api/types/AdminReplyConversationRequest.ts b/src/api/types/AdminReplyConversationRequest.ts deleted file mode 100644 index 36982c2d..00000000 --- a/src/api/types/AdminReplyConversationRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of an admin - */ -export interface AdminReplyConversationRequest { - message_type: AdminReplyConversationRequest.MessageType; - type: "admin"; - /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ - body?: string; - /** The id of the admin who is authoring the comment. */ - admin_id: string; - /** The time the reply was created. If not provided, the current time will be used. */ - created_at?: number; - /** The quick reply options to display to the end user. Must be present for quick_reply message types. */ - reply_options?: Intercom.QuickReplyOption[]; - /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ - attachment_urls?: string[]; - /** A list of files that will be added as attachments. You can include up to 10 files */ - attachment_files?: Intercom.ConversationAttachmentFiles[]; -} - -export namespace AdminReplyConversationRequest { - export const MessageType = { - Comment: "comment", - Note: "note", - QuickReply: "quick_reply", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; -} diff --git a/src/api/types/AdminReplyTicketRequest.ts b/src/api/types/AdminReplyTicketRequest.ts deleted file mode 100644 index 3e2ac1ed..00000000 --- a/src/api/types/AdminReplyTicketRequest.ts +++ /dev/null @@ -1,38 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to reply on behalf of an admin - */ -export interface AdminReplyTicketRequest { - message_type: AdminReplyTicketRequest.MessageType; - type: "admin"; - /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ - body?: string; - /** The id of the admin who is authoring the comment. */ - admin_id: string; - /** The time the reply was created. If not provided, the current time will be used. */ - created_at?: number; - /** The quick reply options to display. Must be present for quick_reply message types. */ - reply_options?: AdminReplyTicketRequest.ReplyOptions.Item[]; - /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ - attachment_urls?: string[]; -} - -export namespace AdminReplyTicketRequest { - export const MessageType = { - Comment: "comment", - Note: "note", - QuickReply: "quick_reply", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; - export type ReplyOptions = ReplyOptions.Item[]; - - export namespace ReplyOptions { - export interface Item { - /** The text to display in this quick reply option. */ - text: string; - /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment ticket part that is created when a user clicks on this reply option. */ - uuid: string; - } - } -} diff --git a/src/api/types/AdminWithApp.ts b/src/api/types/AdminWithApp.ts deleted file mode 100644 index 8675a421..00000000 --- a/src/api/types/AdminWithApp.ts +++ /dev/null @@ -1,45 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Admins are the teammate accounts that have access to a workspace - */ -export interface AdminWithApp { - /** String representing the object's type. Always has the value `admin`. */ - type?: string; - /** The id representing the admin. */ - id?: string; - /** The name of the admin. */ - name?: string; - /** The email of the admin. */ - email?: string; - /** The job title of the admin. */ - job_title?: string; - /** Identifies if this admin is currently set in away mode. */ - away_mode_enabled?: boolean; - /** Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ - away_mode_reassign?: boolean; - /** Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ - has_inbox_seat?: boolean; - /** This is a list of ids of the teams that this admin is part of. */ - team_ids?: number[]; - /** This object represents the avatar associated with the admin. */ - avatar?: AdminWithApp.Avatar; - /** Identifies if this admin's email is verified. */ - email_verified?: boolean; - /** App that the admin belongs to. */ - app?: Intercom.App; -} - -export namespace AdminWithApp { - /** - * This object represents the avatar associated with the admin. - */ - export interface Avatar { - /** This is a string that identifies the type of the object. It will always have the value `avatar`. */ - type?: string; - /** This object represents the avatar associated with the admin. */ - image_url?: string; - } -} diff --git a/src/api/types/App.ts b/src/api/types/App.ts deleted file mode 100644 index 67ce2d3c..00000000 --- a/src/api/types/App.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * App is a workspace on Intercom - */ -export interface App { - /** */ - type?: string; - /** The id of the app. */ - id_code?: string; - /** The name of the app. */ - name?: string; - /** The Intercom region the app is located in. */ - region?: string; - /** The timezone of the region where the app is located. */ - timezone?: string; - /** When the app was created. */ - created_at?: number; - /** Whether or not the app uses identity verification. */ - identity_verification?: boolean; -} diff --git a/src/api/types/ArticleContent.ts b/src/api/types/ArticleContent.ts deleted file mode 100644 index bccb5af5..00000000 --- a/src/api/types/ArticleContent.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The Content of an Article. - */ -export interface ArticleContent { - /** The type of object - `article_content` . */ - type?: "article_content"; - /** The title of the article. */ - title?: string; - /** The description of the article. */ - description?: string; - /** The body of the article. */ - body?: string; - /** The ID of the author of the article. */ - author_id?: number; - /** Whether the article is `published` or is a `draft` . */ - state?: ArticleContent.State; - /** The time when the article was created (seconds). */ - created_at?: number; - /** The time when the article was last updated (seconds). */ - updated_at?: number; - /** The URL of the article. */ - url?: string; -} - -export namespace ArticleContent { - /** Whether the article is `published` or is a `draft` . */ - export const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/types/ArticleList.ts b/src/api/types/ArticleList.ts deleted file mode 100644 index 02eb730b..00000000 --- a/src/api/types/ArticleList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of articles for the App. - */ -export interface ArticleList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: unknown; - /** A count of the total number of articles. */ - total_count?: number; - /** An array of Article objects */ - data?: Intercom.ArticleListItem[]; -} diff --git a/src/api/types/ArticleStatistics.ts b/src/api/types/ArticleStatistics.ts deleted file mode 100644 index 36ea843e..00000000 --- a/src/api/types/ArticleStatistics.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The statistics of an article. - */ -export interface ArticleStatistics { - /** The type of object - `article_statistics`. */ - type: "article_statistics"; - /** The number of total views the article has received. */ - views: number; - /** The number of conversations started from the article. */ - conversions?: number; - /** The number of total reactions the article has received. */ - reactions: number; - /** The percentage of happy reactions the article has received against other types of reaction. */ - happy_reaction_percentage: number; - /** The percentage of neutral reactions the article has received against other types of reaction. */ - neutral_reaction_percentage: number; - /** The percentage of sad reactions the article has received against other types of reaction. */ - sad_reaction_percentage: number; -} diff --git a/src/api/types/ArticleTranslatedContent.ts b/src/api/types/ArticleTranslatedContent.ts deleted file mode 100644 index 351d8148..00000000 --- a/src/api/types/ArticleTranslatedContent.ts +++ /dev/null @@ -1,85 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * The Translated Content of an Article. The keys are the locale codes and the values are the translated content of the article. - */ -export interface ArticleTranslatedContent { - /** The type of object - article_translated_content. */ - type?: "article_translated_content"; - /** The content of the article in Arabic */ - ar?: Intercom.ArticleContent; - /** The content of the article in Bulgarian */ - bg?: Intercom.ArticleContent; - /** The content of the article in Bosnian */ - bs?: Intercom.ArticleContent; - /** The content of the article in Catalan */ - ca?: Intercom.ArticleContent; - /** The content of the article in Czech */ - cs?: Intercom.ArticleContent; - /** The content of the article in Danish */ - da?: Intercom.ArticleContent; - /** The content of the article in German */ - de?: Intercom.ArticleContent; - /** The content of the article in Greek */ - el?: Intercom.ArticleContent; - /** The content of the article in English */ - en?: Intercom.ArticleContent; - /** The content of the article in Spanish */ - es?: Intercom.ArticleContent; - /** The content of the article in Estonian */ - et?: Intercom.ArticleContent; - /** The content of the article in Finnish */ - fi?: Intercom.ArticleContent; - /** The content of the article in French */ - fr?: Intercom.ArticleContent; - /** The content of the article in Hebrew */ - he?: Intercom.ArticleContent; - /** The content of the article in Croatian */ - hr?: Intercom.ArticleContent; - /** The content of the article in Hungarian */ - hu?: Intercom.ArticleContent; - /** The content of the article in Indonesian */ - id?: Intercom.ArticleContent; - /** The content of the article in Italian */ - it?: Intercom.ArticleContent; - /** The content of the article in Japanese */ - ja?: Intercom.ArticleContent; - /** The content of the article in Korean */ - ko?: Intercom.ArticleContent; - /** The content of the article in Lithuanian */ - lt?: Intercom.ArticleContent; - /** The content of the article in Latvian */ - lv?: Intercom.ArticleContent; - /** The content of the article in Mongolian */ - mn?: Intercom.ArticleContent; - /** The content of the article in Norwegian */ - nb?: Intercom.ArticleContent; - /** The content of the article in Dutch */ - nl?: Intercom.ArticleContent; - /** The content of the article in Polish */ - pl?: Intercom.ArticleContent; - /** The content of the article in Portuguese (Portugal) */ - pt?: Intercom.ArticleContent; - /** The content of the article in Romanian */ - ro?: Intercom.ArticleContent; - /** The content of the article in Russian */ - ru?: Intercom.ArticleContent; - /** The content of the article in Slovenian */ - sl?: Intercom.ArticleContent; - /** The content of the article in Serbian */ - sr?: Intercom.ArticleContent; - /** The content of the article in Swedish */ - sv?: Intercom.ArticleContent; - /** The content of the article in Turkish */ - tr?: Intercom.ArticleContent; - /** The content of the article in Vietnamese */ - vi?: Intercom.ArticleContent; - /** The content of the article in Portuguese (Brazil) */ - "pt-BR"?: Intercom.ArticleContent; - /** The content of the article in Chinese (China) */ - "zh-CN"?: Intercom.ArticleContent; - /** The content of the article in Chinese (Taiwan) */ - "zh-TW"?: Intercom.ArticleContent; -} diff --git a/src/api/types/AssignConversationRequest.ts b/src/api/types/AssignConversationRequest.ts deleted file mode 100644 index 0e2e8ba8..00000000 --- a/src/api/types/AssignConversationRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to assign a conversation - */ -export interface AssignConversationRequest { - type: AssignConversationRequest.Type; - /** The id of the admin who is performing the action. */ - admin_id: string; - /** The `id` of the `admin` or `team` which will be assigned the conversation. A conversation can be assigned both an admin and a team.\nSet `0` if you want this assign to no admin or team (ie. Unassigned). */ - assignee_id: string; - /** Optionally you can send a response in the conversation when it is assigned. */ - body?: string; -} - -export namespace AssignConversationRequest { - export const Type = { - Admin: "admin", - Team: "team", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/AwayStatusReason.ts b/src/api/types/AwayStatusReason.ts deleted file mode 100644 index 01eaf720..00000000 --- a/src/api/types/AwayStatusReason.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface AwayStatusReason { - type?: string; - /** The unique identifier for the away status reason */ - id?: string; - /** The display text for the away status reason */ - label?: string; - /** The emoji associated with the status reason */ - emoji?: string; - /** The display order of the status reason */ - order?: number; - /** Whether the status reason has been soft deleted */ - deleted?: boolean; - /** The Unix timestamp when the status reason was created */ - created_at?: number; - /** The Unix timestamp when the status reason was last updated */ - updated_at?: number; -} diff --git a/src/api/types/CallList.ts b/src/api/types/CallList.ts deleted file mode 100644 index ab4b49a4..00000000 --- a/src/api/types/CallList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A paginated list of calls. - */ -export interface CallList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of calls. */ - data?: Intercom.Call[]; - /** Total number of items available. */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/CloseConversationRequest.ts b/src/api/types/CloseConversationRequest.ts deleted file mode 100644 index 0c75f0c3..00000000 --- a/src/api/types/CloseConversationRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to close a conversation - */ -export interface CloseConversationRequest { - type: "admin"; - /** The id of the admin who is performing the action. */ - admin_id: string; - /** Optionally you can leave a message in the conversation to provide additional context to the user and other teammates. */ - body?: string; -} diff --git a/src/api/types/CollectionList.ts b/src/api/types/CollectionList.ts deleted file mode 100644 index d2c02975..00000000 --- a/src/api/types/CollectionList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of Collections for the App. - */ -export interface CollectionList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.OffsetPages; - /** A count of the total number of collections. */ - total_count?: number; - /** An array of collection objects */ - data?: Intercom.Collection[]; -} diff --git a/src/api/types/CompanyAttachedContacts.ts b/src/api/types/CompanyAttachedContacts.ts deleted file mode 100644 index 8725ffd9..00000000 --- a/src/api/types/CompanyAttachedContacts.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of Contact Objects - */ -export interface CompanyAttachedContacts { - /** The type of object - `list` */ - type?: "list"; - /** An array containing Contact Objects */ - data?: Intercom.Contact[]; - /** The total number of contacts */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/CompanyAttachedSegments.ts b/src/api/types/CompanyAttachedSegments.ts deleted file mode 100644 index aa6941ca..00000000 --- a/src/api/types/CompanyAttachedSegments.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of Segment Objects - */ -export interface CompanyAttachedSegments { - /** The type of object - `list` */ - type?: "list"; - /** An array containing Segment Objects */ - data?: Intercom.Segment[]; -} diff --git a/src/api/types/CompanyData.ts b/src/api/types/CompanyData.ts deleted file mode 100644 index 29d3a559..00000000 --- a/src/api/types/CompanyData.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An object containing data about the companies that a contact is associated with. - */ -export interface CompanyData { - /** The unique identifier for the company which is given by Intercom. */ - id?: string; - /** The type of the object. Always company. */ - type?: "company"; - /** The relative URL of the company. */ - url?: string; -} diff --git a/src/api/types/CompanyList.ts b/src/api/types/CompanyList.ts deleted file mode 100644 index 34851ae1..00000000 --- a/src/api/types/CompanyList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of companies for the App. - */ -export interface CompanyList { - /** The type of object - `list`. */ - type?: "list"; - pages?: Intercom.OffsetPages; - /** The total number of companies. */ - total_count?: number; - /** An array containing Company Objects. */ - data?: Intercom.Company[]; -} diff --git a/src/api/types/CompanyScroll.ts b/src/api/types/CompanyScroll.ts deleted file mode 100644 index 1ba47ea4..00000000 --- a/src/api/types/CompanyScroll.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies. - */ -export interface CompanyScroll { - /** The type of object - `list` */ - type?: "list"; - data?: Intercom.Company[]; - pages?: Intercom.CursorPages; - /** The total number of companies */ - total_count?: number; - /** The scroll parameter to use in the next request to fetch the next page of results. */ - scroll_param?: string; -} diff --git a/src/api/types/ContactArchived.ts b/src/api/types/ContactArchived.ts deleted file mode 100644 index 53e83824..00000000 --- a/src/api/types/ContactArchived.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * archived contact object - */ -export interface ContactArchived extends Intercom.ContactReference { - /** Whether the contact is archived or not. */ - archived?: boolean; -} diff --git a/src/api/types/ContactAttachedCompanies.ts b/src/api/types/ContactAttachedCompanies.ts deleted file mode 100644 index 6606054e..00000000 --- a/src/api/types/ContactAttachedCompanies.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of Company Objects - */ -export interface ContactAttachedCompanies { - /** The type of object */ - type?: "list"; - /** An array containing Company Objects */ - companies?: Intercom.Company[]; - /** The total number of companies associated to this contact */ - total_count?: number; - pages?: Intercom.PagesLink; -} diff --git a/src/api/types/ContactBlocked.ts b/src/api/types/ContactBlocked.ts deleted file mode 100644 index 9c85baa7..00000000 --- a/src/api/types/ContactBlocked.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * blocked contact object - */ -export interface ContactBlocked extends Intercom.ContactReference { - /** Always true. */ - blocked?: boolean; -} diff --git a/src/api/types/ContactCompanies.ts b/src/api/types/ContactCompanies.ts deleted file mode 100644 index 8a3a13b0..00000000 --- a/src/api/types/ContactCompanies.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * An object with metadata about companies attached to a contact . Up to 10 will be displayed here. Use the url to get more. - */ -export interface ContactCompanies { - /** An array of company data objects attached to the contact. */ - data?: Intercom.CompanyData[]; - /** Url to get more company resources for this contact */ - url?: string; - /** Integer representing the total number of companies attached to this contact */ - total_count?: number; - /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ - has_more?: boolean; -} diff --git a/src/api/types/ContactDeleted.ts b/src/api/types/ContactDeleted.ts deleted file mode 100644 index 6b047f65..00000000 --- a/src/api/types/ContactDeleted.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * deleted contact object - */ -export interface ContactDeleted extends Intercom.ContactReference { - /** Whether the contact is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/types/ContactList.ts b/src/api/types/ContactList.ts deleted file mode 100644 index 2fc8ab69..00000000 --- a/src/api/types/ContactList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Contacts are your users in Intercom. - */ -export interface ContactList { - /** Always list */ - type?: "list"; - /** The list of contact objects */ - data?: Intercom.Contact[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/ContactLocation.ts b/src/api/types/ContactLocation.ts deleted file mode 100644 index 73f32530..00000000 --- a/src/api/types/ContactLocation.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An object containing location meta data about a Intercom contact. - */ -export interface ContactLocation { - /** Always location */ - type?: string; - /** The country that the contact is located in */ - country?: string; - /** The overal region that the contact is located in */ - region?: string; - /** The city that the contact is located in */ - city?: string; -} diff --git a/src/api/types/ContactNotes.ts b/src/api/types/ContactNotes.ts deleted file mode 100644 index 77a34b6f..00000000 --- a/src/api/types/ContactNotes.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * An object containing notes meta data about the notes that a contact has. Up to 10 will be displayed here. Use the url to get more. - */ -export interface ContactNotes { - /** This object represents the notes attached to a contact. */ - data?: Intercom.AddressableList[]; - /** Url to get more company resources for this contact */ - url?: string; - /** Int representing the total number of companyies attached to this contact */ - total_count?: number; - /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ - has_more?: boolean; -} diff --git a/src/api/types/ContactReference.ts b/src/api/types/ContactReference.ts deleted file mode 100644 index 6ff6080e..00000000 --- a/src/api/types/ContactReference.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * reference to contact object - */ -export interface ContactReference { - /** always contact */ - type?: "contact"; - /** The unique identifier for the contact which is given by Intercom. */ - id?: string; - /** The unique identifier for the contact which is provided by the Client. */ - external_id?: string; -} diff --git a/src/api/types/ContactReplyBaseRequest.ts b/src/api/types/ContactReplyBaseRequest.ts deleted file mode 100644 index e6ebd102..00000000 --- a/src/api/types/ContactReplyBaseRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface ContactReplyBaseRequest { - message_type: "comment"; - type: "user"; - /** The text body of the comment. */ - body: string; - /** The time the reply was created. If not provided, the current time will be used. */ - created_at?: number; - /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ - attachment_urls?: string[]; - /** The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. */ - reply_options?: ContactReplyBaseRequest.ReplyOptions.Item[]; -} - -export namespace ContactReplyBaseRequest { - export type ReplyOptions = ReplyOptions.Item[]; - - export namespace ReplyOptions { - export interface Item { - /** The text of the chosen reply option. */ - text: string; - /** The unique identifier for the quick reply option selected. */ - uuid: string; - } - } -} diff --git a/src/api/types/ContactReplyConversationRequest.ts b/src/api/types/ContactReplyConversationRequest.ts deleted file mode 100644 index c0f18e11..00000000 --- a/src/api/types/ContactReplyConversationRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type ContactReplyConversationRequest = - | Intercom.ContactReplyIntercomUserIdRequest - | Intercom.ContactReplyEmailRequest - | Intercom.ContactReplyUserIdRequest; diff --git a/src/api/types/ContactReplyEmailRequest.ts b/src/api/types/ContactReplyEmailRequest.ts deleted file mode 100644 index 3af33d96..00000000 --- a/src/api/types/ContactReplyEmailRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `email` - */ -export interface ContactReplyEmailRequest extends Intercom.ContactReplyBaseRequest { - /** The email you have defined for the user. */ - email: string; - /** A list of files that will be added as attachments. */ - attachment_files?: Intercom.ConversationAttachmentFiles[]; -} diff --git a/src/api/types/ContactReplyIntercomUserIdRequest.ts b/src/api/types/ContactReplyIntercomUserIdRequest.ts deleted file mode 100644 index 4a3b3f1b..00000000 --- a/src/api/types/ContactReplyIntercomUserIdRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `intercom_user_id` - */ -export interface ContactReplyIntercomUserIdRequest extends Intercom.ContactReplyBaseRequest { - /** The identifier for the contact as given by Intercom. */ - intercom_user_id: string; - /** A list of files that will be added as attachments. */ - attachment_files?: Intercom.ConversationAttachmentFiles[]; -} diff --git a/src/api/types/ContactReplyTicketEmailRequest.ts b/src/api/types/ContactReplyTicketEmailRequest.ts deleted file mode 100644 index 8baf8758..00000000 --- a/src/api/types/ContactReplyTicketEmailRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `email` - */ -export interface ContactReplyTicketEmailRequest extends Intercom.ContactReplyBaseRequest { - /** The email you have defined for the user. */ - email: string; -} diff --git a/src/api/types/ContactReplyTicketIntercomUserIdRequest.ts b/src/api/types/ContactReplyTicketIntercomUserIdRequest.ts deleted file mode 100644 index 712a6dfc..00000000 --- a/src/api/types/ContactReplyTicketIntercomUserIdRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `intercom_user_id` - */ -export interface ContactReplyTicketIntercomUserIdRequest extends Intercom.ContactReplyBaseRequest { - /** The identifier for the contact as given by Intercom. */ - intercom_user_id: string; -} diff --git a/src/api/types/ContactReplyTicketRequest.ts b/src/api/types/ContactReplyTicketRequest.ts deleted file mode 100644 index a8deae5d..00000000 --- a/src/api/types/ContactReplyTicketRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type ContactReplyTicketRequest = - | Intercom.ContactReplyTicketIntercomUserIdRequest - | Intercom.ContactReplyTicketUserIdRequest - | Intercom.ContactReplyTicketEmailRequest; diff --git a/src/api/types/ContactReplyTicketUserIdRequest.ts b/src/api/types/ContactReplyTicketUserIdRequest.ts deleted file mode 100644 index d754bd17..00000000 --- a/src/api/types/ContactReplyTicketUserIdRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `user_id` - */ -export interface ContactReplyTicketUserIdRequest extends Intercom.ContactReplyBaseRequest { - /** The external_id you have defined for the contact. */ - user_id: string; -} diff --git a/src/api/types/ContactReplyUserIdRequest.ts b/src/api/types/ContactReplyUserIdRequest.ts deleted file mode 100644 index c043f3cc..00000000 --- a/src/api/types/ContactReplyUserIdRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `user_id` - */ -export interface ContactReplyUserIdRequest extends Intercom.ContactReplyBaseRequest { - /** The external_id you have defined for the contact. */ - user_id: string; - /** A list of files that will be added as attachments. You can include up to 10 files. */ - attachment_files?: Intercom.ConversationAttachmentFiles[]; -} diff --git a/src/api/types/ContactSegments.ts b/src/api/types/ContactSegments.ts deleted file mode 100644 index 5099c19d..00000000 --- a/src/api/types/ContactSegments.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of segments objects attached to a specific contact. - */ -export interface ContactSegments { - /** The type of the object */ - type?: "list"; - /** Segment objects associated with the contact. */ - data?: Intercom.Segment[]; -} diff --git a/src/api/types/ContactSocialProfiles.ts b/src/api/types/ContactSocialProfiles.ts deleted file mode 100644 index c61e7c62..00000000 --- a/src/api/types/ContactSocialProfiles.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * An object containing social profiles that a contact has. - */ -export interface ContactSocialProfiles { - /** A list of social profiles objects associated with the contact. */ - data?: Intercom.SocialProfile[]; -} diff --git a/src/api/types/ContactSubscriptionTypes.ts b/src/api/types/ContactSubscriptionTypes.ts deleted file mode 100644 index 358f4604..00000000 --- a/src/api/types/ContactSubscriptionTypes.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * An object containing Subscription Types meta data about the SubscriptionTypes that a contact has. - */ -export interface ContactSubscriptionTypes { - /** This object represents the subscriptions attached to a contact. */ - data?: Intercom.AddressableList[]; - /** Url to get more subscription type resources for this contact */ - url?: string; - /** Int representing the total number of subscription types attached to this contact */ - total_count?: number; - /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ - has_more?: boolean; -} diff --git a/src/api/types/ContactTags.ts b/src/api/types/ContactTags.ts deleted file mode 100644 index 90b8cc0f..00000000 --- a/src/api/types/ContactTags.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * An object containing tags meta data about the tags that a contact has. Up to 10 will be displayed here. Use the url to get more. - */ -export interface ContactTags { - /** This object represents the tags attached to a contact. */ - data?: Intercom.AddressableList[]; - /** url to get more tag resources for this contact */ - url?: string; - /** Int representing the total number of tags attached to this contact */ - total_count?: number; - /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ - has_more?: boolean; -} diff --git a/src/api/types/ContactUnarchived.ts b/src/api/types/ContactUnarchived.ts deleted file mode 100644 index 5c84ff30..00000000 --- a/src/api/types/ContactUnarchived.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * unarchived contact object - */ -export interface ContactUnarchived extends Intercom.ContactReference { - /** Whether the contact is archived or not. */ - archived?: boolean; -} diff --git a/src/api/types/ContentSourcesList.ts b/src/api/types/ContentSourcesList.ts deleted file mode 100644 index 4af840d0..00000000 --- a/src/api/types/ContentSourcesList.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export interface ContentSourcesList { - type?: "content_source.list"; - /** The total number of content sources used by AI Agent in the conversation. */ - total_count?: number; - /** The content sources used by AI Agent in the conversation. */ - content_sources?: Intercom.ContentSource[]; -} diff --git a/src/api/types/ConversationAttachmentFiles.ts b/src/api/types/ConversationAttachmentFiles.ts deleted file mode 100644 index f1a0b3e5..00000000 --- a/src/api/types/ConversationAttachmentFiles.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Properties of the attachment files in a conversation part - */ -export interface ConversationAttachmentFiles { - /** The content type of the file */ - content_type?: string; - /** The base64 encoded file data. */ - data?: string; - /** The name of the file. */ - name?: string; -} diff --git a/src/api/types/ConversationAttributeUpdatedByAdmin.ts b/src/api/types/ConversationAttributeUpdatedByAdmin.ts deleted file mode 100644 index b44c2202..00000000 --- a/src/api/types/ConversationAttributeUpdatedByAdmin.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about Custom Data Attributes (CDAs) that were modified by an admin (operator) for conversation part type conversation_attribute_updated_by_admin. - */ -export interface ConversationAttributeUpdatedByAdmin { - attribute?: ConversationAttributeUpdatedByAdmin.Attribute; - value?: ConversationAttributeUpdatedByAdmin.Value; -} - -export namespace ConversationAttributeUpdatedByAdmin { - export interface Attribute { - /** Name of the CDA updated */ - name?: string; - } - - export interface Value { - /** Value of the CDA updated */ - name?: string; - } -} diff --git a/src/api/types/ConversationAttributeUpdatedByWorkflow.ts b/src/api/types/ConversationAttributeUpdatedByWorkflow.ts deleted file mode 100644 index e9e75f32..00000000 --- a/src/api/types/ConversationAttributeUpdatedByWorkflow.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about the workflow that was triggered and any Custom Data Attributes (CDAs) that were modified during the workflow execution for conversation part type conversation_attribute_updated_by_workflow. - */ -export interface ConversationAttributeUpdatedByWorkflow { - workflow?: ConversationAttributeUpdatedByWorkflow.Workflow; - attribute?: ConversationAttributeUpdatedByWorkflow.Attribute; - value?: ConversationAttributeUpdatedByWorkflow.Value; -} - -export namespace ConversationAttributeUpdatedByWorkflow { - export interface Workflow { - /** Name of the workflow */ - name?: string; - } - - export interface Attribute { - /** Name of the CDA updated */ - name?: string; - } - - export interface Value { - /** Value of the CDA updated */ - name?: string; - } -} diff --git a/src/api/types/ConversationContacts.ts b/src/api/types/ConversationContacts.ts deleted file mode 100644 index 860cd318..00000000 --- a/src/api/types/ConversationContacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. - */ -export interface ConversationContacts { - /** */ - type?: "contact.list"; - /** The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. */ - contacts?: Intercom.ContactReference[]; -} diff --git a/src/api/types/ConversationDeleted.ts b/src/api/types/ConversationDeleted.ts deleted file mode 100644 index e61823b9..00000000 --- a/src/api/types/ConversationDeleted.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * deleted conversation object - */ -export interface ConversationDeleted { - /** The unique identifier for the conversation. */ - id?: string; - /** always conversation */ - object?: "conversation"; - /** Whether the conversation is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/types/ConversationFirstContactReply.ts b/src/api/types/ConversationFirstContactReply.ts deleted file mode 100644 index 2085bd1e..00000000 --- a/src/api/types/ConversationFirstContactReply.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An object containing information on the first users message. For a contact initiated message this will represent the users original message. - */ -export interface ConversationFirstContactReply { - /** */ - created_at?: number; - /** */ - type?: string; - /** */ - url?: string; -} diff --git a/src/api/types/ConversationList.ts b/src/api/types/ConversationList.ts deleted file mode 100644 index 4d0c74f3..00000000 --- a/src/api/types/ConversationList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. - */ -export interface ConversationList { - /** Always conversation.list */ - type?: "conversation.list"; - /** The list of conversation objects */ - conversations?: Intercom.Conversation[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/ConversationPart.ts b/src/api/types/ConversationPart.ts deleted file mode 100644 index 2182ec66..00000000 --- a/src/api/types/ConversationPart.ts +++ /dev/null @@ -1,51 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A Conversation Part represents a message in the conversation. - */ -export interface ConversationPart { - /** Always conversation_part */ - type?: string; - /** The id representing the conversation part. */ - id?: string; - /** The type of conversation part. */ - part_type?: string; - /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ - body?: string; - /** The time the conversation part was created. */ - created_at?: number; - /** The last time the conversation part was updated. */ - updated_at?: number; - /** The time the user was notified with the conversation part. */ - notified_at?: number; - /** The id of the admin that was assigned the conversation by this conversation_part (null if there has been no change in assignment.) */ - assigned_to?: Intercom.Reference; - author?: Intercom.ConversationPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.PartAttachment[]; - /** The external id of the conversation part */ - external_id?: string; - /** Whether or not the conversation part has been redacted. */ - redacted?: boolean; - email_message_metadata?: Intercom.EmailMessageMetadata; - metadata?: Intercom.ConversationPartMetadata; - /** Indicates the current state of conversation when the conversation part was created. */ - state?: ConversationPart.State; - /** A list of tags objects associated with the conversation part. */ - tags?: Intercom.TagBasic[]; - event_details?: Intercom.EventDetails; - /** The app package code if this part was created via API. null if the part was not created via API. */ - app_package_code?: string; -} - -export namespace ConversationPart { - /** Indicates the current state of conversation when the conversation part was created. */ - export const State = { - Open: "open", - Closed: "closed", - Snoozed: "snoozed", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/types/ConversationPartAuthor.ts b/src/api/types/ConversationPartAuthor.ts deleted file mode 100644 index 3a17d751..00000000 --- a/src/api/types/ConversationPartAuthor.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The object who initiated the conversation, which can be a Contact, Admin or Team. Bots and campaigns send messages on behalf of Admins or Teams. For Twitter, this will be blank. - */ -export interface ConversationPartAuthor { - /** The type of the author */ - type?: string; - /** The id of the author */ - id?: string; - /** The name of the author */ - name?: string; - /** The email of the author */ - email?: string; - /** If this conversation part was sent by the AI Agent */ - from_ai_agent?: boolean; - /** If this conversation part body was generated by the AI Agent */ - is_ai_answer?: boolean; -} diff --git a/src/api/types/ConversationPartMetadata.ts b/src/api/types/ConversationPartMetadata.ts deleted file mode 100644 index 34c17f40..00000000 --- a/src/api/types/ConversationPartMetadata.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Metadata for a conversation part - */ -export interface ConversationPartMetadata { - /** The quick reply options sent by the Admin or bot, presented in this conversation part. */ - quick_reply_options?: ConversationPartMetadata.QuickReplyOptions.Item[]; - /** The unique identifier for the quick reply option that was clicked by the end user. */ - quick_reply_uuid?: string; -} - -export namespace ConversationPartMetadata { - export type QuickReplyOptions = QuickReplyOptions.Item[]; - - export namespace QuickReplyOptions { - export interface Item extends Intercom.QuickReplyOption { - /** The translations for the quick reply option. */ - translations?: Record; - } - } -} diff --git a/src/api/types/ConversationParts.ts b/src/api/types/ConversationParts.ts deleted file mode 100644 index ba6730f6..00000000 --- a/src/api/types/ConversationParts.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. - */ -export interface ConversationParts { - /** */ - type?: "conversation_part.list"; - /** A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. */ - conversation_parts?: Intercom.ConversationPart[]; - /** */ - total_count?: number; -} diff --git a/src/api/types/ConversationRating.ts b/src/api/types/ConversationRating.ts deleted file mode 100644 index 1ba83dbb..00000000 --- a/src/api/types/ConversationRating.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * The Conversation Rating object which contains information on the rating and/or remark added by a Contact and the Admin assigned to the conversation. - */ -export interface ConversationRating { - /** The rating, between 1 and 5, for the conversation. */ - rating?: number; - /** An optional field to add a remark to correspond to the number rating */ - remark?: string; - /** The time the rating was requested in the conversation being rated. */ - created_at?: number; - /** The time the rating was last updated. */ - updated_at?: number; - contact?: Intercom.ContactReference; - teammate?: Intercom.Reference; -} diff --git a/src/api/types/ConversationResponseTime.ts b/src/api/types/ConversationResponseTime.ts deleted file mode 100644 index 8c503679..00000000 --- a/src/api/types/ConversationResponseTime.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Details of first response time of assigned team in seconds. - */ -export interface ConversationResponseTime { - /** Id of the assigned team. */ - team_id?: number; - /** Name of the assigned Team, null if team does not exist, Unassigned if no team is assigned. */ - team_name?: string; - /** First response time of assigned team in seconds. */ - response_time?: number; -} diff --git a/src/api/types/ConversationSource.ts b/src/api/types/ConversationSource.ts deleted file mode 100644 index 960f667c..00000000 --- a/src/api/types/ConversationSource.ts +++ /dev/null @@ -1,43 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * The type of the conversation part that started this conversation. Can be Contact, Admin, Campaign, Automated or Operator initiated. - */ -export interface ConversationSource { - /** This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ - type?: ConversationSource.Type; - /** The id representing the message. */ - id?: string; - /** The conversation's initiation type. Possible values are customer_initiated, campaigns_initiated (legacy campaigns), operator_initiated (Custom bot), automated (Series and other outbounds with dynamic audience message) and admin_initiated (fixed audience message, ticket initiated by an admin, group email). */ - delivered_as?: string; - /** Optional. The message subject. For Twitter, this will show a generic message regarding why the subject is obscured. */ - subject?: string; - /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ - body?: string; - author?: Intercom.ConversationPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.PartAttachment[]; - /** The URL where the conversation was started. For Twitter, Email, and Bots, this will be blank. */ - url?: string; - /** Whether or not the source message has been redacted. Only applicable for contact initiated messages. */ - redacted?: boolean; -} - -export namespace ConversationSource { - /** This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ - export const Type = { - Conversation: "conversation", - Email: "email", - Facebook: "facebook", - Instagram: "instagram", - PhoneCall: "phone_call", - PhoneSwitch: "phone_switch", - Push: "push", - Sms: "sms", - Twitter: "twitter", - Whatsapp: "whatsapp", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/ConversationStatistics.ts b/src/api/types/ConversationStatistics.ts deleted file mode 100644 index 999c99f5..00000000 --- a/src/api/types/ConversationStatistics.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A Statistics object containing all information required for reporting, with timestamps and calculated metrics. - */ -export interface ConversationStatistics { - /** */ - type?: string; - /** Duration until last assignment before first admin reply. In seconds. */ - time_to_assignment?: number; - /** Duration until first admin reply. Subtracts out of business hours. In seconds. */ - time_to_admin_reply?: number; - /** Duration until conversation was closed first time. Subtracts out of business hours. In seconds. */ - time_to_first_close?: number; - /** Duration until conversation was closed last time. Subtracts out of business hours. In seconds. */ - time_to_last_close?: number; - /** Median based on all admin replies after a contact reply. Subtracts out of business hours. In seconds. */ - median_time_to_reply?: number; - /** Time of first text conversation part from a contact. */ - first_contact_reply_at?: number; - /** Time of first assignment after first_contact_reply_at. */ - first_assignment_at?: number; - /** Time of first admin reply after first_contact_reply_at. */ - first_admin_reply_at?: number; - /** Time of first close after first_contact_reply_at. */ - first_close_at?: number; - /** Time of last assignment after first_contact_reply_at. */ - last_assignment_at?: number; - /** Time of first admin reply since most recent assignment. */ - last_assignment_admin_reply_at?: number; - /** Time of the last conversation part from a contact. */ - last_contact_reply_at?: number; - /** Time of the last conversation part from an admin. */ - last_admin_reply_at?: number; - /** Time of the last conversation close. */ - last_close_at?: number; - /** The last admin who closed the conversation. Returns a reference to an Admin object. */ - last_closed_by_id?: string; - /** Number of reopens after first_contact_reply_at. */ - count_reopens?: number; - /** Number of assignments after first_contact_reply_at. */ - count_assignments?: number; - /** Total number of conversation parts. */ - count_conversation_parts?: number; - /** An array of conversation response time objects */ - assigned_team_first_response_time_by_team?: Intercom.ConversationResponseTime[]; - /** An array of conversation response time objects within office hours */ - assigned_team_first_response_time_in_office_hours?: Intercom.ConversationResponseTime[]; - /** Time from conversation assignment to conversation close in seconds. */ - handling_time?: number; - /** Adjusted handling time for conversation in seconds. This is the active handling time excluding idle periods when teammates are not actively working on the conversation. */ - adjusted_handling_time?: number; -} diff --git a/src/api/types/ConversationTeammates.ts b/src/api/types/ConversationTeammates.ts deleted file mode 100644 index 4f278e45..00000000 --- a/src/api/types/ConversationTeammates.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * The list of teammates who participated in the conversation (wrote at least one conversation part). - */ -export interface ConversationTeammates { - /** The type of the object - `admin.list`. */ - type: "admin.list"; - /** The list of teammates who participated in the conversation (wrote at least one conversation part). */ - admins: Intercom.Reference[]; -} diff --git a/src/api/types/CreateArticleRequest.ts b/src/api/types/CreateArticleRequest.ts deleted file mode 100644 index 432c43aa..00000000 --- a/src/api/types/CreateArticleRequest.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * You can create an Article - */ -export interface CreateArticleRequest { - /** The title of the article.For multilingual articles, this will be the title of the default language's content. */ - title: string; - /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ - description?: string; - /** The content of the article. For multilingual articles, this will be the body of the default language's content. */ - body?: string; - /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ - author_id: number; - /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ - state?: CreateArticleRequest.State; - /** The id of the article's parent collection or section. An article without this field stands alone. */ - parent_id?: number; - /** The type of parent, which can either be a `collection` or `section`. */ - parent_type?: CreateArticleRequest.ParentType; - translated_content?: Intercom.ArticleTranslatedContent; -} - -export namespace CreateArticleRequest { - /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ - export const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; - /** The type of parent, which can either be a `collection` or `section`. */ - export const ParentType = { - Collection: "collection", - Section: "section", - } as const; - export type ParentType = (typeof ParentType)[keyof typeof ParentType]; -} diff --git a/src/api/types/CreateContactRequest.ts b/src/api/types/CreateContactRequest.ts deleted file mode 100644 index 4067737b..00000000 --- a/src/api/types/CreateContactRequest.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload to create a contact - */ -export type CreateContactRequest = - | { - email: string; - phone?: string | undefined; - name?: string | undefined; - avatar?: string | undefined; - signed_up_at?: number | undefined; - last_seen_at?: number | undefined; - owner_id?: number | undefined; - unsubscribed_from_emails?: boolean | undefined; - custom_attributes?: Record | undefined; - } - | { - external_id: string; - phone?: string | undefined; - name?: string | undefined; - avatar?: string | undefined; - signed_up_at?: number | undefined; - last_seen_at?: number | undefined; - owner_id?: number | undefined; - unsubscribed_from_emails?: boolean | undefined; - custom_attributes?: Record | undefined; - } - | { - role: string; - phone?: string | undefined; - name?: string | undefined; - avatar?: string | undefined; - signed_up_at?: number | undefined; - last_seen_at?: number | undefined; - owner_id?: number | undefined; - unsubscribed_from_emails?: boolean | undefined; - custom_attributes?: Record | undefined; - }; diff --git a/src/api/types/CreateContactRequestTwo.ts b/src/api/types/CreateContactRequestTwo.ts deleted file mode 100644 index 06133b6b..00000000 --- a/src/api/types/CreateContactRequestTwo.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type CreateContactRequestTwo = unknown; diff --git a/src/api/types/CreateDataAttributeRequest.ts b/src/api/types/CreateDataAttributeRequest.ts deleted file mode 100644 index e2abd5d2..00000000 --- a/src/api/types/CreateDataAttributeRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type CreateDataAttributeRequest = - | { - data_type?: "options" | undefined; - options: { - value?: string | undefined; - }[]; - } - | { - data_type?: ("string" | "integer" | "float" | "boolean" | "datetime" | "date") | undefined; - }; diff --git a/src/api/types/CreateDataEventRequest.ts b/src/api/types/CreateDataEventRequest.ts deleted file mode 100644 index b0502eab..00000000 --- a/src/api/types/CreateDataEventRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type CreateDataEventRequest = - | { - id: string; - event_name: string; - created_at: number; - metadata?: Record | undefined; - } - | { - user_id: string; - event_name: string; - created_at: number; - metadata?: Record | undefined; - } - | { - email: string; - event_name: string; - created_at: number; - metadata?: Record | undefined; - }; diff --git a/src/api/types/CreateDataEventRequestTwo.ts b/src/api/types/CreateDataEventRequestTwo.ts deleted file mode 100644 index d4d0d15e..00000000 --- a/src/api/types/CreateDataEventRequestTwo.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type CreateDataEventRequestTwo = unknown; diff --git a/src/api/types/CreateInternalArticleRequest.ts b/src/api/types/CreateInternalArticleRequest.ts deleted file mode 100644 index f971e918..00000000 --- a/src/api/types/CreateInternalArticleRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create an Internal Article - */ -export interface CreateInternalArticleRequest { - /** The title of the article. */ - title: string; - /** The content of the article. */ - body?: string; - /** The id of the author of the article. */ - author_id: number; - /** The id of the owner of the article. */ - owner_id: number; -} diff --git a/src/api/types/CreateMessageRequest.ts b/src/api/types/CreateMessageRequest.ts deleted file mode 100644 index 2e3bc5fb..00000000 --- a/src/api/types/CreateMessageRequest.ts +++ /dev/null @@ -1,108 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * You can create a message - */ -export type CreateMessageRequest = Intercom.CreateMessageRequest.Email | Intercom.CreateMessageRequest.Inapp; - -export namespace CreateMessageRequest { - export interface Email { - message_type: "email"; - /** The title of the email. */ - subject: string; - /** The content of the message. HTML and plaintext are supported. */ - body: string; - /** The style of the outgoing message. Possible values `plain` or `personal`. */ - template: string; - /** The sender of the message. If not provided, the default sender will be used. */ - from: CreateMessageRequestWithEmail.From; - /** The sender of the message. If not provided, the default sender will be used. */ - to: CreateMessageRequestWithEmail.To; - /** The time the message was created. If not provided, the current time will be used. */ - created_at?: number; - /** Whether a conversation should be opened in the inbox for the message without the contact replying. Defaults to false if not provided. */ - create_conversation_without_contact_reply?: boolean; - } - - export namespace CreateMessageRequestWithEmail { - /** - * The sender of the message. If not provided, the default sender will be used. - */ - export interface From { - /** Always `admin`. */ - type: "admin"; - /** The identifier for the admin which is given by Intercom. */ - id: number; - } - - /** - * The sender of the message. If not provided, the default sender will be used. - */ - export interface To { - /** The role associated to the contact - `user` or `lead`. */ - type: To.Type; - /** The identifier for the contact which is given by Intercom. */ - id: string; - } - - export namespace To { - /** The role associated to the contact - `user` or `lead`. */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } - - export interface Inapp { - message_type: "inapp"; - /** The title of the email. */ - subject?: string; - /** The content of the message. HTML and plaintext are supported. */ - body: string; - /** The style of the outgoing message. Possible values `plain` or `personal`. */ - template?: string; - /** The sender of the message. If not provided, the default sender will be used. */ - from: CreateMessageRequestWithInapp.From; - /** The sender of the message. If not provided, the default sender will be used. */ - to: CreateMessageRequestWithInapp.To; - /** The time the message was created. If not provided, the current time will be used. */ - created_at?: number; - /** Whether a conversation should be opened in the inbox for the message without the contact replying. Defaults to false if not provided. */ - create_conversation_without_contact_reply?: boolean; - } - - export namespace CreateMessageRequestWithInapp { - /** - * The sender of the message. If not provided, the default sender will be used. - */ - export interface From { - /** Always `admin`. */ - type: "admin"; - /** The identifier for the admin which is given by Intercom. */ - id: number; - } - - /** - * The sender of the message. If not provided, the default sender will be used. - */ - export interface To { - /** The role associated to the contact - `user` or `lead`. */ - type: To.Type; - /** The identifier for the contact which is given by Intercom. */ - id: string; - } - - export namespace To { - /** The role associated to the contact - `user` or `lead`. */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } -} diff --git a/src/api/types/CreateOrUpdateCompanyRequest.ts b/src/api/types/CreateOrUpdateCompanyRequest.ts deleted file mode 100644 index 136693c2..00000000 --- a/src/api/types/CreateOrUpdateCompanyRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create or update a Company - */ -export interface CreateOrUpdateCompanyRequest { - /** The name of the Company */ - name?: string; - /** The company id you have defined for the company. Can't be updated */ - company_id?: string; - /** The name of the plan you have associated with the company. */ - plan?: string; - /** The number of employees in this company. */ - size?: number; - /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ - website?: string; - /** The industry that this company operates in. */ - industry?: string; - /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ - custom_attributes?: Record; - /** The time the company was created by you. */ - remote_created_at?: number; - /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ - monthly_spend?: number; -} diff --git a/src/api/types/CreateOrUpdateTagRequest.ts b/src/api/types/CreateOrUpdateTagRequest.ts deleted file mode 100644 index 7dfd1b3f..00000000 --- a/src/api/types/CreateOrUpdateTagRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create or update an existing tag. - */ -export interface CreateOrUpdateTagRequest { - /** The name of the tag, which will be created if not found, or the new name for the tag if this is an update request. Names are case insensitive. */ - name: string; - /** The id of tag to updates. */ - id?: string; -} diff --git a/src/api/types/CreatePhoneSwitchRequest.ts b/src/api/types/CreatePhoneSwitchRequest.ts deleted file mode 100644 index aae47b79..00000000 --- a/src/api/types/CreatePhoneSwitchRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * You can create an phone switch - */ -export interface CreatePhoneSwitchRequest { - /** Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. */ - phone: string; - custom_attributes?: Intercom.CustomAttributes; -} diff --git a/src/api/types/CreateTicketReplyWithCommentRequest.ts b/src/api/types/CreateTicketReplyWithCommentRequest.ts deleted file mode 100644 index 31d1cccc..00000000 --- a/src/api/types/CreateTicketReplyWithCommentRequest.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type CreateTicketReplyWithCommentRequest = Intercom.ContactReplyTicketRequest | Intercom.AdminReplyTicketRequest; diff --git a/src/api/types/CreateTicketRequestBody.ts b/src/api/types/CreateTicketRequestBody.ts deleted file mode 100644 index 9ec9fb5c..00000000 --- a/src/api/types/CreateTicketRequestBody.ts +++ /dev/null @@ -1,48 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create a Ticket - */ -export interface CreateTicketRequestBody { - /** The ID of the type of ticket you want to create */ - ticket_type_id: string; - /** The list of contacts (users or leads) affected by this ticket. Currently only one is allowed */ - contacts: CreateTicketRequestBody.Contacts.Item[]; - /** - * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: - * - conversation | back-office ticket - * - customer tickets | non-shared back-office ticket - * - conversation | tracker ticket - * - customer ticket | tracker ticket - */ - conversation_to_link_id?: string; - /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom */ - company_id?: string; - /** The time the ticket was created. If not provided, the current time will be used. */ - created_at?: number; - assignment?: CreateTicketRequestBody.Assignment; -} - -export namespace CreateTicketRequestBody { - export type Contacts = Contacts.Item[]; - - export namespace Contacts { - export type Item = - | { - id: string; - } - | { - external_id: string; - } - | { - email: string; - }; - } - - export interface Assignment { - /** The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. */ - admin_assignee_id?: string; - /** The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned. */ - team_assignee_id?: string; - } -} diff --git a/src/api/types/CreateTicketTypeRequest.ts b/src/api/types/CreateTicketTypeRequest.ts deleted file mode 100644 index eebc72da..00000000 --- a/src/api/types/CreateTicketTypeRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The request payload for creating a ticket type. - * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) - */ -export interface CreateTicketTypeRequest { - /** The name of the ticket type. */ - name: string; - /** The description of the ticket type. */ - description?: string; - /** Category of the Ticket Type. */ - category?: CreateTicketTypeRequest.Category; - /** The icon of the ticket type. */ - icon?: string; - /** Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute. */ - is_internal?: boolean; -} - -export namespace CreateTicketTypeRequest { - /** Category of the Ticket Type. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/types/CursorPages.ts b/src/api/types/CursorPages.ts deleted file mode 100644 index 4245c670..00000000 --- a/src/api/types/CursorPages.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Cursor-based pagination is a technique used in the Intercom API to navigate through large amounts of data. - * A "cursor" or pointer is used to keep track of the current position in the result set, allowing the API to return the data in small chunks or "pages" as needed. - */ -export interface CursorPages { - /** the type of object `pages`. */ - type?: "pages"; - /** The current page */ - page?: number; - next?: Intercom.StartingAfterPaging; - /** Number of results per page */ - per_page?: number; - /** Total number of pages */ - total_pages?: number; -} diff --git a/src/api/types/CustomActionFinished.ts b/src/api/types/CustomActionFinished.ts deleted file mode 100644 index 54471392..00000000 --- a/src/api/types/CustomActionFinished.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about final status of the completed action for conversation part type custom_action_finished. - */ -export interface CustomActionFinished { - action?: CustomActionFinished.Action; -} - -export namespace CustomActionFinished { - export interface Action { - /** Name of the action */ - name?: string; - /** Status of the action */ - result?: Action.Result; - } - - export namespace Action { - /** Status of the action */ - export const Result = { - Success: "success", - Failed: "failed", - } as const; - export type Result = (typeof Result)[keyof typeof Result]; - } -} diff --git a/src/api/types/CustomActionStarted.ts b/src/api/types/CustomActionStarted.ts deleted file mode 100644 index 18114f6c..00000000 --- a/src/api/types/CustomActionStarted.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about name of the action that was initiated for conversation part type custom_action_started. - */ -export interface CustomActionStarted { - action?: CustomActionStarted.Action; -} - -export namespace CustomActionStarted { - export interface Action { - /** Name of the action */ - name?: string; - } -} diff --git a/src/api/types/CustomAttributes.ts b/src/api/types/CustomAttributes.ts deleted file mode 100644 index 6fd00ee3..00000000 --- a/src/api/types/CustomAttributes.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Custom data set for this data. - */ -export type CustomAttributes = Record; - -export namespace CustomAttributes { - export type Value = string | number | Intercom.Datetime | Intercom.CustomObjectInstanceList; -} diff --git a/src/api/types/CustomChannelAttribute.ts b/src/api/types/CustomChannelAttribute.ts deleted file mode 100644 index 9afa1dd6..00000000 --- a/src/api/types/CustomChannelAttribute.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface CustomChannelAttribute { - /** Identifier for the attribute being collected. */ - id: string; - /** Value provided by the user for the attribute. */ - value: string; -} diff --git a/src/api/types/CustomChannelBaseEvent.ts b/src/api/types/CustomChannelBaseEvent.ts deleted file mode 100644 index dcf9e00e..00000000 --- a/src/api/types/CustomChannelBaseEvent.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export interface CustomChannelBaseEvent { - /** Unique identifier for the event. */ - event_id: string; - /** Identifier for the conversation in your application. */ - external_conversation_id: string; - contact: Intercom.CustomChannelContact; -} diff --git a/src/api/types/CustomChannelContact.ts b/src/api/types/CustomChannelContact.ts deleted file mode 100644 index 7d11a83c..00000000 --- a/src/api/types/CustomChannelContact.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface CustomChannelContact { - /** Type of contact, must be "user" or "lead". */ - type: CustomChannelContact.Type; - /** External identifier for the contact. Intercom will take care of the mapping of your external_id with our internal ones so you don't have to worry about it. */ - external_id: string; - /** Name of the contact. Required for user type. */ - name?: string; - /** Email address of the contact. Required for user type. */ - email?: string; -} - -export namespace CustomChannelContact { - /** Type of contact, must be "user" or "lead". */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/CustomChannelNotificationResponse.ts b/src/api/types/CustomChannelNotificationResponse.ts deleted file mode 100644 index 238b883d..00000000 --- a/src/api/types/CustomChannelNotificationResponse.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface CustomChannelNotificationResponse { - /** The external conversation ID provided in the notification request */ - external_conversation_id: string; - /** The Intercom conversation ID mapped to the external conversation ID */ - conversation_id: string; - /** The external contact ID provided in the notification request */ - external_contact_id: string; - /** The Intercom contact ID mapped to the external contact ID */ - contact_id: string; -} diff --git a/src/api/types/CustomObjectInstanceDeleted.ts b/src/api/types/CustomObjectInstanceDeleted.ts deleted file mode 100644 index 4c14eba9..00000000 --- a/src/api/types/CustomObjectInstanceDeleted.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * deleted custom object instance object - */ -export interface CustomObjectInstanceDeleted { - /** The unique identifier of the Custom Object type that defines the structure of the Custom Object instance. */ - object?: string; - /** The Intercom defined id representing the Custom Object instance. */ - id?: string; - /** Whether the Custom Object instance is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/types/CustomObjectInstanceList.ts b/src/api/types/CustomObjectInstanceList.ts deleted file mode 100644 index f537ed2d..00000000 --- a/src/api/types/CustomObjectInstanceList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * The list of associated custom object instances for a given reference attribute on the parent object. - */ -export interface CustomObjectInstanceList { - type?: string; - /** The list of associated custom object instances for a given reference attribute on the parent object. */ - instances?: (Intercom.CustomObjectInstance | undefined)[]; -} diff --git a/src/api/types/CustomerRequest.ts b/src/api/types/CustomerRequest.ts deleted file mode 100644 index d86d11c7..00000000 --- a/src/api/types/CustomerRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type CustomerRequest = - | { - intercom_user_id: string; - } - | { - user_id: string; - } - | { - email: string; - }; diff --git a/src/api/types/DataAttributeList.ts b/src/api/types/DataAttributeList.ts deleted file mode 100644 index 6fb01c20..00000000 --- a/src/api/types/DataAttributeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of all data attributes belonging to a workspace for contacts, companies or conversations. - */ -export interface DataAttributeList { - /** The type of the object */ - type?: "list"; - /** A list of data attributes */ - data?: Intercom.DataAttribute[]; -} diff --git a/src/api/types/DataEventList.ts b/src/api/types/DataEventList.ts deleted file mode 100644 index 2a68082a..00000000 --- a/src/api/types/DataEventList.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of data events for the App. - */ -export interface DataEventList { - /** The type of the object */ - type?: "event.list"; - /** A list of data events */ - events?: Intercom.DataEvent[]; - /** Pagination */ - pages?: DataEventList.Pages; -} - -export namespace DataEventList { - /** - * Pagination - */ - export interface Pages { - next?: string; - since?: string; - } -} diff --git a/src/api/types/DataEventSummary.ts b/src/api/types/DataEventSummary.ts deleted file mode 100644 index e2791b1f..00000000 --- a/src/api/types/DataEventSummary.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a summary of data events for the App. - */ -export interface DataEventSummary { - /** The type of the object */ - type?: "event.summary"; - /** The email address of the user */ - email?: string; - /** The Intercom user ID of the user */ - intercom_user_id?: string; - /** The user ID of the user */ - user_id?: string; - /** A summary of data events */ - events: (Intercom.DataEventSummaryItem | undefined)[]; -} diff --git a/src/api/types/DataEventSummaryItem.ts b/src/api/types/DataEventSummaryItem.ts deleted file mode 100644 index 9f0d9192..00000000 --- a/src/api/types/DataEventSummaryItem.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * This will return a summary of a data event for the App. - */ -export interface DataEventSummaryItem { - /** The name of the event */ - name?: string; - /** The first time the event was sent */ - first?: string; - /** The last time the event was sent */ - last?: string; - /** The number of times the event was sent */ - count?: number; - /** The description of the event */ - description?: string; -} diff --git a/src/api/types/DataExportCsv.ts b/src/api/types/DataExportCsv.ts deleted file mode 100644 index 8c268f7e..00000000 --- a/src/api/types/DataExportCsv.ts +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A CSV output file - */ -export interface DataExportCsv { - /** The user_id of the user who was sent the message. */ - user_id?: string; - /** The external_user_id of the user who was sent the message */ - user_external_id?: string; - /** The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. */ - company_id?: string; - /** The users email who was sent the message. */ - email?: string; - /** The full name of the user receiving the message */ - name?: string; - /** The id of the message. */ - ruleset_id?: string; - /** The specific content that was received. In an A/B test each version has its own Content ID. */ - content_id?: string; - /** Email, Chat, Post etc. */ - content_type?: string; - /** The title of the content you see in your Intercom workspace. */ - content_title?: string; - /** As you edit content we record new versions. This ID can help you determine which version of a piece of content that was received. */ - ruleset_version_id?: string; - /** ID for this receipt. Will be included with any related stats in other files to identify this specific delivery of a message. */ - receipt_id?: string; - /** Timestamp for when the receipt was recorded. */ - received_at?: number; - /** The id of the series that this content is part of. Will return -1 if not part of a series. */ - series_id?: string; - /** The title of the series that this content is part of. */ - series_title?: string; - /** The id of the series node that this ruleset is associated with. Each block in a series has a corresponding node_id. */ - node_id?: string; - /** The first time a user replied to this message if the content was able to receive replies. */ - first_reply?: number; - /** The first time a user completed this message if the content was able to be completed e.g. Tours, Surveys. */ - first_completion?: number; - /** The first time the series this message was a part of was completed by the user. */ - first_series_completion?: number; - /** The first time the series this message was a part of was disengaged by the user. */ - first_series_disengagement?: number; - /** The first time the series this message was a part of was exited by the user. */ - first_series_exit?: number; - /** The first time the user met this messages associated goal if one exists. */ - first_goal_success?: number; - /** The first time the user opened this message. */ - first_open?: number; - /** The first time the series the user clicked on a link within this message. */ - first_click?: number; - /** The first time the series the user dismissed this message. */ - first_dismisall?: number; - /** The first time the user unsubscribed from this message. */ - first_unsubscribe?: number; - /** The first time this message hard bounced for this user */ - first_hard_bounce?: number; -} diff --git a/src/api/types/Datetime.ts b/src/api/types/Datetime.ts deleted file mode 100644 index 63964732..00000000 --- a/src/api/types/Datetime.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type Datetime = - /** - * A date and time following the ISO8601 notation. */ - | string - /** - * A date and time as UNIX timestamp notation. */ - | number; diff --git a/src/api/types/DeletedArticleObject.ts b/src/api/types/DeletedArticleObject.ts deleted file mode 100644 index 5667114c..00000000 --- a/src/api/types/DeletedArticleObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedArticleObject { - /** The unique identifier for the article which you provided in the URL. */ - id?: string; - /** The type of object which was deleted. - article */ - object?: "article"; - /** Whether the article was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/types/DeletedCollectionObject.ts b/src/api/types/DeletedCollectionObject.ts deleted file mode 100644 index 4d03d936..00000000 --- a/src/api/types/DeletedCollectionObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedCollectionObject { - /** The unique identifier for the collection which you provided in the URL. */ - id?: string; - /** The type of object which was deleted. - `collection` */ - object?: "collection"; - /** Whether the collection was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/types/DeletedCompanyObject.ts b/src/api/types/DeletedCompanyObject.ts deleted file mode 100644 index b5ee6cf6..00000000 --- a/src/api/types/DeletedCompanyObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedCompanyObject { - /** The unique identifier for the company which is given by Intercom. */ - id?: string; - /** The type of object which was deleted. - `company` */ - object?: "company"; - /** Whether the company was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/types/DeletedInternalArticleObject.ts b/src/api/types/DeletedInternalArticleObject.ts deleted file mode 100644 index 47d5060b..00000000 --- a/src/api/types/DeletedInternalArticleObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedInternalArticleObject { - /** The unique identifier for the internal article which you provided in the URL. */ - id?: string; - /** The type of object which was deleted. - internal_article */ - object?: "internal_article"; - /** Whether the internal article was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/types/DeletedObject.ts b/src/api/types/DeletedObject.ts deleted file mode 100644 index a22b393b..00000000 --- a/src/api/types/DeletedObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedObject { - /** The unique identifier for the news item which you provided in the URL. */ - id?: string; - /** The type of object which was deleted - news-item. */ - object?: "news-item"; - /** Whether the news item was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/types/EmailAddressHeader.ts b/src/api/types/EmailAddressHeader.ts deleted file mode 100644 index 7e8d234d..00000000 --- a/src/api/types/EmailAddressHeader.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains data for an email address header for a conversation part that was sent as an email. - */ -export interface EmailAddressHeader { - /** The type of email address header */ - type?: string; - /** The email address */ - email_address?: string; - /** The name associated with the email address */ - name?: string; -} diff --git a/src/api/types/EmailMessageMetadata.ts b/src/api/types/EmailMessageMetadata.ts deleted file mode 100644 index 815571b7..00000000 --- a/src/api/types/EmailMessageMetadata.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Contains metadata if the message was sent as an email - */ -export interface EmailMessageMetadata { - /** The subject of the email */ - subject?: string; - /** A list of an email address headers. */ - email_address_headers?: Intercom.EmailAddressHeader[]; -} diff --git a/src/api/types/Error_.ts b/src/api/types/Error_.ts deleted file mode 100644 index 5a4a39f0..00000000 --- a/src/api/types/Error_.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The API will return an Error List for a failed request, which will contain one or more Error objects. - */ -export interface Error_ { - /** The type is error.list */ - type: "error.list"; - /** */ - request_id?: string; - /** An array of one or more error objects */ - errors: Error_.Errors.Item[]; -} - -export namespace Error_ { - export type Errors = Errors.Item[]; - - export namespace Errors { - export interface Item { - /** A string indicating the kind of error, used to further qualify the HTTP response code */ - code: string; - /** Optional. Human readable description of the error. */ - message?: string; - /** Optional. Used to identify a particular field or query parameter that was in error. */ - field?: string; - } - } -} diff --git a/src/api/types/EventDetails.ts b/src/api/types/EventDetails.ts deleted file mode 100644 index 6db41ca1..00000000 --- a/src/api/types/EventDetails.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type EventDetails = - | Intercom.ConversationAttributeUpdatedByWorkflow - | Intercom.ConversationAttributeUpdatedByAdmin - | Intercom.CustomActionStarted - | Intercom.CustomActionFinished - | Intercom.OperatorWorkflowEvent; diff --git a/src/api/types/FileAttribute.ts b/src/api/types/FileAttribute.ts deleted file mode 100644 index b8fab036..00000000 --- a/src/api/types/FileAttribute.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The value describing a file upload set for a custom attribute - */ -export interface FileAttribute { - type?: string; - /** The name of the file */ - name?: string; - /** The url of the file. This is a temporary URL and will expire after 30 minutes. */ - url?: string; - /** The type of file */ - content_type?: string; - /** The size of the file in bytes */ - filesize?: number; - /** The width of the file in pixels, if applicable */ - width?: number; - /** The height of the file in pixels, if applicable */ - height?: number; -} diff --git a/src/api/types/GroupContent.ts b/src/api/types/GroupContent.ts deleted file mode 100644 index 68c5b320..00000000 --- a/src/api/types/GroupContent.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The Content of a Group. - */ -export interface GroupContent { - /** The type of object - `group_content` . */ - type?: "group_content"; - /** The name of the collection or section. */ - name?: string; - /** The description of the collection. Only available for collections. */ - description?: string; -} diff --git a/src/api/types/GroupTranslatedContent.ts b/src/api/types/GroupTranslatedContent.ts deleted file mode 100644 index 51302ff2..00000000 --- a/src/api/types/GroupTranslatedContent.ts +++ /dev/null @@ -1,85 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * The Translated Content of an Group. The keys are the locale codes and the values are the translated content of the Group. - */ -export interface GroupTranslatedContent { - /** The type of object - group_translated_content. */ - type?: "group_translated_content"; - /** The content of the group in Arabic */ - ar?: Intercom.GroupContent; - /** The content of the group in Bulgarian */ - bg?: Intercom.GroupContent; - /** The content of the group in Bosnian */ - bs?: Intercom.GroupContent; - /** The content of the group in Catalan */ - ca?: Intercom.GroupContent; - /** The content of the group in Czech */ - cs?: Intercom.GroupContent; - /** The content of the group in Danish */ - da?: Intercom.GroupContent; - /** The content of the group in German */ - de?: Intercom.GroupContent; - /** The content of the group in Greek */ - el?: Intercom.GroupContent; - /** The content of the group in English */ - en?: Intercom.GroupContent; - /** The content of the group in Spanish */ - es?: Intercom.GroupContent; - /** The content of the group in Estonian */ - et?: Intercom.GroupContent; - /** The content of the group in Finnish */ - fi?: Intercom.GroupContent; - /** The content of the group in French */ - fr?: Intercom.GroupContent; - /** The content of the group in Hebrew */ - he?: Intercom.GroupContent; - /** The content of the group in Croatian */ - hr?: Intercom.GroupContent; - /** The content of the group in Hungarian */ - hu?: Intercom.GroupContent; - /** The content of the group in Indonesian */ - id?: Intercom.GroupContent; - /** The content of the group in Italian */ - it?: Intercom.GroupContent; - /** The content of the group in Japanese */ - ja?: Intercom.GroupContent; - /** The content of the group in Korean */ - ko?: Intercom.GroupContent; - /** The content of the group in Lithuanian */ - lt?: Intercom.GroupContent; - /** The content of the group in Latvian */ - lv?: Intercom.GroupContent; - /** The content of the group in Mongolian */ - mn?: Intercom.GroupContent; - /** The content of the group in Norwegian */ - nb?: Intercom.GroupContent; - /** The content of the group in Dutch */ - nl?: Intercom.GroupContent; - /** The content of the group in Polish */ - pl?: Intercom.GroupContent; - /** The content of the group in Portuguese (Portugal) */ - pt?: Intercom.GroupContent; - /** The content of the group in Romanian */ - ro?: Intercom.GroupContent; - /** The content of the group in Russian */ - ru?: Intercom.GroupContent; - /** The content of the group in Slovenian */ - sl?: Intercom.GroupContent; - /** The content of the group in Serbian */ - sr?: Intercom.GroupContent; - /** The content of the group in Swedish */ - sv?: Intercom.GroupContent; - /** The content of the group in Turkish */ - tr?: Intercom.GroupContent; - /** The content of the group in Vietnamese */ - vi?: Intercom.GroupContent; - /** The content of the group in Portuguese (Brazil) */ - "pt-BR"?: Intercom.GroupContent; - /** The content of the group in Chinese (China) */ - "zh-CN"?: Intercom.GroupContent; - /** The content of the group in Chinese (Taiwan) */ - "zh-TW"?: Intercom.GroupContent; -} diff --git a/src/api/types/InternalArticleList.ts b/src/api/types/InternalArticleList.ts deleted file mode 100644 index 8de68a0a..00000000 --- a/src/api/types/InternalArticleList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of internal articles for the App. - */ -export interface InternalArticleList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.CursorPages; - /** A count of the total number of internal articles. */ - total_count?: number; - /** An array of Internal Article objects */ - data?: Intercom.InternalArticleListItem[]; -} diff --git a/src/api/types/IpAllowlist.ts b/src/api/types/IpAllowlist.ts deleted file mode 100644 index 27a5b011..00000000 --- a/src/api/types/IpAllowlist.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * IP allowlist settings for the workspace. - */ -export interface IpAllowlist { - /** String representing the object's type. Always has the value `ip_allowlist`. */ - type?: string; - /** Whether the IP allowlist is enabled for the workspace. */ - enabled?: boolean; - /** - * List of allowed IP addresses and/or IP ranges in CIDR notation. - * Examples: - * - Single IP: `192.168.0.1` - * - IP range: `192.168.0.1/24` (allows 192.168.0.0 - 192.168.0.255) - */ - ip_allowlist?: string[]; -} diff --git a/src/api/types/LinkedObject.ts b/src/api/types/LinkedObject.ts deleted file mode 100644 index 27fe77b5..00000000 --- a/src/api/types/LinkedObject.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A linked conversation or ticket. - */ -export interface LinkedObject { - /** ticket or conversation */ - type?: LinkedObject.Type; - /** The ID of the linked object */ - id?: string; - /** Category of the Linked Ticket Object. */ - category?: LinkedObject.Category; -} - -export namespace LinkedObject { - /** ticket or conversation */ - export const Type = { - Ticket: "ticket", - Conversation: "conversation", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - /** Category of the Linked Ticket Object. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/types/LinkedObjectList.ts b/src/api/types/LinkedObjectList.ts deleted file mode 100644 index 3443c217..00000000 --- a/src/api/types/LinkedObjectList.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * An object containing metadata about linked conversations and linked tickets. Up to 1000 can be returned. - */ -export interface LinkedObjectList { - /** Always list. */ - type?: "list"; - /** The total number of linked objects. */ - total_count?: number; - /** Whether or not there are more linked objects than returned. */ - has_more?: boolean; - /** An array containing the linked conversations and linked tickets. */ - data?: Intercom.LinkedObject[]; -} diff --git a/src/api/types/Metadata.ts b/src/api/types/Metadata.ts deleted file mode 100644 index 8d9ca56e..00000000 --- a/src/api/types/Metadata.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type Metadata = Intercom.unstable.ConversationPartMetadata; diff --git a/src/api/types/MultipleFilterSearchRequest.ts b/src/api/types/MultipleFilterSearchRequest.ts deleted file mode 100644 index 400b4119..00000000 --- a/src/api/types/MultipleFilterSearchRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Search using Intercoms Search APIs with more than one filter. - */ -export interface MultipleFilterSearchRequest { - /** An operator to allow boolean inspection between multiple fields. */ - operator?: MultipleFilterSearchRequest.Operator; - value?: MultipleFilterSearchRequest.Value; -} - -export namespace MultipleFilterSearchRequest { - /** An operator to allow boolean inspection between multiple fields. */ - export const Operator = { - And: "AND", - Or: "OR", - } as const; - export type Operator = (typeof Operator)[keyof typeof Operator]; - export type Value = - /** - * Add mutiple filters. */ - | Intercom.MultipleFilterSearchRequest[] - /** - * Add a single filter field. */ - | Intercom.SingleFilterSearchRequest[]; -} diff --git a/src/api/types/NewsItemRequest.ts b/src/api/types/NewsItemRequest.ts deleted file mode 100644 index 89a1a61d..00000000 --- a/src/api/types/NewsItemRequest.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A News Item is a content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers. - */ -export interface NewsItemRequest { - /** The title of the news item. */ - title: string; - /** The news item body, which may contain HTML. */ - body?: string; - /** The id of the sender of the news item. Must be a teammate on the workspace. */ - sender_id: number; - /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ - state?: NewsItemRequest.State; - /** When set to `true`, the news item will appear in the messenger newsfeed without showing a notification badge. */ - deliver_silently?: boolean; - /** Label names displayed to users to categorize the news item. */ - labels?: string[]; - /** Ordered list of emoji reactions to the news item. When empty, reactions are disabled. */ - reactions?: (string | undefined)[]; - /** A list of newsfeed_assignments to assign to the specified newsfeed. */ - newsfeed_assignments?: Intercom.NewsfeedAssignment[]; -} - -export namespace NewsItemRequest { - /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ - export const State = { - Draft: "draft", - Live: "live", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/types/NotFoundErrorBody.ts b/src/api/types/NotFoundErrorBody.ts deleted file mode 100644 index de9109f3..00000000 --- a/src/api/types/NotFoundErrorBody.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface NotFoundErrorBody { - /** The type is error.list */ - type: string; - /** */ - request_id?: string; - /** An array of one or more error objects */ - errors: NotFoundErrorBody.Errors.Item[]; -} - -export namespace NotFoundErrorBody { - export type Errors = Errors.Item[]; - - export namespace Errors { - export interface Item { - /** ticket_not_found */ - code: string; - /** Ticket not found */ - message?: string; - } - } -} diff --git a/src/api/types/NoteList.ts b/src/api/types/NoteList.ts deleted file mode 100644 index 5090713e..00000000 --- a/src/api/types/NoteList.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A paginated list of notes associated with a contact. - */ -export interface NoteList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** An array of notes. */ - data?: Intercom.Note[]; - /** A count of the total number of notes. */ - total_count?: number; -} diff --git a/src/api/types/OffsetPages.ts b/src/api/types/OffsetPages.ts deleted file mode 100644 index 7118e2df..00000000 --- a/src/api/types/OffsetPages.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface OffsetPages { - /** the type of object `offset_pages` */ - type: "offset_pages"; - /** The current offset */ - page?: number; - next?: string; - /** Number of results per page */ - per_page?: number; - /** Total number of pages */ - total_pages?: number; -} diff --git a/src/api/types/OpenConversationRequest.ts b/src/api/types/OpenConversationRequest.ts deleted file mode 100644 index b3e63714..00000000 --- a/src/api/types/OpenConversationRequest.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to open a conversation - */ -export interface OpenConversationRequest { - /** The id of the admin who is performing the action. */ - admin_id: string; -} diff --git a/src/api/types/OperatorWorkflowEvent.ts b/src/api/types/OperatorWorkflowEvent.ts deleted file mode 100644 index df8629d3..00000000 --- a/src/api/types/OperatorWorkflowEvent.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about name of the workflow for conversation part type operator_workflow_event. - */ -export interface OperatorWorkflowEvent { - workflow?: OperatorWorkflowEvent.Workflow; - event?: OperatorWorkflowEvent.Event; -} - -export namespace OperatorWorkflowEvent { - export interface Workflow { - /** The name of the workflow */ - name?: string; - } - - export interface Event { - /** Type of the workflow event initiated */ - type?: string; - /** Result of the workflow event */ - result?: string; - } -} diff --git a/src/api/types/PagesLink.ts b/src/api/types/PagesLink.ts deleted file mode 100644 index 59d698ff..00000000 --- a/src/api/types/PagesLink.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The majority of list resources in the API are paginated to allow clients to traverse data over multiple requests. - * - * Their responses are likely to contain a pages object that hosts pagination links which a client can use to paginate through the data without having to construct a query. The link relations for the pages field are as follows. - */ -export interface PagesLink { - type?: "pages"; - page?: number; - /** A link to the next page of results. A response that does not contain a next link does not have further data to fetch. */ - next?: string; - per_page?: number; - total_pages?: number; -} diff --git a/src/api/types/PaginatedResponse.ts b/src/api/types/PaginatedResponse.ts deleted file mode 100644 index 320b646d..00000000 --- a/src/api/types/PaginatedResponse.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Paginated Response - */ -export interface PaginatedResponse { - /** The type of object */ - type?: PaginatedResponse.Type; - pages?: Intercom.CursorPages; - /** A count of the total number of objects. */ - total_count?: number; - /** An array of Objects */ - data?: Intercom.PaginatedResponseDataItem[]; -} - -export namespace PaginatedResponse { - /** The type of object */ - export const Type = { - List: "list", - ConversationList: "conversation.list", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/PaginatedResponseDataItem.ts b/src/api/types/PaginatedResponseDataItem.ts deleted file mode 100644 index 4aec3d71..00000000 --- a/src/api/types/PaginatedResponseDataItem.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type PaginatedResponseDataItem = - | Intercom.PaginatedResponseDataItem.NewsItem - | Intercom.PaginatedResponseDataItem.Newsfeed; - -export namespace PaginatedResponseDataItem { - export interface NewsItem extends Intercom.NewsItem { - type: "news-item"; - } - - export interface Newsfeed extends Intercom.Newsfeed { - type: "newsfeed"; - } -} diff --git a/src/api/types/PartAttachment.ts b/src/api/types/PartAttachment.ts deleted file mode 100644 index 3c01b778..00000000 --- a/src/api/types/PartAttachment.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The file attached to a part - */ -export interface PartAttachment { - /** The type of attachment */ - type?: string; - /** The name of the attachment */ - name?: string; - /** The URL of the attachment */ - url?: string; - /** The content type of the attachment */ - content_type?: string; - /** The size of the attachment */ - filesize?: number; - /** The width of the attachment */ - width?: number; - /** The height of the attachment */ - height?: number; -} diff --git a/src/api/types/PhoneSwitch.ts b/src/api/types/PhoneSwitch.ts deleted file mode 100644 index 5fbeb892..00000000 --- a/src/api/types/PhoneSwitch.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Phone Switch Response - */ -export interface PhoneSwitch { - /** */ - type?: "phone_call_redirect"; - /** Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. */ - phone?: string; -} diff --git a/src/api/types/QuickReplyOption.ts b/src/api/types/QuickReplyOption.ts deleted file mode 100644 index 8de2d400..00000000 --- a/src/api/types/QuickReplyOption.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface QuickReplyOption { - /** The text to display in this quick reply option. */ - text: string; - /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment conversation part that is created when a user clicks on this reply option. */ - uuid: string; -} diff --git a/src/api/types/Recipient.ts b/src/api/types/Recipient.ts deleted file mode 100644 index 194d11d0..00000000 --- a/src/api/types/Recipient.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A recipient of a message - */ -export interface Recipient { - /** The role associated to the contact - `user` or `lead`. */ - type: Recipient.Type; - /** The identifier for the contact which is given by Intercom. */ - id: string; -} - -export namespace Recipient { - /** The role associated to the contact - `user` or `lead`. */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/RedactConversationRequest.ts b/src/api/types/RedactConversationRequest.ts deleted file mode 100644 index 08d784b4..00000000 --- a/src/api/types/RedactConversationRequest.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type RedactConversationRequest = - /** - * Payload of the request to redact a conversation part */ - | Intercom.RedactConversationRequest.ConversationPart - /** - * Payload of the request to redact a conversation source */ - | Intercom.RedactConversationRequest.Source; - -export namespace RedactConversationRequest { - export interface ConversationPart { - type: "conversation_part"; - /** The id of the conversation. */ - conversation_id: string; - /** The id of the conversation_part. */ - conversation_part_id: string; - } - - export interface Source { - type: "source"; - /** The id of the conversation. */ - conversation_id: string; - /** The id of the source. */ - source_id: string; - } -} diff --git a/src/api/types/Reference.ts b/src/api/types/Reference.ts deleted file mode 100644 index 7c9c82a3..00000000 --- a/src/api/types/Reference.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * reference to another object - */ -export interface Reference { - /** */ - type?: string; - /** */ - id?: string; -} diff --git a/src/api/types/ReplyConversationRequest.ts b/src/api/types/ReplyConversationRequest.ts deleted file mode 100644 index 113e344e..00000000 --- a/src/api/types/ReplyConversationRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type ReplyConversationRequest = - | Intercom.ContactReplyConversationRequest - | Intercom.AdminReplyConversationRequest; diff --git a/src/api/types/SearchRequest.ts b/src/api/types/SearchRequest.ts deleted file mode 100644 index be8ae5af..00000000 --- a/src/api/types/SearchRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Search using Intercoms Search APIs. - */ -export interface SearchRequest { - query: SearchRequest.Query; - pagination?: Intercom.StartingAfterPaging; -} - -export namespace SearchRequest { - export type Query = Intercom.SingleFilterSearchRequest | Intercom.MultipleFilterSearchRequest; -} diff --git a/src/api/types/SegmentList.ts b/src/api/types/SegmentList.ts deleted file mode 100644 index cb3efe41..00000000 --- a/src/api/types/SegmentList.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of Segment Objects. The result may also have a pages object if the response is paginated. - */ -export interface SegmentList { - /** The type of the object */ - type?: "segment.list"; - /** A list of Segment objects */ - segments?: Intercom.Segment[]; - /** A pagination object, which may be empty, indicating no further pages to fetch. */ - pages?: Record; -} diff --git a/src/api/types/SingleFilterSearchRequest.ts b/src/api/types/SingleFilterSearchRequest.ts deleted file mode 100644 index b51eb1a2..00000000 --- a/src/api/types/SingleFilterSearchRequest.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Search using Intercoms Search APIs with a single filter. - */ -export interface SingleFilterSearchRequest { - /** The accepted field that you want to search on. */ - field?: string; - /** The accepted operators you can use to define how you want to search for the value. */ - operator?: SingleFilterSearchRequest.Operator; - /** The value that you want to search on. */ - value?: SingleFilterSearchRequest.Value; -} - -export namespace SingleFilterSearchRequest { - /** The accepted operators you can use to define how you want to search for the value. */ - export const Operator = { - Equals: "=", - NotEquals: "!=", - In: "IN", - NotIn: "NIN", - LessThan: "<", - GreaterThan: ">", - Contains: "~", - DoesNotContain: "!~", - StartsWith: "^", - EndsWith: "$", - } as const; - export type Operator = (typeof Operator)[keyof typeof Operator]; - /** - * The value that you want to search on. - */ - export type Value = string | number | (string | number)[]; -} diff --git a/src/api/types/SlaApplied.ts b/src/api/types/SlaApplied.ts deleted file mode 100644 index 3ea77f62..00000000 --- a/src/api/types/SlaApplied.ts +++ /dev/null @@ -1,35 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The SLA Applied object contains the details for which SLA has been applied to this conversation. - * Important: if there are any canceled sla_events for the conversation - meaning an SLA has been manually removed from a conversation, the sla_status will always be returned as null. - */ -export interface SlaApplied { - /** object type */ - type?: string; - /** The name of the SLA as given by the teammate when it was created. */ - sla_name?: string; - /** - * SLA statuses: - * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. - * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. - * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. - */ - sla_status?: SlaApplied.SlaStatus; -} - -export namespace SlaApplied { - /** - * SLA statuses: - * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. - * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. - * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. - */ - export const SlaStatus = { - Hit: "hit", - Missed: "missed", - Cancelled: "cancelled", - Active: "active", - } as const; - export type SlaStatus = (typeof SlaStatus)[keyof typeof SlaStatus]; -} diff --git a/src/api/types/SnoozeConversationRequest.ts b/src/api/types/SnoozeConversationRequest.ts deleted file mode 100644 index 7e3e7061..00000000 --- a/src/api/types/SnoozeConversationRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload of the request to snooze a conversation - */ -export interface SnoozeConversationRequest { - /** The id of the admin who is performing the action. */ - admin_id: string; - /** The time you want the conversation to reopen. */ - snoozed_until: number; -} diff --git a/src/api/types/SocialProfile.ts b/src/api/types/SocialProfile.ts deleted file mode 100644 index 78030405..00000000 --- a/src/api/types/SocialProfile.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A Social Profile allows you to label your contacts, companies, and conversations and list them using that Social Profile. - */ -export interface SocialProfile { - /** value is "social_profile" */ - type?: "social_profile"; - /** The name of the Social media profile */ - name?: string; - /** The name of the Social media profile */ - url?: string; -} diff --git a/src/api/types/StartingAfterPaging.ts b/src/api/types/StartingAfterPaging.ts deleted file mode 100644 index 6fc82b73..00000000 --- a/src/api/types/StartingAfterPaging.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface StartingAfterPaging { - /** The number of results to fetch per page. */ - per_page?: number; - /** The cursor to use in the next request to get the next page of results. */ - starting_after?: string; -} diff --git a/src/api/types/SubscriptionTypeList.ts b/src/api/types/SubscriptionTypeList.ts deleted file mode 100644 index 134688b1..00000000 --- a/src/api/types/SubscriptionTypeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of subscription type objects. - */ -export interface SubscriptionTypeList { - /** The type of the object */ - type?: "list"; - /** A list of subscription type objects associated with the workspace . */ - data?: Intercom.SubscriptionType[]; -} diff --git a/src/api/types/TagCompanyRequest.ts b/src/api/types/TagCompanyRequest.ts deleted file mode 100644 index 4f4affb5..00000000 --- a/src/api/types/TagCompanyRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can tag a single company or a list of companies. - */ -export interface TagCompanyRequest { - /** The name of the tag, which will be created if not found. */ - name: string; - /** The id or company_id of the company can be passed as input parameters. */ - companies: TagCompanyRequest.Companies.Item[]; -} - -export namespace TagCompanyRequest { - export type Companies = Companies.Item[]; - - export namespace Companies { - export interface Item { - /** The Intercom defined id representing the company. */ - id?: string; - /** The company id you have defined for the company. */ - company_id?: string; - } - } -} diff --git a/src/api/types/TagList.ts b/src/api/types/TagList.ts deleted file mode 100644 index 54b9506c..00000000 --- a/src/api/types/TagList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of tags objects in the workspace. - */ -export interface TagList { - /** The type of the object */ - type?: "list"; - /** A list of tags objects associated with the workspace . */ - data?: Intercom.Tag[]; -} diff --git a/src/api/types/TagMultipleUsersRequest.ts b/src/api/types/TagMultipleUsersRequest.ts deleted file mode 100644 index fc697987..00000000 --- a/src/api/types/TagMultipleUsersRequest.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can tag a list of users. - */ -export interface TagMultipleUsersRequest { - /** The name of the tag, which will be created if not found. */ - name: string; - users: TagMultipleUsersRequest.Users.Item[]; -} - -export namespace TagMultipleUsersRequest { - export type Users = Users.Item[]; - - export namespace Users { - export interface Item { - /** The Intercom defined id representing the user. */ - id?: string; - } - } -} diff --git a/src/api/types/Tags.ts b/src/api/types/Tags.ts deleted file mode 100644 index 0d3680ce..00000000 --- a/src/api/types/Tags.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of tags objects associated with a conversation - */ -export interface Tags { - /** The type of the object */ - type?: "tag.list"; - /** A list of tags objects associated with the conversation. */ - tags?: Intercom.Tag[]; -} diff --git a/src/api/types/TeamList.ts b/src/api/types/TeamList.ts deleted file mode 100644 index def5cbe1..00000000 --- a/src/api/types/TeamList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of team objects for the App. - */ -export interface TeamList { - /** The type of the object */ - type?: "team.list"; - /** A list of team objects */ - teams?: Intercom.Team[]; -} diff --git a/src/api/types/TeamPriorityLevel.ts b/src/api/types/TeamPriorityLevel.ts deleted file mode 100644 index 07d6bae5..00000000 --- a/src/api/types/TeamPriorityLevel.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Admin priority levels for teams - */ -export interface TeamPriorityLevel { - /** The primary team ids for the team */ - primary_team_ids?: number[]; - /** The secondary team ids for the team */ - secondary_team_ids?: number[]; -} diff --git a/src/api/types/TicketCustomAttributes.ts b/src/api/types/TicketCustomAttributes.ts deleted file mode 100644 index 2596f28b..00000000 --- a/src/api/types/TicketCustomAttributes.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * An object containing the different attributes associated to the ticket as key-value pairs. For the default title and description attributes, the keys are `_default_title_` and `_default_description_`. - */ -export type TicketCustomAttributes = Record; diff --git a/src/api/types/TicketList.ts b/src/api/types/TicketList.ts deleted file mode 100644 index e512f129..00000000 --- a/src/api/types/TicketList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Tickets are how you track requests from your users. - */ -export interface TicketList { - /** Always ticket.list */ - type?: "ticket.list"; - /** The list of ticket objects */ - tickets?: (Intercom.Ticket | undefined)[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/TicketPartAuthor.ts b/src/api/types/TicketPartAuthor.ts deleted file mode 100644 index e0ea7ff3..00000000 --- a/src/api/types/TicketPartAuthor.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The author that wrote or triggered the part. Can be a bot, admin, team or user. - */ -export interface TicketPartAuthor { - /** The type of the author */ - type?: TicketPartAuthor.Type; - /** The id of the author */ - id?: string; - /** The name of the author */ - name?: string; - /** The email of the author */ - email?: string; -} - -export namespace TicketPartAuthor { - /** The type of the author */ - export const Type = { - Admin: "admin", - Bot: "bot", - Team: "team", - User: "user", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/TicketParts.ts b/src/api/types/TicketParts.ts deleted file mode 100644 index 9ff75bbe..00000000 --- a/src/api/types/TicketParts.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of Ticket Part objects for each note and event in the ticket. There is a limit of 500 parts. - */ -export interface TicketParts { - /** */ - type?: "ticket_part.list"; - /** A list of Ticket Part objects for each ticket. There is a limit of 500 parts. */ - ticket_parts?: Intercom.TicketPart[]; - /** */ - total_count?: number; -} diff --git a/src/api/types/TicketReply.ts b/src/api/types/TicketReply.ts deleted file mode 100644 index f86b2ef4..00000000 --- a/src/api/types/TicketReply.ts +++ /dev/null @@ -1,36 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A Ticket Part representing a note, comment, or quick_reply on a ticket - */ -export interface TicketReply { - /** Always ticket_part */ - type?: "ticket_part"; - /** The id representing the part. */ - id?: string; - /** Type of the part */ - part_type?: TicketReply.PartType; - /** The message body, which may contain HTML. */ - body?: string; - /** The time the note was created. */ - created_at?: number; - /** The last time the note was updated. */ - updated_at?: number; - author?: Intercom.TicketPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.PartAttachment[]; - /** Whether or not the ticket part has been redacted. */ - redacted?: boolean; -} - -export namespace TicketReply { - /** Type of the part */ - export const PartType = { - Note: "note", - Comment: "comment", - QuickReply: "quick_reply", - } as const; - export type PartType = (typeof PartType)[keyof typeof PartType]; -} diff --git a/src/api/types/TicketRequestCustomAttributes.ts b/src/api/types/TicketRequestCustomAttributes.ts deleted file mode 100644 index f8cce5a3..00000000 --- a/src/api/types/TicketRequestCustomAttributes.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The attributes set on the ticket. When setting the default title and description attributes, the attribute keys that should be used are `_default_title_` and `_default_description_`. When setting ticket type attributes of the list attribute type, the key should be the attribute name and the value of the attribute should be the list item id, obtainable by [listing the ticket type](ref:get_ticket-types). For example, if the ticket type has an attribute called `priority` of type `list`, the key should be `priority` and the value of the attribute should be the guid of the list item (e.g. `de1825a0-0164-4070-8ca6-13e22462fa7e`). - */ -export type TicketRequestCustomAttributes = Record; diff --git a/src/api/types/TicketStateList.ts b/src/api/types/TicketStateList.ts deleted file mode 100644 index ac2fbc51..00000000 --- a/src/api/types/TicketStateList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of ticket states associated with a given ticket type. - */ -export interface TicketStateList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of ticket states associated with a given ticket type. */ - data?: (Intercom.TicketStateDetailed | undefined)[]; -} diff --git a/src/api/types/TicketTypeAttribute.ts b/src/api/types/TicketTypeAttribute.ts deleted file mode 100644 index 855266f6..00000000 --- a/src/api/types/TicketTypeAttribute.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Ticket type attribute, used to define each data field to be captured in a ticket. - */ -export interface TicketTypeAttribute { - /** String representing the object's type. Always has the value `ticket_type_attribute`. */ - type?: string; - /** The id representing the ticket type attribute. */ - id?: string; - /** The id of the workspace that the ticket type attribute belongs to. */ - workspace_id?: string; - /** The name of the ticket type attribute */ - name?: string; - /** The description of the ticket type attribute */ - description?: string; - /** The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ - data_type?: TicketTypeAttribute.DataType; - /** Input options for the attribute */ - input_options?: Record; - /** The order of the attribute against other attributes */ - order?: number; - /** Whether the attribute is required or not for teammates. */ - required_to_create?: boolean; - /** Whether the attribute is required or not for contacts. */ - required_to_create_for_contacts?: boolean; - /** Whether the attribute is visible or not to teammates. */ - visible_on_create?: boolean; - /** Whether the attribute is visible or not to contacts. */ - visible_to_contacts?: boolean; - /** Whether the attribute is built in or not. */ - default?: boolean; - /** The id of the ticket type that the attribute belongs to. */ - ticket_type_id?: number; - /** Whether the ticket type attribute is archived or not. */ - archived?: boolean; - /** The date and time the ticket type attribute was created. */ - created_at?: number; - /** The date and time the ticket type attribute was last updated. */ - updated_at?: number; -} - -export namespace TicketTypeAttribute { - /** The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ - export const DataType = { - String: "string", - List: "list", - Integer: "integer", - Decimal: "decimal", - Boolean: "boolean", - Datetime: "datetime", - Files: "files", - } as const; - export type DataType = (typeof DataType)[keyof typeof DataType]; -} diff --git a/src/api/types/TicketTypeAttributeList.ts b/src/api/types/TicketTypeAttributeList.ts deleted file mode 100644 index 6a9b00dc..00000000 --- a/src/api/types/TicketTypeAttributeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of attributes associated with a given ticket type. - */ -export interface TicketTypeAttributeList { - /** String representing the object's type. Always has the value `ticket_type_attributes.list`. */ - type?: string; - /** A list of ticket type attributes associated with a given ticket type. */ - ticket_type_attributes?: (Intercom.TicketTypeAttribute | undefined)[]; -} diff --git a/src/api/types/TicketTypeList.ts b/src/api/types/TicketTypeList.ts deleted file mode 100644 index d76acea8..00000000 --- a/src/api/types/TicketTypeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of ticket types associated with a given workspace. - */ -export interface TicketTypeList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of ticket_types associated with a given workspace. */ - data?: (Intercom.TicketType | undefined)[]; -} diff --git a/src/api/types/Translation.ts b/src/api/types/Translation.ts deleted file mode 100644 index 3d656a16..00000000 --- a/src/api/types/Translation.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A translation object contains the localised details of a subscription type. - */ -export interface Translation { - /** The localised name of the subscription type. */ - name?: string; - /** The localised description of the subscription type. */ - description?: string; - /** The two character identifier for the language of the translation object. */ - locale?: string; -} diff --git a/src/api/types/UntagCompanyRequest.ts b/src/api/types/UntagCompanyRequest.ts deleted file mode 100644 index 09886bd1..00000000 --- a/src/api/types/UntagCompanyRequest.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can tag a single company or a list of companies. - */ -export interface UntagCompanyRequest { - /** The name of the tag which will be untagged from the company */ - name: string; - /** The id or company_id of the company can be passed as input parameters. */ - companies: UntagCompanyRequest.Companies.Item[]; -} - -export namespace UntagCompanyRequest { - export type Companies = Companies.Item[]; - - export namespace Companies { - export interface Item { - /** The Intercom defined id representing the company. */ - id?: string; - /** The company id you have defined for the company. */ - company_id?: string; - /** Always set to true */ - untag?: boolean; - } - } -} diff --git a/src/api/types/UpdateArticleRequestBody.ts b/src/api/types/UpdateArticleRequestBody.ts deleted file mode 100644 index 3a5100b8..00000000 --- a/src/api/types/UpdateArticleRequestBody.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface UpdateArticleRequestBody { - parent_type?: UpdateArticleRequestBody.ParentType; -} - -export namespace UpdateArticleRequestBody { - export const ParentType = { - Collection: "collection", - Section: "section", - } as const; - export type ParentType = (typeof ParentType)[keyof typeof ParentType]; -} diff --git a/src/api/types/UpdateCompanyRequestBody.ts b/src/api/types/UpdateCompanyRequestBody.ts deleted file mode 100644 index 8949ca97..00000000 --- a/src/api/types/UpdateCompanyRequestBody.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can update a Company - */ -export interface UpdateCompanyRequestBody { - /** The name of the Company */ - name?: string; - /** The name of the plan you have associated with the company. */ - plan?: string; - /** The number of employees in this company. */ - size?: number; - /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ - website?: string; - /** The industry that this company operates in. */ - industry?: string; - /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ - custom_attributes?: Record; - /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ - monthly_spend?: number; -} diff --git a/src/api/types/UpdateDataAttributeRequestBody.ts b/src/api/types/UpdateDataAttributeRequestBody.ts deleted file mode 100644 index 6524ae99..00000000 --- a/src/api/types/UpdateDataAttributeRequestBody.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type UpdateDataAttributeRequestBody = - | { - options: { - value?: string | undefined; - }[]; - } - | unknown; diff --git a/src/api/types/UpdateVisitorRequest.ts b/src/api/types/UpdateVisitorRequest.ts deleted file mode 100644 index 349fd6b2..00000000 --- a/src/api/types/UpdateVisitorRequest.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Update an existing visitor. - */ -export type UpdateVisitorRequest = - | { - id: string; - name?: string | undefined; - custom_attributes?: Record | undefined; - } - | { - user_id: string; - name?: string | undefined; - custom_attributes?: Record | undefined; - }; diff --git a/src/api/types/UpdateVisitorRequestOne.ts b/src/api/types/UpdateVisitorRequestOne.ts deleted file mode 100644 index cfdac3c4..00000000 --- a/src/api/types/UpdateVisitorRequestOne.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type UpdateVisitorRequestOne = unknown; diff --git a/src/api/types/Visitor.ts b/src/api/types/Visitor.ts deleted file mode 100644 index 5aa58457..00000000 --- a/src/api/types/Visitor.ts +++ /dev/null @@ -1,136 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Visitors are useful for representing anonymous people that have not yet been identified. They usually represent website visitors. Visitors are not visible in Intercom platform. The Visitors resource provides methods to fetch, update, convert and delete. - */ -export interface Visitor { - /** Value is 'visitor' */ - type: "visitor"; - /** The Intercom defined id representing the Visitor. */ - id: string; - /** Automatically generated identifier for the Visitor. */ - user_id: string; - /** Identifies if this visitor is anonymous. */ - anonymous?: boolean; - /** The email of the visitor. */ - email?: string; - /** The phone number of the visitor. */ - phone?: string; - /** The name of the visitor. */ - name?: string; - /** The pseudonym of the visitor. */ - pseudonym?: string; - avatar?: Visitor.Avatar; - /** The id of the app the visitor is associated with. */ - app_id?: string; - companies?: Visitor.Companies; - location_data?: Visitor.LocationData; - /** The time the Lead last recorded making a request. */ - las_request_at?: number; - /** The time the Visitor was added to Intercom. */ - created_at?: number; - /** The time the Visitor was added to Intercom. */ - remote_created_at?: number; - /** The time the Visitor signed up for your product. */ - signed_up_at?: number; - /** The last time the Visitor was updated. */ - updated_at?: number; - /** The number of sessions the Visitor has had. */ - session_count?: number; - social_profiles?: Visitor.SocialProfiles; - /** The id of the admin that owns the Visitor. */ - owner_id?: string; - /** Whether the Visitor is unsubscribed from emails. */ - unsubscribed_from_emails?: boolean; - /** Identifies if this visitor has marked an email as spam. */ - marked_email_as_spam?: boolean; - /** Identifies if this visitor has had a hard bounce. */ - has_hard_bounced?: boolean; - tags?: Visitor.Tags; - segments?: Visitor.Segments; - /** The custom attributes you have set on the Visitor. */ - custom_attributes?: Record; - /** The referer of the visitor. */ - referrer?: string; - /** The utm_campaign of the visitor. */ - utm_campaign?: string; - /** The utm_content of the visitor. */ - utm_content?: string; - /** The utm_medium of the visitor. */ - utm_medium?: string; - /** The utm_source of the visitor. */ - utm_source?: string; - /** The utm_term of the visitor. */ - utm_term?: string; - /** Identifies if this visitor has do not track enabled. */ - do_not_track?: boolean; -} - -export namespace Visitor { - export interface Avatar { - /** */ - type?: string; - /** This object represents the avatar associated with the visitor. */ - image_url?: string; - } - - export interface Companies { - /** The type of the object */ - type?: "company.list"; - companies?: Intercom.Company[]; - } - - export interface LocationData { - /** */ - type?: string; - /** The city name of the visitor. */ - city_name?: string; - /** The continent code of the visitor. */ - continent_code?: string; - /** The country code of the visitor. */ - country_code?: string; - /** The country name of the visitor. */ - country_name?: string; - /** The postal code of the visitor. */ - postal_code?: string; - /** The region name of the visitor. */ - region_name?: string; - /** The timezone of the visitor. */ - timezone?: string; - } - - export interface SocialProfiles { - /** The type of the object */ - type?: "social_profile.list"; - social_profiles?: string[]; - } - - export interface Tags { - /** The type of the object */ - type?: "tag.list"; - tags?: Tags.Tags.Item[]; - } - - export namespace Tags { - export type Tags = Tags.Item[]; - - export namespace Tags { - export interface Item { - /** The type of the object */ - type?: "tag"; - /** The id of the tag. */ - id?: string; - /** The name of the tag. */ - name?: string; - } - } - } - - export interface Segments { - /** The type of the object */ - type?: "segment.list"; - segments?: string[]; - } -} diff --git a/src/api/types/VisitorDeletedObject.ts b/src/api/types/VisitorDeletedObject.ts deleted file mode 100644 index 6a3cc196..00000000 --- a/src/api/types/VisitorDeletedObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface VisitorDeletedObject { - /** The unique identifier for the visitor which is given by Intercom. */ - id?: string; - /** The type of object which was deleted */ - type?: "visitor"; - /** Automatically generated identifier for the Visitor. */ - user_id?: string; -} diff --git a/src/api/types/WhatsappMessageStatusList.ts b/src/api/types/WhatsappMessageStatusList.ts deleted file mode 100644 index b1d0e8d8..00000000 --- a/src/api/types/WhatsappMessageStatusList.ts +++ /dev/null @@ -1,67 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface WhatsappMessageStatusList { - type: "list"; - /** The provided ruleset ID */ - ruleset_id: string; - pages: WhatsappMessageStatusList.Pages; - /** Total number of events */ - total_count: number; - events: WhatsappMessageStatusList.Events.Item[]; -} - -export namespace WhatsappMessageStatusList { - export interface Pages { - type: "pages"; - /** Number of results per page */ - per_page: number; - /** Total number of pages */ - total_pages: number; - /** Information for fetching next page (null if no more pages) */ - next?: Pages.Next; - } - - export namespace Pages { - /** - * Information for fetching next page (null if no more pages) - */ - export interface Next { - /** Cursor for the next page */ - starting_after?: string; - } - } - - export type Events = Events.Item[]; - - export namespace Events { - export interface Item { - /** Event ID */ - id: string; - /** ID of the conversation */ - conversation_id: string; - /** Current status of the message */ - status: Item.Status; - /** Event type */ - type: "broadcast_outbound"; - /** Creation timestamp */ - created_at: number; - /** Last update timestamp */ - updated_at: number; - /** WhatsApp's message identifier */ - whatsapp_message_id: string; - /** Name of the WhatsApp template used */ - template_name?: string; - } - - export namespace Item { - /** Current status of the message */ - export const Status = { - Sent: "sent", - Delivered: "delivered", - Read: "read", - Failed: "failed", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; - } - } -} diff --git a/src/api/types/index.ts b/src/api/types/index.ts index d0b6e87d..a0c4ebf2 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -1,163 +1 @@ -export * from "./ActivityLog.js"; -export * from "./ActivityLogList.js"; -export * from "./ActivityLogMetadata.js"; -export * from "./AddressableList.js"; -export * from "./AdminList.js"; -export * from "./AdminPriorityLevel.js"; -export * from "./AdminReplyConversationRequest.js"; -export * from "./AdminReplyTicketRequest.js"; -export * from "./AdminWithApp.js"; -export * from "./App.js"; -export * from "./ArticleContent.js"; -export * from "./ArticleList.js"; -export * from "./ArticleStatistics.js"; -export * from "./ArticleTranslatedContent.js"; -export * from "./AssignConversationRequest.js"; -export * from "./AwayStatusReason.js"; -export * from "./CallList.js"; -export * from "./CloseConversationRequest.js"; -export * from "./CollectionList.js"; -export * from "./CompanyAttachedContacts.js"; -export * from "./CompanyAttachedSegments.js"; -export * from "./CompanyData.js"; -export * from "./CompanyList.js"; -export * from "./CompanyScroll.js"; -export * from "./ContactArchived.js"; -export * from "./ContactAttachedCompanies.js"; -export * from "./ContactBlocked.js"; -export * from "./ContactCompanies.js"; -export * from "./ContactDeleted.js"; -export * from "./ContactList.js"; -export * from "./ContactLocation.js"; -export * from "./ContactNotes.js"; -export * from "./ContactReference.js"; -export * from "./ContactReplyBaseRequest.js"; -export * from "./ContactReplyConversationRequest.js"; -export * from "./ContactReplyEmailRequest.js"; -export * from "./ContactReplyIntercomUserIdRequest.js"; -export * from "./ContactReplyTicketEmailRequest.js"; -export * from "./ContactReplyTicketIntercomUserIdRequest.js"; -export * from "./ContactReplyTicketRequest.js"; -export * from "./ContactReplyTicketUserIdRequest.js"; -export * from "./ContactReplyUserIdRequest.js"; -export * from "./ContactSegments.js"; -export * from "./ContactSocialProfiles.js"; -export * from "./ContactSubscriptionTypes.js"; -export * from "./ContactTags.js"; -export * from "./ContactUnarchived.js"; -export * from "./ContentSourcesList.js"; -export * from "./ConversationAttachmentFiles.js"; -export * from "./ConversationAttributeUpdatedByAdmin.js"; -export * from "./ConversationAttributeUpdatedByWorkflow.js"; -export * from "./ConversationContacts.js"; -export * from "./ConversationDeleted.js"; -export * from "./ConversationFirstContactReply.js"; -export * from "./ConversationList.js"; -export * from "./ConversationPart.js"; -export * from "./ConversationPartAuthor.js"; -export * from "./ConversationPartMetadata.js"; -export * from "./ConversationParts.js"; -export * from "./ConversationRating.js"; -export * from "./ConversationResponseTime.js"; -export * from "./ConversationSource.js"; -export * from "./ConversationStatistics.js"; -export * from "./ConversationTeammates.js"; -export * from "./CreateArticleRequest.js"; -export * from "./CreateContactRequest.js"; -export * from "./CreateContactRequestTwo.js"; -export * from "./CreateDataAttributeRequest.js"; -export * from "./CreateDataEventRequest.js"; -export * from "./CreateDataEventRequestTwo.js"; -export * from "./CreateInternalArticleRequest.js"; -export * from "./CreateMessageRequest.js"; -export * from "./CreateOrUpdateCompanyRequest.js"; -export * from "./CreateOrUpdateTagRequest.js"; -export * from "./CreatePhoneSwitchRequest.js"; -export * from "./CreateTicketReplyWithCommentRequest.js"; -export * from "./CreateTicketRequestBody.js"; -export * from "./CreateTicketTypeRequest.js"; -export * from "./CursorPages.js"; -export * from "./CustomActionFinished.js"; -export * from "./CustomActionStarted.js"; -export * from "./CustomAttributes.js"; -export * from "./CustomChannelAttribute.js"; -export * from "./CustomChannelBaseEvent.js"; -export * from "./CustomChannelContact.js"; -export * from "./CustomChannelNotificationResponse.js"; -export * from "./CustomerRequest.js"; -export * from "./CustomObjectInstanceDeleted.js"; -export * from "./CustomObjectInstanceList.js"; -export * from "./DataAttributeList.js"; -export * from "./DataEventList.js"; -export * from "./DataEventSummary.js"; -export * from "./DataEventSummaryItem.js"; -export * from "./DataExportCsv.js"; -export * from "./Datetime.js"; -export * from "./DeletedArticleObject.js"; -export * from "./DeletedCollectionObject.js"; -export * from "./DeletedCompanyObject.js"; -export * from "./DeletedInternalArticleObject.js"; -export * from "./DeletedObject.js"; -export * from "./EmailAddressHeader.js"; -export * from "./EmailMessageMetadata.js"; -export * from "./Error_.js"; -export * from "./EventDetails.js"; -export * from "./FileAttribute.js"; -export * from "./GroupContent.js"; -export * from "./GroupTranslatedContent.js"; -export * from "./InternalArticleList.js"; -export * from "./IpAllowlist.js"; -export * from "./LinkedObject.js"; -export * from "./LinkedObjectList.js"; -export * from "./Metadata.js"; -export * from "./MultipleFilterSearchRequest.js"; -export * from "./NewsItemRequest.js"; -export * from "./NoteList.js"; -export * from "./NotFoundErrorBody.js"; -export * from "./OffsetPages.js"; -export * from "./OpenConversationRequest.js"; -export * from "./OperatorWorkflowEvent.js"; -export * from "./PagesLink.js"; -export * from "./PaginatedResponse.js"; -export * from "./PaginatedResponseDataItem.js"; -export * from "./PartAttachment.js"; -export * from "./PhoneSwitch.js"; -export * from "./QuickReplyOption.js"; -export * from "./Recipient.js"; -export * from "./RedactConversationRequest.js"; -export * from "./Reference.js"; -export * from "./ReplyConversationRequest.js"; -export * from "./SearchRequest.js"; -export * from "./SegmentList.js"; -export * from "./SingleFilterSearchRequest.js"; -export * from "./SlaApplied.js"; -export * from "./SnoozeConversationRequest.js"; -export * from "./SocialProfile.js"; -export * from "./StartingAfterPaging.js"; -export * from "./SubscriptionTypeList.js"; -export * from "./TagCompanyRequest.js"; -export * from "./TagList.js"; -export * from "./TagMultipleUsersRequest.js"; -export * from "./Tags.js"; -export * from "./TeamList.js"; -export * from "./TeamPriorityLevel.js"; -export * from "./TicketCustomAttributes.js"; -export * from "./TicketList.js"; -export * from "./TicketPartAuthor.js"; -export * from "./TicketParts.js"; -export * from "./TicketReply.js"; -export * from "./TicketRequestCustomAttributes.js"; -export * from "./TicketStateList.js"; -export * from "./TicketTypeAttribute.js"; -export * from "./TicketTypeAttributeList.js"; -export * from "./TicketTypeList.js"; -export * from "./Translation.js"; -export * from "./UntagCompanyRequest.js"; -export * from "./UpdateArticleRequestBody.js"; -export * from "./UpdateCompanyRequestBody.js"; -export * from "./UpdateDataAttributeRequestBody.js"; -export * from "./UpdateVisitorRequest.js"; -export * from "./UpdateVisitorRequestOne.js"; -export * from "./Visitor.js"; -export * from "./VisitorDeletedObject.js"; -export * from "./WhatsappMessageStatusList.js"; +export * from "./types.js"; diff --git a/src/api/types/types.ts b/src/api/types/types.ts new file mode 100644 index 00000000..b535896d --- /dev/null +++ b/src/api/types/types.ts @@ -0,0 +1,3194 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Intercom from "../index.js"; + +export interface UnprocessableEntityErrorBody { + /** Validation messages keyed by the field they apply to, or `base` for conversation-level failures. */ + errors?: Record; +} + +export type Datetime = + /** + * A date and time following the ISO8601 notation. */ + | string + /** + * A date and time as UNIX timestamp notation. */ + | number; + +/** + * Activities performed by Admins. + */ +export interface ActivityLog { + /** The id representing the activity. */ + id?: string; + /** Details about the Admin involved in the activity. */ + performed_by?: ActivityLog.PerformedBy; + metadata?: Intercom.ActivityLogMetadata; + /** The time the activity was created. */ + created_at?: number; + activity_type?: ActivityLog.ActivityType; + /** A sentence or two describing the activity. */ + activity_description?: string; +} + +export namespace ActivityLog { + /** + * Details about the Admin involved in the activity. + */ + export interface PerformedBy { + /** String representing the object's type. Always has the value `admin`. */ + type?: string; + /** The id representing the admin. */ + id?: string; + /** The email of the admin. */ + email?: string; + /** The IP address of the admin. */ + ip?: string; + } + + export const ActivityType = { + AdminConversationAssignmentLimitChange: "admin_conversation_assignment_limit_change", + AdminTicketAssignmentLimitChange: "admin_ticket_assignment_limit_change", + AdminAvatarChange: "admin_avatar_change", + AdminAwayModeChange: "admin_away_mode_change", + AdminDeletion: "admin_deletion", + AdminDeprovisioned: "admin_deprovisioned", + AdminImpersonationEnd: "admin_impersonation_end", + AdminImpersonationStart: "admin_impersonation_start", + AdminImpersonationConsentApproved: "admin_impersonation_consent_approved", + AdminImpersonationConsentRevoked: "admin_impersonation_consent_revoked", + AdminInviteChange: "admin_invite_change", + AdminInviteCreation: "admin_invite_creation", + AdminInviteDeletion: "admin_invite_deletion", + AdminLoginFailure: "admin_login_failure", + AdminLoginSuccess: "admin_login_success", + AdminLogout: "admin_logout", + AdminOccupancySettingChange: "admin_occupancy_setting_change", + AdminOccupancyStateChange: "admin_occupancy_state_change", + AdminPasswordResetRequest: "admin_password_reset_request", + AdminPasswordResetSuccess: "admin_password_reset_success", + AdminPermissionChange: "admin_permission_change", + AdminProvisioned: "admin_provisioned", + AdminTwoFactorAuthChange: "admin_two_factor_auth_change", + AdminUnauthorizedSignInMethod: "admin_unauthorized_sign_in_method", + AppAdminJoin: "app_admin_join", + AppAuthenticationMethodChange: "app_authentication_method_change", + AppDataDeletion: "app_data_deletion", + AppDataExport: "app_data_export", + AppGoogleSsoDomainChange: "app_google_sso_domain_change", + AppIdentityVerificationChange: "app_identity_verification_change", + AppNameChange: "app_name_change", + AppOutboundAddressChange: "app_outbound_address_change", + AppPackageInstallation: "app_package_installation", + AppPackageTokenRegeneration: "app_package_token_regeneration", + AppPackageUninstallation: "app_package_uninstallation", + AppTeamCreation: "app_team_creation", + AppTeamDeletion: "app_team_deletion", + AppTeamMembershipModification: "app_team_membership_modification", + AppTimezoneChange: "app_timezone_change", + AppWebhookCreation: "app_webhook_creation", + AppWebhookDeletion: "app_webhook_deletion", + ArticlesInMessengerEnabledChange: "articles_in_messenger_enabled_change", + AutomaticAwayModeSettingChange: "automatic_away_mode_setting_change", + BulkDelete: "bulk_delete", + BulkExport: "bulk_export", + CampaignDeletion: "campaign_deletion", + CampaignStateChange: "campaign_state_change", + ConversationPartDeletion: "conversation_part_deletion", + ConversationPdfExport: "conversation_pdf_export", + ConversationTopicChange: "conversation_topic_change", + ConversationTopicCreation: "conversation_topic_creation", + ConversationTopicDeletion: "conversation_topic_deletion", + CustomAuthenticationTokenCreation: "custom_authentication_token_creation", + CustomerFacingNameChange: "customer_facing_name_change", + HelpCenterSettingsChange: "help_center_settings_change", + InboundConversationsChange: "inbound_conversations_change", + InboxAccessChange: "inbox_access_change", + MacroCreation: "macro_creation", + MacroDeletion: "macro_deletion", + MacroUpdate: "macro_update", + MacroUsageExport: "macro_usage_export", + MaliciousDomainsSettingChange: "malicious_domains_setting_change", + MessageDeletion: "message_deletion", + MessageStateChange: "message_state_change", + MessengerApiSecretCreation: "messenger_api_secret_creation", + MessengerApiSecretDeletion: "messenger_api_secret_deletion", + MessengerLookAndFeelChange: "messenger_look_and_feel_change", + MessengerSearchRequiredChange: "messenger_search_required_change", + MessengerSpacesChange: "messenger_spaces_change", + OauthTokenRevocation: "oauth_token_revocation", + OfficeHoursChange: "office_hours_change", + RoleChange: "role_change", + RoleCreation: "role_creation", + RoleDeletion: "role_deletion", + RulesetActivationTitlePreview: "ruleset_activation_title_preview", + RulesetCreation: "ruleset_creation", + RulesetDeletion: "ruleset_deletion", + SearchBrowseEnabledChange: "search_browse_enabled_change", + SearchBrowseRequiredChange: "search_browse_required_change", + SeatChange: "seat_change", + SeatRevoke: "seat_revoke", + SecuritySettingsChange: "security_settings_change", + SeriesCreation: "series_creation", + SeriesDeletion: "series_deletion", + SeriesSettingsUpdate: "series_settings_update", + SeriesStatusChange: "series_status_change", + SeriesUpdate: "series_update", + StripInboundEmailLinksChange: "strip_inbound_email_links_change", + TemporaryExpectationChange: "temporary_expectation_change", + TeamAssignmentLimitChange: "team_assignment_limit_change", + TrustedDomainsSettingChange: "trusted_domains_setting_change", + UnassignUnsnoozedAtCapacitySettingChange: "unassign_unsnoozed_at_capacity_setting_change", + UnassignUnsnoozedWhenAwaySettingChange: "unassign_unsnoozed_when_away_setting_change", + UpfrontEmailCollectionChange: "upfront_email_collection_change", + AllowedAttachmentFiletypesSettingChange: "allowed_attachment_filetypes_setting_change", + AttachUploadsInlineSettingChange: "attach_uploads_inline_setting_change", + TeammateGifsSettingChange: "teammate_gifs_setting_change", + UserCameraAttachmentsSettingChange: "user_camera_attachments_setting_change", + UserConversationAttachmentsSettingChange: "user_conversation_attachments_setting_change", + UserFileAttachmentsSettingChange: "user_file_attachments_setting_change", + UserGifsSettingChange: "user_gifs_setting_change", + UserMediaAttachmentsSettingChange: "user_media_attachments_setting_change", + UserVoiceNotesSettingChange: "user_voice_notes_setting_change", + WelcomeMessageChange: "welcome_message_change", + WorkspaceDeletionRequest: "workspace_deletion_request", + } as const; + export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType]; +} + +/** + * A paginated list of activity logs. + */ +export interface ActivityLogList { + /** String representing the object's type. Always has the value `activity_log.list`. */ + type?: string; + pages?: Intercom.CursorPages; + /** An array of activity logs */ + activity_logs?: (Intercom.ActivityLog | undefined)[]; +} + +/** + * Additional data provided about Admin activity. + */ +export interface ActivityLogMetadata { + /** The way the admin signed in. */ + sign_in_method?: string; + /** The unique identifier for the contact which is provided by the Client. */ + external_id?: string; + /** The away mode status which is set to true when away and false when returned. */ + away_mode?: boolean; + /** The reason the Admin is away. */ + away_status_reason?: string; + /** Indicates if conversations should be reassigned while an Admin is away. */ + reassign_conversations?: boolean; + /** The action that initiated the status change. */ + source?: string; + /** Indicates if the status was changed automatically or manually. */ + auto_changed?: string; + /** The ID of the Admin who initiated the activity. */ + update_by?: number; + /** The name of the Admin who initiated the activity. */ + update_by_name?: string; + /** The state before the change. `idle` or `occupied`, and null when the Admin had not been classified yet. */ + previous_state?: string; + /** The state after the change. `idle` or `occupied`. */ + new_state?: string; + /** The inactivity window, in minutes, used to classify the Admin. */ + threshold_minutes?: number; + /** The time of the Admin's last recorded activity. */ + last_activity_at?: number; + /** Indicates the state was derived automatically rather than set by an Admin. */ + auto?: boolean; + /** The group of workspace settings the change belongs to, for example `teammate_occupancy` or `automatic_away_mode`. */ + setting_type?: string; + /** The settings altered by the change, keyed by setting name. Only settings whose value actually moved are included, so an unchanged setting is absent rather than present with equal values. */ + changes?: Record; + /** The conversation assignment limit value for an admin. */ + conversation_assignment_limit?: number; + /** The ticket assignment limit value for an admin. */ + ticket_assignment_limit?: number; + /** Details about the team whose assignment limit was changed. */ + team?: ActivityLogMetadata.Team; + /** The team assignment limit value (null if limit was removed). */ + team_assignment_limit?: number; + /** Indicates if the setting is enabled or disabled. */ + enabled?: boolean; + /** The ID of the impersonation consent. */ + consent_id?: number; + /** The timestamp when the impersonation consent expires. */ + expired_at?: string; + /** The state of settings or values before the change. Structure varies by activity type. */ + before?: Record; + /** The state of settings or values after the change. Structure varies by activity type. */ + after?: Record; +} + +export namespace ActivityLogMetadata { + export namespace Changes { + export interface Value { + /** The value before the change. */ + before?: unknown; + /** The value after the change. */ + after?: unknown; + } + } + + /** + * Details about the team whose assignment limit was changed. + */ + export interface Team { + /** The ID of the team. */ + id?: number; + /** The name of the team. */ + name?: string; + } +} + +/** + * A list used to access other resources from a parent model. + */ +export interface AddressableList { + /** The addressable object type */ + type?: string; + /** The id of the addressable object */ + id?: string; + /** Url to get more company resources for this contact */ + url?: string; +} + +/** + * A list of admins associated with a given workspace. + */ +export interface AdminList { + /** String representing the object's type. Always has the value `admin.list`. */ + type?: string; + /** A list of admins associated with a given workspace. */ + admins?: (Intercom.Admin | undefined)[]; +} + +/** + * Admin priority levels for the team + */ +export interface AdminPriorityLevel { + /** The primary admin ids for the team */ + primary_admin_ids?: number[]; + /** The secondary admin ids for the team */ + secondary_admin_ids?: number[]; +} + +/** + * Payload of the request to reply on behalf of an admin + */ +export interface AdminReplyConversationRequest { + message_type: AdminReplyConversationRequest.MessageType; + type: "admin"; + /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ + body?: string; + /** The id of the admin who is authoring the comment. */ + admin_id: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** The quick reply options to display to the end user. Must be present for quick_reply message types. */ + reply_options?: Intercom.QuickReplyOption[]; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; + /** A list of files that will be added as attachments. You can include up to 10 files */ + attachment_files?: Intercom.ConversationAttachmentFiles[]; +} + +export namespace AdminReplyConversationRequest { + export const MessageType = { + Comment: "comment", + Note: "note", + QuickReply: "quick_reply", + } as const; + export type MessageType = (typeof MessageType)[keyof typeof MessageType]; +} + +/** + * Payload of the request to reply on behalf of an admin + */ +export interface AdminReplyTicketRequest { + /** The type of reply. Tracker tickets and back-office tickets that are not shared with the customer do not support `comment`; use `note` instead. */ + message_type: AdminReplyTicketRequest.MessageType; + type: "admin"; + /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ + body?: string; + /** The id of the admin who is authoring the comment. */ + admin_id: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** The quick reply options to display. Must be present for quick_reply message types. */ + reply_options?: AdminReplyTicketRequest.ReplyOptions.Item[]; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; + /** If set to true, the note will be cross-posted to all linked conversations. Only applicable to note message types on back-office tickets. */ + cross_post?: boolean; +} + +export namespace AdminReplyTicketRequest { + /** The type of reply. Tracker tickets and back-office tickets that are not shared with the customer do not support `comment`; use `note` instead. */ + export const MessageType = { + Comment: "comment", + Note: "note", + QuickReply: "quick_reply", + } as const; + export type MessageType = (typeof MessageType)[keyof typeof MessageType]; + export type ReplyOptions = ReplyOptions.Item[]; + + export namespace ReplyOptions { + export interface Item { + /** The text to display in this quick reply option. */ + text: string; + /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment ticket part that is created when a user clicks on this reply option. */ + uuid: string; + } + } +} + +/** + * Admins are the teammate accounts that have access to a workspace + */ +export interface AdminWithApp { + /** String representing the object's type. Always has the value `admin`. */ + type?: string; + /** The id representing the admin. */ + id?: string; + /** The name of the admin. */ + name?: string; + /** The email of the admin. */ + email?: string; + /** The job title of the admin. */ + job_title?: string; + /** Identifies if this admin is currently set in away mode. */ + away_mode_enabled?: boolean; + /** Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ + away_mode_reassign?: boolean; + /** Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ + has_inbox_seat?: boolean; + /** This is a list of ids of the teams that this admin is part of. */ + team_ids?: number[]; + /** This object represents the avatar associated with the admin. */ + avatar?: AdminWithApp.Avatar; + /** Identifies if this admin's email is verified. */ + email_verified?: boolean; + /** App that the admin belongs to. */ + app?: Intercom.App; +} + +export namespace AdminWithApp { + /** + * This object represents the avatar associated with the admin. + */ + export interface Avatar { + /** This is a string that identifies the type of the object. It will always have the value `avatar`. */ + type?: string; + /** This object represents the avatar associated with the admin. */ + image_url?: string; + } +} + +/** + * App is a workspace on Intercom + */ +export interface App { + /** */ + type?: string; + /** The id of the app. */ + id_code?: string; + /** The name of the app. */ + name?: string; + /** The Intercom region the app is located in. */ + region?: string; + /** The timezone of the region where the app is located. */ + timezone?: string; + /** When the app was created. */ + created_at?: number; + /** Whether or not the app uses identity verification. */ + identity_verification?: boolean; +} + +/** + * The Content of an Article. + */ +export interface ArticleContent { + /** The type of object - `article_content` . */ + type?: "article_content"; + /** The title of the article. */ + title?: string; + /** The description of the article. */ + description?: string; + /** The body of the article. */ + body?: string; + /** The ID of the author of the article. */ + author_id?: number; + /** Whether the article is `published` or is a `draft` . */ + state?: ArticleContent.State; + /** The time when the article was created (seconds). */ + created_at?: number; + /** The time when the article was last updated (seconds). */ + updated_at?: number; + /** The URL of the article. */ + url?: string; +} + +export namespace ArticleContent { + /** Whether the article is `published` or is a `draft` . */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * This will return a list of internal articles for the App. + */ +export interface InternalArticleList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.CursorPages; + /** A count of the total number of internal articles. */ + total_count?: number; + /** An array of Internal Article objects */ + data?: Intercom.InternalArticleListItem[]; +} + +/** + * This will return a list of articles for the App. + */ +export interface ArticleList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: unknown; + /** A count of the total number of articles. */ + total_count?: number; + /** An array of Article objects */ + data?: Intercom.ArticleListItem[]; +} + +/** + * The statistics of an article. + */ +export interface ArticleStatistics { + /** The type of object - `article_statistics`. */ + type: "article_statistics"; + /** The number of total views the article has received. */ + views: number; + /** The number of conversations started from the article. */ + conversions?: number; + /** The number of total reactions the article has received. */ + reactions: number; + /** The percentage of happy reactions the article has received against other types of reaction. */ + happy_reaction_percentage: number; + /** The percentage of neutral reactions the article has received against other types of reaction. */ + neutral_reaction_percentage: number; + /** The percentage of sad reactions the article has received against other types of reaction. */ + sad_reaction_percentage: number; +} + +/** + * The Translated Content of an Article. The keys are the locale codes and the values are the translated content of the article. + */ +export interface ArticleTranslatedContent { + /** The type of object - article_translated_content. */ + type?: "article_translated_content"; + /** The content of the article in Arabic */ + ar?: Intercom.ArticleContent; + /** The content of the article in Bulgarian */ + bg?: Intercom.ArticleContent; + /** The content of the article in Bosnian */ + bs?: Intercom.ArticleContent; + /** The content of the article in Catalan */ + ca?: Intercom.ArticleContent; + /** The content of the article in Czech */ + cs?: Intercom.ArticleContent; + /** The content of the article in Danish */ + da?: Intercom.ArticleContent; + /** The content of the article in German */ + de?: Intercom.ArticleContent; + /** The content of the article in Greek */ + el?: Intercom.ArticleContent; + /** The content of the article in English */ + en?: Intercom.ArticleContent; + /** The content of the article in Spanish */ + es?: Intercom.ArticleContent; + /** The content of the article in Estonian */ + et?: Intercom.ArticleContent; + /** The content of the article in Finnish */ + fi?: Intercom.ArticleContent; + /** The content of the article in French */ + fr?: Intercom.ArticleContent; + /** The content of the article in Hebrew */ + he?: Intercom.ArticleContent; + /** The content of the article in Croatian */ + hr?: Intercom.ArticleContent; + /** The content of the article in Hungarian */ + hu?: Intercom.ArticleContent; + /** The content of the article in Indonesian */ + id?: Intercom.ArticleContent; + /** The content of the article in Italian */ + it?: Intercom.ArticleContent; + /** The content of the article in Japanese */ + ja?: Intercom.ArticleContent; + /** The content of the article in Korean */ + ko?: Intercom.ArticleContent; + /** The content of the article in Lithuanian */ + lt?: Intercom.ArticleContent; + /** The content of the article in Latvian */ + lv?: Intercom.ArticleContent; + /** The content of the article in Mongolian */ + mn?: Intercom.ArticleContent; + /** The content of the article in Norwegian */ + nb?: Intercom.ArticleContent; + /** The content of the article in Dutch */ + nl?: Intercom.ArticleContent; + /** The content of the article in Polish */ + pl?: Intercom.ArticleContent; + /** The content of the article in Portuguese (Portugal) */ + pt?: Intercom.ArticleContent; + /** The content of the article in Romanian */ + ro?: Intercom.ArticleContent; + /** The content of the article in Russian */ + ru?: Intercom.ArticleContent; + /** The content of the article in Slovenian */ + sl?: Intercom.ArticleContent; + /** The content of the article in Serbian */ + sr?: Intercom.ArticleContent; + /** The content of the article in Swedish */ + sv?: Intercom.ArticleContent; + /** The content of the article in Turkish */ + tr?: Intercom.ArticleContent; + /** The content of the article in Vietnamese */ + vi?: Intercom.ArticleContent; + /** The content of the article in Portuguese (Brazil) */ + "pt-BR"?: Intercom.ArticleContent; + /** The content of the article in Chinese (China) */ + "zh-CN"?: Intercom.ArticleContent; + /** The content of the article in Chinese (Taiwan) */ + "zh-TW"?: Intercom.ArticleContent; +} + +/** + * Payload of the request to assign a conversation + */ +export interface AssignConversationRequest { + type: AssignConversationRequest.Type; + /** The id of the admin who is performing the action. */ + admin_id: string; + /** The `id` of the `admin` or `team` which will be assigned the conversation. A conversation can be assigned both an admin and a team.\nSet `0` if you want this assign to no admin or team (ie. Unassigned). */ + assignee_id: string; + /** Optionally you can send a response in the conversation when it is assigned. */ + body?: string; +} + +export namespace AssignConversationRequest { + export const Type = { + Admin: "admin", + Team: "team", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * The participants of the conversation, returned after attaching or detaching a contact + */ +export interface ConversationParticipantsResponse { + /** The conversation participants after the change */ + customers: ConversationParticipantsResponse.Customers.Item[]; +} + +export namespace ConversationParticipantsResponse { + export type Customers = Customers.Item[]; + + export namespace Customers { + export interface Item { + /** The role of the participant. Can be "user" or "lead" */ + type: string; + /** The unique identifier for the participant */ + id: string; + } + } +} + +export interface AwayStatusReason { + type?: string; + /** The unique identifier for the away status reason */ + id?: string; + /** The display text for the away status reason */ + label?: string; + /** The emoji associated with the status reason */ + emoji?: string; + /** The display order of the status reason */ + order?: number; + /** Whether the status reason has been soft deleted */ + deleted?: boolean; + /** The Unix timestamp when the status reason was created */ + created_at?: number; + /** The Unix timestamp when the status reason was last updated */ + updated_at?: number; +} + +/** + * A list of away status reasons. + */ +export interface AwayStatusReasonList { + /** The type of the object */ + type?: "list"; + /** A list of away status reason objects. */ + data?: Intercom.AwayStatusReason[]; +} + +/** + * Payload of the request to close a conversation + */ +export interface CloseConversationRequest { + type: "admin"; + /** The id of the admin who is performing the action. */ + admin_id: string; + /** Optionally you can leave a message in the conversation to provide additional context to the user and other teammates. */ + body?: string; +} + +/** + * This will return a list of Collections for the App. + */ +export interface CollectionList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.OffsetPages; + /** A count of the total number of collections. */ + total_count?: number; + /** An array of collection objects */ + data?: Intercom.Collection[]; +} + +/** + * A list of Contact Objects + */ +export interface CompanyAttachedContacts { + /** The type of object - `list` */ + type?: "list"; + /** An array containing Contact Objects */ + data?: Intercom.Contact[]; + /** The total number of contacts */ + total_count?: number; + pages?: Intercom.CursorPages; +} + +/** + * A list of Segment Objects + */ +export interface CompanyAttachedSegments { + /** The type of object - `list` */ + type?: "list"; + /** An array containing Segment Objects */ + data?: Intercom.Segment[]; +} + +/** + * This will return a list of companies for the App. + */ +export interface CompanyList { + /** The type of object - `list`. */ + type?: "list"; + pages?: Intercom.OffsetPages; + /** The total number of companies. */ + total_count?: number; + /** An array containing Company Objects. */ + data?: Intercom.Company[]; +} + +/** + * Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies. + */ +export interface CompanyScroll { + /** The type of object - `list` */ + type?: "list"; + data?: Intercom.Company[]; + pages?: Intercom.CursorPages; + /** The total number of companies */ + total_count?: number; + /** The scroll parameter to use in the next request to fetch the next page of results. */ + scroll_param?: string; +} + +/** + * A list of Company Objects + */ +export interface ContactAttachedCompanies { + /** The type of object */ + type?: "list"; + /** An array containing Company Objects */ + companies?: Intercom.Company[]; + /** The total number of companies associated to this contact */ + total_count?: number; + pages?: Intercom.PagesLink; +} + +/** + * An object with metadata about companies attached to a contact . Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactCompanies { + /** An array of company data objects attached to the contact. */ + data?: Intercom.CompanyData[]; + /** Url to get more company resources for this contact */ + url?: string; + /** Integer representing the total number of companies attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} + +/** + * An object containing data about the companies that a contact is associated with. + */ +export interface CompanyData { + /** The unique identifier for the company which is given by Intercom. */ + id?: string; + /** The type of the object. Always company. */ + type?: "company"; + /** The relative URL of the company. */ + url?: string; +} + +/** + * deleted contact object + */ +export interface ContactDeleted extends Intercom.ContactReference { + /** Whether the contact is deleted or not. */ + deleted?: boolean; +} + +/** + * Contacts are your users in Intercom. + */ +export interface ContactList { + /** Always list */ + type?: "list"; + /** The list of contact objects */ + data?: Intercom.Contact[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.CursorPages; +} + +/** + * An object containing location meta data about a Intercom contact. + */ +export interface ContactLocation { + /** Always location */ + type?: string; + /** The country that the contact is located in */ + country?: string; + /** The overal region that the contact is located in */ + region?: string; + /** The city that the contact is located in */ + city?: string; +} + +/** + * An object containing notes meta data about the notes that a contact has. Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactNotes { + /** This object represents the notes attached to a contact. */ + data?: Intercom.AddressableList[]; + /** Url to get more company resources for this contact */ + url?: string; + /** Int representing the total number of companyies attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} + +/** + * reference to contact object + */ +export interface ContactReference { + /** always contact */ + type?: "contact"; + /** The unique identifier for the contact which is given by Intercom. */ + id?: string; + /** The unique identifier for the contact which is provided by the Client. */ + external_id?: string; +} + +export interface ContactReplyBaseRequest { + message_type: "comment"; + type: "user"; + /** The text body of the comment. */ + body: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; + /** The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. */ + reply_options?: ContactReplyBaseRequest.ReplyOptions.Item[]; +} + +export namespace ContactReplyBaseRequest { + export type ReplyOptions = ReplyOptions.Item[]; + + export namespace ReplyOptions { + export interface Item { + /** The text of the chosen reply option. */ + text: string; + /** The unique identifier for the quick reply option selected. */ + uuid: string; + } + } +} + +export type ContactReplyConversationRequest = + | Intercom.ContactReplyIntercomUserIdRequest + | Intercom.ContactReplyEmailRequest + | Intercom.ContactReplyUserIdRequest; + +/** + * Payload of the request to reply on behalf of a contact using their `email` + */ +export interface ContactReplyEmailRequest extends Intercom.ContactReplyBaseRequest { + /** The email you have defined for the user. */ + email: string; + /** A list of files that will be added as attachments. */ + attachment_files?: Intercom.ConversationAttachmentFiles[]; +} + +/** + * Payload of the request to reply on behalf of a contact using their `intercom_user_id` + */ +export interface ContactReplyIntercomUserIdRequest extends Intercom.ContactReplyBaseRequest { + /** The identifier for the contact as given by Intercom. */ + intercom_user_id: string; + /** A list of files that will be added as attachments. */ + attachment_files?: Intercom.ConversationAttachmentFiles[]; +} + +/** + * Payload of the request to reply on behalf of a contact using their `email` + */ +export interface ContactReplyTicketEmailRequest extends Intercom.ContactReplyBaseRequest { + /** The email you have defined for the user. */ + email: string; +} + +/** + * Payload of the request to reply on behalf of a contact using their `intercom_user_id` + */ +export interface ContactReplyTicketIntercomUserIdRequest extends Intercom.ContactReplyBaseRequest { + /** The identifier for the contact as given by Intercom. */ + intercom_user_id: string; +} + +export type ContactReplyTicketRequest = + | Intercom.ContactReplyTicketIntercomUserIdRequest + | Intercom.ContactReplyTicketUserIdRequest + | Intercom.ContactReplyTicketEmailRequest; + +/** + * Payload of the request to reply on behalf of a contact using their `user_id` + */ +export interface ContactReplyTicketUserIdRequest extends Intercom.ContactReplyBaseRequest { + /** The external_id you have defined for the contact. */ + user_id: string; +} + +/** + * Payload of the request to reply on behalf of a contact using their `user_id` + */ +export interface ContactReplyUserIdRequest extends Intercom.ContactReplyBaseRequest { + /** The external_id you have defined for the contact. */ + user_id: string; + /** A list of files that will be added as attachments. You can include up to 10 files. */ + attachment_files?: Intercom.ConversationAttachmentFiles[]; +} + +/** + * A list of segments objects attached to a specific contact. + */ +export interface ContactSegments { + /** The type of the object */ + type?: "list"; + /** Segment objects associated with the contact. */ + data?: Intercom.Segment[]; +} + +/** + * An object containing social profiles that a contact has. + */ +export interface ContactSocialProfiles { + /** A list of social profiles objects associated with the contact. */ + data?: Intercom.SocialProfile[]; +} + +/** + * An object containing Subscription Types meta data about the SubscriptionTypes that a contact has. + */ +export interface ContactSubscriptionTypes { + /** This object represents the subscriptions attached to a contact. */ + data?: Intercom.AddressableList[]; + /** Url to get more subscription type resources for this contact */ + url?: string; + /** Int representing the total number of subscription types attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} + +/** + * An object containing tags meta data about the tags that a contact has. Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactTags { + /** This object represents the tags attached to a contact. */ + data?: Intercom.AddressableList[]; + /** url to get more tag resources for this contact */ + url?: string; + /** Int representing the total number of tags attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} + +/** + * archived contact object + */ +export interface ContactArchived extends Intercom.ContactReference { + /** Whether the contact is archived or not. */ + archived?: boolean; +} + +/** + * unarchived contact object + */ +export interface ContactUnarchived extends Intercom.ContactReference { + /** Whether the contact is archived or not. */ + archived?: boolean; +} + +/** + * blocked contact object + */ +export interface ContactBlocked extends Intercom.ContactReference { + /** Always true. */ + blocked?: boolean; +} + +export interface ContentSourcesList { + type?: "content_source.list"; + /** The total number of content sources used by AI Agent in the conversation. */ + total_count?: number; + /** The content sources used by AI Agent in the conversation. */ + content_sources?: Intercom.ContentSource[]; +} + +/** + * Properties of the attachment files in a conversation part + */ +export interface ConversationAttachmentFiles { + /** The content type of the file */ + content_type?: string; + /** The base64 encoded file data. */ + data?: string; + /** The name of the file. */ + name?: string; +} + +/** + * The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. + */ +export interface ConversationContacts { + /** */ + type?: "contact.list"; + /** The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. */ + contacts?: Intercom.ContactReference[]; +} + +/** + * deleted conversation object + */ +export interface ConversationDeleted { + /** The unique identifier for the conversation. */ + id?: string; + /** always conversation */ + object?: "conversation"; + /** Whether the conversation is deleted or not. */ + deleted?: boolean; +} + +/** + * An object containing information on the first users message. For a contact initiated message this will represent the users original message. + */ +export interface ConversationFirstContactReply { + /** */ + created_at?: number; + /** */ + type?: string; + /** */ + url?: string; +} + +/** + * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. + */ +export interface ConversationList { + /** Always conversation.list */ + type?: "conversation.list"; + /** The list of conversation objects */ + conversations?: Intercom.ConversationListItem[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.CursorPages; +} + +/** + * A Conversation Part represents a message in the conversation. + */ +export interface ConversationPart { + /** Always conversation_part */ + type: string; + /** The id representing the conversation part. */ + id: string; + /** The type of conversation part. */ + part_type: string; + /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ + body?: string; + /** The time the conversation part was created. */ + created_at: number; + /** The last time the conversation part was updated. */ + updated_at: number; + /** The time the user was notified with the conversation part. */ + notified_at?: number; + /** The assignee this conversation_part assigned the conversation to, as a reference whose `type` is `admin`, `team` or `bot`. When the part unassigned the conversation, `type` is `nobody_admin` and `id` is `null`. Null when the part did not change the assignment, or when the assignee has since been deleted. */ + assigned_to?: Intercom.Reference; + author: Intercom.ConversationPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.PartAttachment[]; + /** The external id of the conversation part */ + external_id?: string; + /** Whether or not the conversation part has been redacted. */ + redacted: boolean; + email_message_metadata?: Intercom.EmailMessageMetadata; + metadata?: Intercom.ConversationPartMetadata; + /** Indicates the current state of conversation when the conversation part was created. */ + state?: ConversationPart.State; + /** A list of tags objects associated with the conversation part. */ + tags?: Intercom.TagBasic[]; + event_details?: Intercom.EventDetails; + /** The app package code if this part was created via API. null if the part was not created via API. */ + app_package_code?: string; +} + +export namespace ConversationPart { + /** Indicates the current state of conversation when the conversation part was created. */ + export const State = { + Open: "open", + Closed: "closed", + Snoozed: "snoozed", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * The object who initiated the conversation, which can be a Contact, Admin or Team. Bots and campaigns send messages on behalf of Admins or Teams. For Twitter, this will be blank. + */ +export interface ConversationPartAuthor { + /** The type of the author */ + type: string; + /** The id of the author */ + id: string; + /** The name of the author */ + name?: string; + /** The email of the author */ + email?: string; + /** If this conversation part was sent by the AI Agent */ + from_ai_agent?: boolean; + /** If this conversation part body was generated by the AI Agent */ + is_ai_answer?: boolean; +} + +/** + * A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. + */ +export interface ConversationParts { + /** */ + type?: "conversation_part.list"; + /** A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. */ + conversation_parts?: Intercom.ConversationPart[]; + /** */ + total_count?: number; +} + +/** + * Metadata for a conversation part + */ +export interface ConversationPartMetadata { + /** The quick reply options sent by the Admin or bot, presented in this conversation part. */ + quick_reply_options?: ConversationPartMetadata.QuickReplyOptions.Item[]; + /** The unique identifier for the quick reply option that was clicked by the end user. */ + quick_reply_uuid?: string; +} + +export namespace ConversationPartMetadata { + export type QuickReplyOptions = QuickReplyOptions.Item[]; + + export namespace QuickReplyOptions { + export interface Item extends Intercom.QuickReplyOption { + /** The translations for the quick reply option. */ + translations?: Record; + } + } +} + +/** + * The Conversation Rating object which contains information on the rating and/or remark added by a Contact and the Admin assigned to the conversation. + */ +export interface ConversationRating { + /** The rating, between 1 and 5, for the conversation. */ + rating: number; + /** An optional field to add a remark to correspond to the number rating */ + remark?: string; + /** The time the rating was requested in the conversation being rated. */ + created_at: number; + /** The time the rating was last updated. */ + updated_at?: number; + contact?: Intercom.ContactReference; + teammate?: Intercom.Reference; +} + +/** + * Details of first response time of assigned team in seconds. + */ +export interface ConversationResponseTime { + /** Id of the assigned team. */ + team_id?: number; + /** Name of the assigned Team, null if team does not exist, Unassigned if no team is assigned. */ + team_name?: string; + /** First response time of assigned team in seconds. */ + response_time?: number; +} + +/** + * The type of the conversation part that started this conversation. Can be Contact, Admin, Campaign, Automated or Operator initiated. + */ +export interface ConversationSource { + /** This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ + type: ConversationSource.Type; + /** The id representing the message. */ + id: string; + /** The conversation's initiation type. Possible values are customer_initiated, campaigns_initiated (legacy campaigns), operator_initiated (Custom bot), automated (Series and other outbounds with dynamic audience message) and admin_initiated (fixed audience message, ticket initiated by an admin, group email). */ + delivered_as: string; + /** Optional. The message subject. For Twitter, this will show a generic message regarding why the subject is obscured. */ + subject?: string; + /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ + body?: string; + author: Intercom.ConversationPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.PartAttachment[]; + /** The URL where the conversation was started. For Twitter, Email, and Bots, this will be blank. */ + url?: string; + /** Whether or not the source message has been redacted. Only applicable for contact initiated messages. */ + redacted: boolean; +} + +export namespace ConversationSource { + /** This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ + export const Type = { + Conversation: "conversation", + Email: "email", + Facebook: "facebook", + Instagram: "instagram", + PhoneCall: "phone_call", + PhoneSwitch: "phone_switch", + Push: "push", + Sms: "sms", + Twitter: "twitter", + Whatsapp: "whatsapp", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * A Statistics object containing all information required for reporting, with timestamps and calculated metrics. + */ +export interface ConversationStatistics { + /** */ + type?: string; + /** Duration until last assignment before first admin reply. In seconds. */ + time_to_assignment?: number; + /** Duration until first admin reply. Subtracts out of business hours. In seconds. */ + time_to_admin_reply?: number; + /** Duration until conversation was closed first time. Subtracts out of business hours. In seconds. */ + time_to_first_close?: number; + /** Duration until conversation was closed last time. Subtracts out of business hours. In seconds. */ + time_to_last_close?: number; + /** Median based on all admin replies after a contact reply. Subtracts out of business hours. In seconds. */ + median_time_to_reply?: number; + /** Time of first text conversation part from a contact. */ + first_contact_reply_at?: number; + /** Time of first assignment after first_contact_reply_at. */ + first_assignment_at?: number; + /** Time of first admin reply after first_contact_reply_at. */ + first_admin_reply_at?: number; + /** Time of first close after first_contact_reply_at. */ + first_close_at?: number; + /** Time of last assignment after first_contact_reply_at. */ + last_assignment_at?: number; + /** Time of first admin reply since most recent assignment. */ + last_assignment_admin_reply_at?: number; + /** Time of the last conversation part from a contact. */ + last_contact_reply_at?: number; + /** Time of the last conversation part from an admin. */ + last_admin_reply_at?: number; + /** Time of the last conversation close. */ + last_close_at?: number; + /** The last admin who closed the conversation. Returns a reference to an Admin object. */ + last_closed_by_id?: string; + /** Number of reopens after first_contact_reply_at. */ + count_reopens?: number; + /** Number of assignments after first_contact_reply_at. */ + count_assignments?: number; + /** Total number of conversation parts. */ + count_conversation_parts?: number; + /** An array of conversation response time objects */ + assigned_team_first_response_time?: Intercom.ConversationResponseTime[]; + /** An array of conversation response time objects within office hours */ + assigned_team_first_response_time_in_office_hours?: Intercom.ConversationResponseTime[]; + /** Time from conversation assignment to conversation close in seconds. */ + handling_time?: number; + /** Adjusted handling time for conversation in seconds. This is the active handling time excluding idle periods when teammates are not actively working on the conversation. */ + adjusted_handling_time?: number; +} + +/** + * The list of teammates who participated in the conversation (wrote at least one conversation part). + */ +export interface ConversationTeammates { + /** The type of the object - `admin.list`. */ + type: "admin.list"; + /** The list of teammates who participated in the conversation (wrote at least one conversation part). */ + admins: Intercom.Reference[]; +} + +/** + * You can create an Article + */ +export interface CreateArticleRequest { + /** The title of the article.For multilingual articles, this will be the title of the default language's content. */ + title: string; + /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ + description?: string; + /** The content of the article. For multilingual articles, this will be the body of the default language's content. */ + body?: string; + /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ + author_id: number; + /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ + state?: CreateArticleRequest.State; + /** The id of the article's parent collection or section. An article without this field stands alone. */ + parent_id?: number; + /** The type of parent, which can either be a `collection` or `section`. */ + parent_type?: CreateArticleRequest.ParentType; + translated_content?: Intercom.ArticleTranslatedContent; +} + +export namespace CreateArticleRequest { + /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ + export const State = { + Published: "published", + Draft: "draft", + } as const; + export type State = (typeof State)[keyof typeof State]; + /** The type of parent, which can either be a `collection` or `section`. */ + export const ParentType = { + Collection: "collection", + Section: "section", + } as const; + export type ParentType = (typeof ParentType)[keyof typeof ParentType]; +} + +/** + * You can create an Internal Article + */ +export interface CreateInternalArticleRequest { + /** The title of the article. */ + title: string; + /** The content of the article. */ + body?: string; + /** The id of the author of the article. */ + author_id: number; + /** The id of the owner of the article. */ + owner_id: number; +} + +/** + * Payload to create a contact + */ +export type CreateContactRequest = + | { + email: string; + phone?: string | undefined; + name?: string | undefined; + avatar?: string | undefined; + signed_up_at?: number | undefined; + last_seen_at?: number | undefined; + owner_id?: number | undefined; + unsubscribed_from_emails?: boolean | undefined; + custom_attributes?: Record | undefined; + } + | { + external_id: string; + phone?: string | undefined; + name?: string | undefined; + avatar?: string | undefined; + signed_up_at?: number | undefined; + last_seen_at?: number | undefined; + owner_id?: number | undefined; + unsubscribed_from_emails?: boolean | undefined; + custom_attributes?: Record | undefined; + } + | { + role: string; + phone?: string | undefined; + name?: string | undefined; + avatar?: string | undefined; + signed_up_at?: number | undefined; + last_seen_at?: number | undefined; + owner_id?: number | undefined; + unsubscribed_from_emails?: boolean | undefined; + custom_attributes?: Record | undefined; + }; + +/** + * + */ +export type CreateDataAttributeRequest = + | { + data_type?: "options" | undefined; + options: { + value?: string | undefined; + }[]; + } + | { + data_type?: ("string" | "integer" | "float" | "boolean" | "datetime" | "date") | undefined; + }; + +/** + * + */ +export type CreateDataEventRequest = + | { + id: string; + event_name: string; + created_at: number; + metadata?: Record | undefined; + } + | { + user_id: string; + event_name: string; + created_at: number; + metadata?: Record | undefined; + } + | { + email: string; + event_name: string; + created_at: number; + metadata?: Record | undefined; + }; + +/** + * You can create a message + */ +export type CreateMessageRequest = Intercom.CreateMessageRequest.Email | Intercom.CreateMessageRequest.Inapp; + +export namespace CreateMessageRequest { + export interface Email { + message_type: "email"; + /** The title of the email. */ + subject: string; + /** The content of the message. HTML and plaintext are supported. */ + body: string; + /** The style of the outgoing message. Possible values `plain` or `personal`. */ + template: string; + /** The sender of the message. If not provided, the default sender will be used. */ + from: CreateMessageRequestWithEmail.From; + /** The sender of the message. If not provided, the default sender will be used. */ + to: CreateMessageRequestWithEmail.To; + /** The time the message was created. If not provided, the current time will be used. */ + created_at?: number; + /** Whether a conversation should be opened in the inbox for the message without the contact replying. Defaults to false if not provided. */ + create_conversation_without_contact_reply?: boolean; + } + + export namespace CreateMessageRequestWithEmail { + /** + * The sender of the message. If not provided, the default sender will be used. + */ + export interface From { + /** Always `admin`. */ + type: "admin"; + /** The identifier for the admin which is given by Intercom. */ + id: number; + } + + /** + * The sender of the message. If not provided, the default sender will be used. + */ + export interface To { + /** The role associated to the contact - `user` or `lead`. */ + type: To.Type; + /** The identifier for the contact which is given by Intercom. */ + id: string; + } + + export namespace To { + /** The role associated to the contact - `user` or `lead`. */ + export const Type = { + User: "user", + Lead: "lead", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } + + export interface Inapp { + message_type: "inapp"; + /** The title of the email. */ + subject?: string; + /** The content of the message. HTML and plaintext are supported. */ + body: string; + /** The style of the outgoing message. Possible values `plain` or `personal`. */ + template?: string; + /** The sender of the message. If not provided, the default sender will be used. */ + from: CreateMessageRequestWithInapp.From; + /** The sender of the message. If not provided, the default sender will be used. */ + to: CreateMessageRequestWithInapp.To; + /** The time the message was created. If not provided, the current time will be used. */ + created_at?: number; + /** Whether a conversation should be opened in the inbox for the message without the contact replying. Defaults to false if not provided. */ + create_conversation_without_contact_reply?: boolean; + } + + export namespace CreateMessageRequestWithInapp { + /** + * The sender of the message. If not provided, the default sender will be used. + */ + export interface From { + /** Always `admin`. */ + type: "admin"; + /** The identifier for the admin which is given by Intercom. */ + id: number; + } + + /** + * The sender of the message. If not provided, the default sender will be used. + */ + export interface To { + /** The role associated to the contact - `user` or `lead`. */ + type: To.Type; + /** The identifier for the contact which is given by Intercom. */ + id: string; + } + + export namespace To { + /** The role associated to the contact - `user` or `lead`. */ + export const Type = { + User: "user", + Lead: "lead", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + } + } +} + +/** + * A recipient of a message + */ +export interface Recipient { + /** The role associated to the contact - `user` or `lead`. */ + type: Recipient.Type; + /** The identifier for the contact which is given by Intercom. */ + id: string; +} + +export namespace Recipient { + /** The role associated to the contact - `user` or `lead`. */ + export const Type = { + User: "user", + Lead: "lead", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * You can create or update a Company + */ +export interface CreateOrUpdateCompanyRequest { + /** The name of the Company */ + name?: string; + /** The company id you have defined for the company. Can't be updated */ + company_id?: string; + /** The name of the plan you have associated with the company. */ + plan?: string; + /** The number of employees in this company. */ + size?: number; + /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ + website?: string; + /** The industry that this company operates in. */ + industry?: string; + /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ + custom_attributes?: Record; + /** The time the company was created by you. */ + remote_created_at?: number; + /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ + monthly_spend?: number; +} + +/** + * You can update a Company + */ +export interface UpdateCompanyRequestBody { + /** The name of the Company */ + name?: string; + /** The name of the plan you have associated with the company. */ + plan?: string; + /** The number of employees in this company. */ + size?: number; + /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ + website?: string; + /** The industry that this company operates in. */ + industry?: string; + /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ + custom_attributes?: Record; + /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ + monthly_spend?: number; +} + +/** + * You can create or update an existing tag. + */ +export interface CreateOrUpdateTagRequest { + /** The name of the tag, which will be created if not found, or the new name for the tag if this is an update request. Names are case insensitive. */ + name: string; + /** The id of tag to updates. */ + id?: string; +} + +/** + * You can create an phone switch + */ +export interface CreatePhoneSwitchRequest { + /** Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. */ + phone: string; + custom_attributes?: Intercom.CustomAttributes; +} + +export type CreateTicketReplyWithCommentRequest = Intercom.ContactReplyTicketRequest | Intercom.AdminReplyTicketRequest; + +/** + * You can create a Ticket + */ +export interface CreateTicketRequestBody { + /** The ID of the type of ticket you want to create */ + ticket_type_id: string; + /** The list of contacts (users or leads) affected by this ticket. Currently only one is allowed */ + contacts: CreateTicketRequestBody.Contacts.Item[]; + /** + * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: + * - conversation | back-office ticket + * - customer tickets | non-shared back-office ticket + * - conversation | tracker ticket + * - customer ticket | tracker ticket + */ + conversation_to_link_id?: string; + /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom */ + company_id?: string; + /** The time the ticket was created. If not provided, the current time will be used. */ + created_at?: number; + assignment?: CreateTicketRequestBody.Assignment; +} + +export namespace CreateTicketRequestBody { + export type Contacts = Contacts.Item[]; + + export namespace Contacts { + export type Item = + | { + id: string; + } + | { + external_id: string; + } + | { + email: string; + }; + } + + export interface Assignment { + /** The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. */ + admin_assignee_id?: string; + /** The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned. */ + team_assignee_id?: string; + } +} + +/** + * The request payload for creating a ticket type. + * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) + */ +export interface CreateTicketTypeRequest { + /** The name of the ticket type. */ + name: string; + /** The description of the ticket type. */ + description?: string; + /** Category of the Ticket Type. */ + category?: CreateTicketTypeRequest.Category; + /** The icon of the ticket type. */ + icon?: string; + /** Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute. */ + is_internal?: boolean; +} + +export namespace CreateTicketTypeRequest { + /** Category of the Ticket Type. */ + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; +} + +/** + * Cursor-based pagination is a technique used in the Intercom API to navigate through large amounts of data. + * A "cursor" or pointer is used to keep track of the current position in the result set, allowing the API to return the data in small chunks or "pages" as needed. + */ +export interface CursorPages { + /** the type of object `pages`. */ + type?: "pages"; + /** The current page */ + page?: number; + next?: Intercom.StartingAfterPaging; + /** Number of results per page */ + per_page?: number; + /** Total number of pages */ + total_pages?: number; +} + +/** + * A paginated list of calls. + */ +export interface CallList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of calls. */ + data?: Intercom.Call[]; + /** Total number of items available. */ + total_count?: number; + pages?: Intercom.CursorPages; +} + +/** + * Custom data set for this data. + */ +export type CustomAttributes = Record; + +export namespace CustomAttributes { + export type Value = string | number | Intercom.Datetime | Intercom.CustomObjectInstanceList; +} + +/** + * deleted custom object instance object + */ +export interface CustomObjectInstanceDeleted { + /** The unique identifier of the Custom Object type that defines the structure of the Custom Object instance. */ + object?: string; + /** The Intercom defined id representing the Custom Object instance. */ + id?: string; + /** Whether the Custom Object instance is deleted or not. */ + deleted?: boolean; +} + +/** + * The list of associated custom object instances for a given reference attribute on the parent object. + */ +export interface CustomObjectInstanceList { + type?: string; + /** The list of associated custom object instances for a given reference attribute on the parent object. */ + instances?: (Intercom.CustomObjectInstance | undefined)[]; +} + +export type CustomerRequest = + | { + intercom_user_id: string; + } + | { + user_id: string; + } + | { + email: string; + }; + +/** + * A list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ +export interface DataAttributeList { + /** The type of the object */ + type?: "list"; + /** A list of data attributes */ + data?: Intercom.DataAttribute[]; +} + +/** + * This will return a list of data events for the App. + */ +export interface DataEventList { + /** The type of the object */ + type?: "event.list"; + /** A list of data events */ + events?: Intercom.DataEvent[]; + /** Pagination */ + pages?: DataEventList.Pages; +} + +export namespace DataEventList { + /** + * Pagination + */ + export interface Pages { + next?: string; + since?: string; + } +} + +/** + * This will return a summary of data events for the App. + */ +export interface DataEventSummary { + /** The type of the object */ + type?: "event.summary"; + /** The email address of the user */ + email?: string; + /** The Intercom user ID of the user */ + intercom_user_id?: string; + /** The user ID of the user */ + user_id?: string; + /** A summary of data events */ + events: (Intercom.DataEventSummaryItem | undefined)[]; +} + +/** + * This will return a summary of a data event for the App. + */ +export interface DataEventSummaryItem { + /** The name of the event */ + name?: string; + /** The first time the event was sent */ + first?: string; + /** The last time the event was sent */ + last?: string; + /** The number of times the event was sent */ + count?: number; + /** The description of the event */ + description?: string; +} + +/** + * A CSV output file + */ +export interface DataExportCsv { + /** The user_id of the user who was sent the message. */ + user_id?: string; + /** The external_user_id of the user who was sent the message */ + user_external_id?: string; + /** The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. */ + company_id?: string; + /** The users email who was sent the message. */ + email?: string; + /** The full name of the user receiving the message */ + name?: string; + /** The id of the message. */ + ruleset_id?: string; + /** The specific content that was received. In an A/B test each version has its own Content ID. */ + content_id?: string; + /** Email, Chat, Post etc. */ + content_type?: string; + /** The title of the content you see in your Intercom workspace. */ + content_title?: string; + /** As you edit content we record new versions. This ID can help you determine which version of a piece of content that was received. */ + ruleset_version_id?: string; + /** ID for this receipt. Will be included with any related stats in other files to identify this specific delivery of a message. */ + receipt_id?: string; + /** Timestamp for when the receipt was recorded. */ + received_at?: number; + /** The id of the series that this content is part of. Will return -1 if not part of a series. */ + series_id?: string; + /** The title of the series that this content is part of. */ + series_title?: string; + /** The id of the series node that this ruleset is associated with. Each block in a series has a corresponding node_id. */ + node_id?: string; + /** The first time a user replied to this message if the content was able to receive replies. Only events within the export job's requested date range are counted. */ + first_reply?: number; + /** The first time a user completed this message if the content was able to be completed e.g. Tours, Surveys. Only events within the export job's requested date range are counted. */ + first_completion?: number; + /** The first time the series this message was a part of was completed by the user. Only events within the export job's requested date range are counted. */ + first_series_completion?: number; + /** The first time the series this message was a part of was disengaged by the user. Only events within the export job's requested date range are counted. */ + first_series_disengagement?: number; + /** The first time the series this message was a part of was exited by the user. Only events within the export job's requested date range are counted. */ + first_series_exit?: number; + /** The first time the user met this messages associated goal if one exists. Only events within the export job's requested date range are counted. */ + first_goal_success?: number; + /** The first time the user opened this message. Only events within the export job's requested date range are counted. */ + first_open?: number; + /** The first time the series the user clicked on a link within this message. Only events within the export job's requested date range are counted. */ + first_click?: number; + /** The first time the series the user dismissed this message. Only events within the export job's requested date range are counted. */ + first_dismisall?: number; + /** The first time the user unsubscribed from this message. Only events within the export job's requested date range are counted. */ + first_unsubscribe?: number; + /** The first time this message hard bounced for this user. Only events within the export job's requested date range are counted. */ + first_hard_bounce?: number; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedArticleObject { + /** The unique identifier for the article which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - article */ + object?: "article"; + /** Whether the article was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedInternalArticleObject { + /** The unique identifier for the internal article which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - internal_article */ + object?: "internal_article"; + /** Whether the internal article was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedCollectionObject { + /** The unique identifier for the collection which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - `collection` */ + object?: "collection"; + /** Whether the collection was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedCompanyObject { + /** The unique identifier for the company which is given by Intercom. */ + id?: string; + /** The type of object which was deleted. - `company` */ + object?: "company"; + /** Whether the company was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedObject { + /** The unique identifier for the news item which you provided in the URL. */ + id?: string; + /** The type of object which was deleted - news-item. */ + object?: "news-item"; + /** Whether the news item was deleted successfully or not. */ + deleted?: boolean; +} + +/** + * Contains data for an email address header for a conversation part that was sent as an email. + */ +export interface EmailAddressHeader { + /** The type of email address header */ + type?: string; + /** The email address */ + email_address?: string; + /** The name associated with the email address */ + name?: string; +} + +/** + * Contains metadata if the message was sent as an email + */ +export interface EmailMessageMetadata { + /** The subject of the email */ + subject?: string; + /** A list of an email address headers. */ + email_address_headers?: Intercom.EmailAddressHeader[]; +} + +export type Metadata = Intercom.preview.ConversationPartMetadata; + +/** + * Contains details about the workflow that was triggered and any Custom Data Attributes (CDAs) that were modified during the workflow execution for conversation part type conversation_attribute_updated_by_workflow. + */ +export interface ConversationAttributeUpdatedByWorkflow { + workflow?: ConversationAttributeUpdatedByWorkflow.Workflow; + attribute?: ConversationAttributeUpdatedByWorkflow.Attribute; + value?: ConversationAttributeUpdatedByWorkflow.Value; +} + +export namespace ConversationAttributeUpdatedByWorkflow { + export interface Workflow { + /** Name of the workflow */ + name?: string; + } + + export interface Attribute { + /** Name of the CDA updated */ + name?: string; + } + + export interface Value { + /** Value of the CDA updated */ + name?: string; + } +} + +/** + * Contains details about Custom Data Attributes (CDAs) that were modified by an admin (operator) for conversation part type conversation_attribute_updated_by_admin. + */ +export interface ConversationAttributeUpdatedByAdmin { + attribute?: ConversationAttributeUpdatedByAdmin.Attribute; + value?: ConversationAttributeUpdatedByAdmin.Value; +} + +export namespace ConversationAttributeUpdatedByAdmin { + export interface Attribute { + /** Name of the CDA updated */ + name?: string; + } + + export interface Value { + /** Value of the CDA updated */ + name?: string; + } +} + +/** + * Contains details about name of the action that was initiated for conversation part type custom_action_started. + */ +export interface CustomActionStarted { + action?: CustomActionStarted.Action; +} + +export namespace CustomActionStarted { + export interface Action { + /** Name of the action */ + name?: string; + } +} + +/** + * Contains details about final status of the completed action for conversation part type custom_action_finished. + */ +export interface CustomActionFinished { + action?: CustomActionFinished.Action; +} + +export namespace CustomActionFinished { + export interface Action { + /** Name of the action */ + name?: string; + /** Status of the action */ + result?: Action.Result; + } + + export namespace Action { + /** Status of the action */ + export const Result = { + Success: "success", + Failed: "failed", + } as const; + export type Result = (typeof Result)[keyof typeof Result]; + } +} + +/** + * Contains details about name of the workflow for conversation part type operator_workflow_event. + */ +export interface OperatorWorkflowEvent { + workflow?: OperatorWorkflowEvent.Workflow; + event?: OperatorWorkflowEvent.Event; +} + +export namespace OperatorWorkflowEvent { + export interface Workflow { + /** The name of the workflow */ + name?: string; + } + + export interface Event { + /** Type of the workflow event initiated */ + type?: string; + /** Result of the workflow event */ + result?: string; + } +} + +export type EventDetails = + | Intercom.ConversationAttributeUpdatedByWorkflow + | Intercom.ConversationAttributeUpdatedByAdmin + | Intercom.CustomActionStarted + | Intercom.CustomActionFinished + | Intercom.OperatorWorkflowEvent; + +/** + * The API will return an Error List for a failed request, which will contain one or more Error objects. + */ +export interface Error_ { + /** The type is error.list */ + type: "error.list"; + /** */ + request_id?: string; + /** An array of one or more error objects */ + errors: Error_.Errors.Item[]; +} + +export namespace Error_ { + export type Errors = Errors.Item[]; + + export namespace Errors { + export interface Item { + /** A string indicating the kind of error, used to further qualify the HTTP response code */ + code: string; + /** Optional. Human readable description of the error. */ + message?: string; + /** Optional. Used to identify a particular field or query parameter that was in error. */ + field?: string; + } + } +} + +/** + * The value describing a file upload set for a custom attribute + */ +export interface FileAttribute { + type?: string; + /** The name of the file */ + name?: string; + /** The url of the file. This is a temporary URL and will expire after 30 minutes. */ + url?: string; + /** The type of file */ + content_type?: string; + /** The size of the file in bytes */ + filesize?: number; + /** The width of the file in pixels, if applicable */ + width?: number; + /** The height of the file in pixels, if applicable */ + height?: number; +} + +/** + * The Content of a Group. + */ +export interface GroupContent { + /** The type of object - `group_content` . */ + type?: "group_content"; + /** The name of the collection or section. */ + name?: string; + /** The description of the collection. Only available for collections. */ + description?: string; +} + +/** + * The Translated Content of an Group. The keys are the locale codes and the values are the translated content of the Group. + */ +export interface GroupTranslatedContent { + /** The type of object - group_translated_content. */ + type?: "group_translated_content"; + /** The content of the group in Arabic */ + ar?: Intercom.GroupContent; + /** The content of the group in Bulgarian */ + bg?: Intercom.GroupContent; + /** The content of the group in Bosnian */ + bs?: Intercom.GroupContent; + /** The content of the group in Catalan */ + ca?: Intercom.GroupContent; + /** The content of the group in Czech */ + cs?: Intercom.GroupContent; + /** The content of the group in Danish */ + da?: Intercom.GroupContent; + /** The content of the group in German */ + de?: Intercom.GroupContent; + /** The content of the group in Greek */ + el?: Intercom.GroupContent; + /** The content of the group in English */ + en?: Intercom.GroupContent; + /** The content of the group in Spanish */ + es?: Intercom.GroupContent; + /** The content of the group in Estonian */ + et?: Intercom.GroupContent; + /** The content of the group in Finnish */ + fi?: Intercom.GroupContent; + /** The content of the group in French */ + fr?: Intercom.GroupContent; + /** The content of the group in Hebrew */ + he?: Intercom.GroupContent; + /** The content of the group in Croatian */ + hr?: Intercom.GroupContent; + /** The content of the group in Hungarian */ + hu?: Intercom.GroupContent; + /** The content of the group in Indonesian */ + id?: Intercom.GroupContent; + /** The content of the group in Italian */ + it?: Intercom.GroupContent; + /** The content of the group in Japanese */ + ja?: Intercom.GroupContent; + /** The content of the group in Korean */ + ko?: Intercom.GroupContent; + /** The content of the group in Lithuanian */ + lt?: Intercom.GroupContent; + /** The content of the group in Latvian */ + lv?: Intercom.GroupContent; + /** The content of the group in Mongolian */ + mn?: Intercom.GroupContent; + /** The content of the group in Norwegian */ + nb?: Intercom.GroupContent; + /** The content of the group in Dutch */ + nl?: Intercom.GroupContent; + /** The content of the group in Polish */ + pl?: Intercom.GroupContent; + /** The content of the group in Portuguese (Portugal) */ + pt?: Intercom.GroupContent; + /** The content of the group in Romanian */ + ro?: Intercom.GroupContent; + /** The content of the group in Russian */ + ru?: Intercom.GroupContent; + /** The content of the group in Slovenian */ + sl?: Intercom.GroupContent; + /** The content of the group in Serbian */ + sr?: Intercom.GroupContent; + /** The content of the group in Swedish */ + sv?: Intercom.GroupContent; + /** The content of the group in Turkish */ + tr?: Intercom.GroupContent; + /** The content of the group in Vietnamese */ + vi?: Intercom.GroupContent; + /** The content of the group in Portuguese (Brazil) */ + "pt-BR"?: Intercom.GroupContent; + /** The content of the group in Chinese (China) */ + "zh-CN"?: Intercom.GroupContent; + /** The content of the group in Chinese (Taiwan) */ + "zh-TW"?: Intercom.GroupContent; +} + +/** + * IP allowlist settings for the workspace. + */ +export interface IpAllowlist { + /** String representing the object's type. Always has the value `ip_allowlist`. */ + type?: string; + /** Whether the IP allowlist is enabled for the workspace. */ + enabled?: boolean; + /** + * List of allowed IP addresses and/or IP ranges in CIDR notation. + * Examples: + * - Single IP: `192.168.0.1` + * - IP range: `192.168.0.1/24` (allows 192.168.0.0 - 192.168.0.255) + */ + ip_allowlist?: string[]; +} + +/** + * A linked conversation or ticket. + */ +export interface LinkedObject { + /** ticket or conversation */ + type: LinkedObject.Type; + /** The ID of the linked object */ + id: string; + /** Category of the Linked Ticket Object. */ + category?: LinkedObject.Category; +} + +export namespace LinkedObject { + /** ticket or conversation */ + export const Type = { + Ticket: "ticket", + Conversation: "conversation", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + /** Category of the Linked Ticket Object. */ + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + export type Category = (typeof Category)[keyof typeof Category]; +} + +/** + * An object containing metadata about linked conversations and linked tickets. Up to 1000 can be returned. + */ +export interface LinkedObjectList { + /** Always list. */ + type?: "list"; + /** The total number of linked objects. */ + total_count?: number; + /** Whether or not there are more linked objects than returned. */ + has_more?: boolean; + /** An array containing the linked conversations and linked tickets. */ + data?: Intercom.LinkedObject[]; +} + +export interface WhatsappMessageStatusList { + type: "list"; + /** The provided ruleset ID */ + ruleset_id: string; + pages: WhatsappMessageStatusList.Pages; + /** Total number of events */ + total_count: number; + events: WhatsappMessageStatusList.Events.Item[]; +} + +export namespace WhatsappMessageStatusList { + export interface Pages { + type: "pages"; + /** Number of results per page */ + per_page: number; + /** Total number of pages */ + total_pages: number; + /** Information for fetching next page (null if no more pages) */ + next?: Pages.Next; + } + + export namespace Pages { + /** + * Information for fetching next page (null if no more pages) + */ + export interface Next { + /** Cursor for the next page */ + starting_after?: string; + } + } + + export type Events = Events.Item[]; + + export namespace Events { + export interface Item { + /** Event ID */ + id: string; + /** ID of the conversation */ + conversation_id: string; + /** Current status of the message */ + status: Item.Status; + /** Event type */ + type: "broadcast_outbound"; + /** Creation timestamp */ + created_at: number; + /** Last update timestamp */ + updated_at: number; + /** WhatsApp's message identifier */ + whatsapp_message_id: string; + /** Name of the WhatsApp template used */ + template_name?: string; + } + + export namespace Item { + /** Current status of the message */ + export const Status = { + Sent: "sent", + Delivered: "delivered", + Read: "read", + Failed: "failed", + } as const; + export type Status = (typeof Status)[keyof typeof Status]; + } + } +} + +/** + * Search using Intercoms Search APIs with more than one filter. + */ +export interface MultipleFilterSearchRequest { + /** An operator to allow boolean inspection between multiple fields. */ + operator?: MultipleFilterSearchRequest.Operator; + value?: MultipleFilterSearchRequest.Value; +} + +export namespace MultipleFilterSearchRequest { + /** An operator to allow boolean inspection between multiple fields. */ + export const Operator = { + And: "AND", + Or: "OR", + } as const; + export type Operator = (typeof Operator)[keyof typeof Operator]; + export type Value = + /** + * Add mutiple filters. */ + | Intercom.MultipleFilterSearchRequest[] + /** + * Add a single filter field. */ + | Intercom.SingleFilterSearchRequest[]; +} + +/** + * A News Item is a content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers. + */ +export interface NewsItemRequest { + /** The title of the news item. */ + title: string; + /** The news item body, which may contain HTML. */ + body?: string; + /** The id of the sender of the news item. Must be a teammate on the workspace. */ + sender_id: number; + /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ + state?: NewsItemRequest.State; + /** When set to `true`, the news item will appear in the messenger newsfeed without showing a notification badge. */ + deliver_silently?: boolean; + /** Label names displayed to users to categorize the news item. */ + labels?: string[]; + /** Ordered list of emoji reactions to the news item. When empty, reactions are disabled. */ + reactions?: (string | undefined)[]; + /** A list of newsfeed_assignments to assign to the specified newsfeed. */ + newsfeed_assignments?: Intercom.NewsfeedAssignment[]; +} + +export namespace NewsItemRequest { + /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ + export const State = { + Draft: "draft", + Live: "live", + } as const; + export type State = (typeof State)[keyof typeof State]; +} + +/** + * A paginated list of notes associated with a contact. + */ +export interface NoteList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** An array of notes. */ + data?: Intercom.Note[]; + /** A count of the total number of notes. */ + total_count?: number; +} + +/** + * Payload of the request to open a conversation + */ +export interface OpenConversationRequest { + /** The id of the admin who is performing the action. */ + admin_id: string; +} + +/** + * The majority of list resources in the API are paginated to allow clients to traverse data over multiple requests. + * + * Their responses are likely to contain a pages object that hosts pagination links which a client can use to paginate through the data without having to construct a query. The link relations for the pages field are as follows. + */ +export interface PagesLink { + type?: "pages"; + page?: number; + /** A link to the next page of results. A response that does not contain a next link does not have further data to fetch. */ + next?: string; + per_page?: number; + total_pages?: number; +} + +export type PaginatedResponseDataItem = + | Intercom.PaginatedResponseDataItem.NewsItem + | Intercom.PaginatedResponseDataItem.Newsfeed; + +export namespace PaginatedResponseDataItem { + export interface NewsItem extends Intercom.NewsItem { + type: "news-item"; + } + + export interface Newsfeed extends Intercom.Newsfeed { + type: "newsfeed"; + } +} + +/** + * Paginated Response + */ +export interface PaginatedResponse { + /** The type of object */ + type?: PaginatedResponse.Type; + pages?: Intercom.CursorPages; + /** A count of the total number of objects. */ + total_count?: number; + /** An array of Objects */ + data?: Intercom.PaginatedResponseDataItem[]; +} + +export namespace PaginatedResponse { + /** The type of object */ + export const Type = { + List: "list", + ConversationList: "conversation.list", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * The file attached to a part + */ +export interface PartAttachment { + /** The type of attachment */ + type: string; + /** The name of the attachment */ + name: string; + /** The URL of the attachment */ + url: string; + /** The content type of the attachment */ + content_type?: string; + /** The size of the attachment */ + filesize?: number; + /** The width of the attachment */ + width?: number; + /** The height of the attachment */ + height?: number; +} + +/** + * Phone Switch Response + */ +export interface PhoneSwitch { + /** */ + type?: "phone_call_redirect"; + /** Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. */ + phone?: string; +} + +export interface QuickReplyOption { + /** The text to display in this quick reply option. */ + text: string; + /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment conversation part that is created when a user clicks on this reply option. */ + uuid: string; +} + +export type RedactConversationRequest = + /** + * Payload of the request to redact a conversation part */ + | Intercom.RedactConversationRequest.ConversationPart + /** + * Payload of the request to redact a conversation source */ + | Intercom.RedactConversationRequest.Source; + +export namespace RedactConversationRequest { + export interface ConversationPart { + type: "conversation_part"; + /** The id of the conversation. */ + conversation_id: string; + /** The id of the conversation_part. */ + conversation_part_id: string; + } + + export interface Source { + type: "source"; + /** The id of the conversation. */ + conversation_id: string; + /** The id of the source. */ + source_id: string; + } +} + +/** + * reference to another object + */ +export interface Reference { + /** */ + type?: string; + /** */ + id?: string; +} + +export type ReplyConversationRequest = + | Intercom.ContactReplyConversationRequest + | Intercom.AdminReplyConversationRequest; + +/** + * Search using Intercoms Search APIs. + */ +export interface SearchRequest { + query: SearchRequest.Query; + pagination?: Intercom.StartingAfterPaging; +} + +export namespace SearchRequest { + export type Query = Intercom.SingleFilterSearchRequest | Intercom.MultipleFilterSearchRequest; +} + +/** + * This will return a list of Segment Objects. The result may also have a pages object if the response is paginated. + */ +export interface SegmentList { + /** The type of the object */ + type?: "segment.list"; + /** A list of Segment objects */ + segments?: Intercom.Segment[]; + /** A pagination object, which may be empty, indicating no further pages to fetch. */ + pages?: Record; +} + +/** + * Search using Intercoms Search APIs with a single filter. + */ +export interface SingleFilterSearchRequest { + /** The accepted field that you want to search on. */ + field?: string; + /** + * The accepted operators you can use to define how you want to search for the value. Operator support depends on the field's data type. The breakdown below is for Contacts search; the other search endpoints that share this schema accept a different set per field: + * - `string` fields: `=`, `!=`, `IN`, `NIN`, `~`, `!~`, `^`, `$` + * - `tag_id`: `=` and `!=` only. Every other operator returns an error. + * - `boolean` fields: `=`, `!=`, `IN`, `NIN` + * - `integer` fields: `=`, `!=`, `IN`, `NIN`, `<`, `>`, `<=`, `>=` + * - `date` fields (all standard timestamp attributes and date custom attributes): `=`, `<`, `>` only. `!=`, `<=`, `>=`, `IN`, and `NIN` are not supported and return an error. + */ + operator?: SingleFilterSearchRequest.Operator; + /** The value that you want to search on. */ + value?: SingleFilterSearchRequest.Value; +} + +export namespace SingleFilterSearchRequest { + /** + * The accepted operators you can use to define how you want to search for the value. Operator support depends on the field's data type. The breakdown below is for Contacts search; the other search endpoints that share this schema accept a different set per field: + * - `string` fields: `=`, `!=`, `IN`, `NIN`, `~`, `!~`, `^`, `$` + * - `tag_id`: `=` and `!=` only. Every other operator returns an error. + * - `boolean` fields: `=`, `!=`, `IN`, `NIN` + * - `integer` fields: `=`, `!=`, `IN`, `NIN`, `<`, `>`, `<=`, `>=` + * - `date` fields (all standard timestamp attributes and date custom attributes): `=`, `<`, `>` only. `!=`, `<=`, `>=`, `IN`, and `NIN` are not supported and return an error. + */ + export const Operator = { + Equals: "=", + NotEquals: "!=", + In: "IN", + NotIn: "NIN", + LessThan: "<", + LessThanOrEqualTo: "<=", + GreaterThan: ">", + GreaterThanOrEqualTo: ">=", + Contains: "~", + DoesNotContain: "!~", + StartsWith: "^", + EndsWith: "$", + } as const; + export type Operator = (typeof Operator)[keyof typeof Operator]; + /** + * The value that you want to search on. + */ + export type Value = string | number | boolean | (string | number)[]; +} + +/** + * The SLA Applied object contains the details for which SLA has been applied to this conversation. + * Important: if there are any canceled sla_events for the conversation - meaning an SLA has been manually removed from a conversation, the sla_status will always be returned as null. + */ +export interface SlaApplied { + /** object type */ + type?: string; + /** The name of the SLA as given by the teammate when it was created. */ + sla_name?: string; + /** + * SLA statuses: + * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. + * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. + * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. + */ + sla_status?: SlaApplied.SlaStatus; +} + +export namespace SlaApplied { + /** + * SLA statuses: + * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. + * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. + * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. + */ + export const SlaStatus = { + Hit: "hit", + Missed: "missed", + Cancelled: "cancelled", + Active: "active", + } as const; + export type SlaStatus = (typeof SlaStatus)[keyof typeof SlaStatus]; +} + +/** + * Payload of the request to snooze a conversation + */ +export interface SnoozeConversationRequest { + /** The id of the admin who is performing the action. */ + admin_id: string; + /** The time you want the conversation to reopen. */ + snoozed_until: number; +} + +/** + * A Social Profile allows you to label your contacts, companies, and conversations and list them using that Social Profile. + */ +export interface SocialProfile { + /** value is "social_profile" */ + type?: "social_profile"; + /** The name of the Social media profile */ + name?: string; + /** The name of the Social media profile */ + url?: string; +} + +export interface StartingAfterPaging { + /** The number of results to fetch per page. */ + per_page?: number; + /** The cursor to use in the next request to get the next page of results. */ + starting_after?: string; +} + +/** + * A list of subscription type objects. + */ +export interface SubscriptionTypeList { + /** The type of the object */ + type?: "list"; + /** A list of subscription type objects associated with the workspace . */ + data?: Intercom.SubscriptionType[]; +} + +/** + * You can tag a single company or a list of companies. + */ +export interface TagCompanyRequest { + /** The name of the tag, which will be created if not found. */ + name: string; + /** The id or company_id of the company can be passed as input parameters. */ + companies: TagCompanyRequest.Companies.Item[]; +} + +export namespace TagCompanyRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom defined id representing the company. */ + id?: string; + /** The company id you have defined for the company. */ + company_id?: string; + } + } +} + +/** + * A list of tags objects in the workspace. + */ +export interface TagList { + /** The type of the object */ + type?: "list"; + /** A list of tags objects associated with the workspace . */ + data?: Intercom.Tag[]; +} + +/** + * You can tag a list of users. + */ +export interface TagMultipleUsersRequest { + /** The name of the tag, which will be created if not found. */ + name: string; + users: TagMultipleUsersRequest.Users.Item[]; +} + +export namespace TagMultipleUsersRequest { + export type Users = Users.Item[]; + + export namespace Users { + export interface Item { + /** The Intercom defined id representing the user. */ + id?: string; + } + } +} + +/** + * A list of tags objects associated with a conversation + */ +export interface Tags { + /** The type of the object */ + type?: "tag.list"; + /** A list of tags objects associated with the conversation. */ + tags?: Intercom.Tag[]; +} + +/** + * This will return a list of team objects for the App. + */ +export interface TeamList { + /** The type of the object */ + type?: "team.list"; + /** A list of team objects */ + teams?: Intercom.Team[]; +} + +/** + * Admin priority levels for teams + */ +export interface TeamPriorityLevel { + /** The primary team ids for the team */ + primary_team_ids?: number[]; + /** The secondary team ids for the team */ + secondary_team_ids?: number[]; +} + +/** + * deleted ticket object + */ +export interface TicketDeleted { + /** The unique identifier for the ticket. */ + id?: string; + /** always ticket */ + object?: "ticket"; + /** Whether the ticket is deleted or not. */ + deleted?: boolean; +} + +/** + * An object containing the different attributes associated to the ticket as key-value pairs. For the default title and description attributes, the keys are `_default_title_` and `_default_description_`. + */ +export type TicketCustomAttributes = Record; + +/** + * Tickets are how you track requests from your users. + */ +export interface TicketList { + /** Always ticket.list */ + type?: "ticket.list"; + /** The list of ticket objects */ + tickets?: (Intercom.Ticket | undefined)[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.CursorPages; +} + +/** + * The author that wrote or triggered the part. Can be a bot, admin, team or user. + */ +export interface TicketPartAuthor { + /** The type of the author */ + type: TicketPartAuthor.Type; + /** The id of the author */ + id: string; + /** The name of the author */ + name?: string; + /** The email of the author */ + email?: string; +} + +export namespace TicketPartAuthor { + /** The type of the author */ + export const Type = { + Admin: "admin", + Bot: "bot", + Team: "team", + User: "user", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} + +/** + * A list of Ticket Part objects for each note and event in the ticket. There is a limit of 500 parts. + */ +export interface TicketParts { + /** */ + type?: "ticket_part.list"; + /** A list of Ticket Part objects for each ticket. There is a limit of 500 parts. */ + ticket_parts?: Intercom.TicketPart[]; + /** */ + total_count?: number; +} + +/** + * A Ticket Part representing a note, comment, or quick_reply on a ticket + */ +export interface TicketReply { + /** Always ticket_part */ + type?: "ticket_part"; + /** The id representing the part. */ + id?: string; + /** Type of the part */ + part_type?: TicketReply.PartType; + /** The message body, which may contain HTML. */ + body?: string; + /** The time the note was created. */ + created_at?: number; + /** The last time the note was updated. */ + updated_at?: number; + author?: Intercom.TicketPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.PartAttachment[]; + /** Whether or not the ticket part has been redacted. */ + redacted?: boolean; +} + +export namespace TicketReply { + /** Type of the part */ + export const PartType = { + Note: "note", + Comment: "comment", + QuickReply: "quick_reply", + } as const; + export type PartType = (typeof PartType)[keyof typeof PartType]; +} + +/** + * The attributes set on the ticket. When setting the default title and description attributes, the attribute keys that should be used are `_default_title_` and `_default_description_`. When setting ticket type attributes of the list attribute type, the key should be the attribute name and the value of the attribute should be the list item id, obtainable by [listing the ticket type](ref:get_ticket-types). For example, if the ticket type has an attribute called `priority` of type `list`, the key should be `priority` and the value of the attribute should be the guid of the list item (e.g. `de1825a0-0164-4070-8ca6-13e22462fa7e`). + */ +export type TicketRequestCustomAttributes = Record; + +/** + * A list of ticket states associated with a given ticket type. + */ +export interface TicketStateList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket states associated with a given ticket type. */ + data?: (Intercom.TicketStateDetailed | undefined)[]; +} + +/** + * Ticket type attribute, used to define each data field to be captured in a ticket. + */ +export interface TicketTypeAttribute { + /** String representing the object's type. Always has the value `ticket_type_attribute`. */ + type?: string; + /** The id representing the ticket type attribute. */ + id?: string; + /** The id of the workspace that the ticket type attribute belongs to. */ + workspace_id?: string; + /** The name of the ticket type attribute */ + name?: string; + /** The description of the ticket type attribute */ + description?: string; + /** The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ + data_type?: TicketTypeAttribute.DataType; + /** Input options for the attribute */ + input_options?: Record; + /** The order of the attribute against other attributes */ + order?: number; + /** Whether the attribute is required or not for teammates. */ + required_to_create?: boolean; + /** Whether the attribute is required or not for contacts. */ + required_to_create_for_contacts?: boolean; + /** Whether the attribute is visible or not to teammates. */ + visible_on_create?: boolean; + /** Whether the attribute is visible or not to contacts. */ + visible_to_contacts?: boolean; + /** Whether the attribute is built in or not. */ + default?: boolean; + /** The id of the ticket type that the attribute belongs to. */ + ticket_type_id?: number; + /** Whether the ticket type attribute is archived or not. */ + archived?: boolean; + /** The date and time the ticket type attribute was created. */ + created_at?: number; + /** The date and time the ticket type attribute was last updated. */ + updated_at?: number; +} + +export namespace TicketTypeAttribute { + /** The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ + export const DataType = { + String: "string", + List: "list", + Integer: "integer", + Decimal: "decimal", + Boolean: "boolean", + Datetime: "datetime", + Files: "files", + } as const; + export type DataType = (typeof DataType)[keyof typeof DataType]; +} + +/** + * A list of attributes associated with a given ticket type. + */ +export interface TicketTypeAttributeList { + /** String representing the object's type. Always has the value `ticket_type_attributes.list`. */ + type?: string; + /** A list of ticket type attributes associated with a given ticket type. */ + ticket_type_attributes?: (Intercom.TicketTypeAttribute | undefined)[]; +} + +/** + * A list of ticket types associated with a given workspace. + */ +export interface TicketTypeList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket_types associated with a given workspace. */ + data?: (Intercom.TicketType | undefined)[]; +} + +/** + * A translation object contains the localised details of a subscription type. + */ +export interface Translation { + /** The localised name of the subscription type. */ + name?: string; + /** The localised description of the subscription type. */ + description?: string; + /** The two character identifier for the language of the translation object. */ + locale?: string; +} + +/** + * You can tag a single company or a list of companies. + */ +export interface UntagCompanyRequest { + /** The name of the tag which will be untagged from the company */ + name: string; + /** The id or company_id of the company can be passed as input parameters. */ + companies: UntagCompanyRequest.Companies.Item[]; +} + +export namespace UntagCompanyRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom defined id representing the company. */ + id?: string; + /** The company id you have defined for the company. */ + company_id?: string; + /** Always set to true */ + untag?: boolean; + } + } +} + +/** + * + */ +export type UpdateDataAttributeRequestBody = + | { + options: { + value?: string | undefined; + }[]; + } + | unknown; + +/** + * You can update a Ticket + */ +export interface UpdateTicketRequestBody { + /** The attributes set on the ticket. */ + ticket_attributes?: Record; + /** The ID of the ticket state associated with the ticket type. */ + ticket_state_id?: string; + /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. */ + company_id?: string; + /** Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. */ + open?: boolean; + /** Specify whether the ticket is visible to users. */ + is_shared?: boolean; + /** The time you want the ticket to reopen. */ + snoozed_until?: number; + /** The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. */ + admin_id?: number; + /** The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. */ + assignee_id?: string; +} + +/** + * Update an existing visitor. + */ +export type UpdateVisitorRequest = + | { + id: string; + name?: string | undefined; + custom_attributes?: Record | undefined; + } + | { + user_id: string; + name?: string | undefined; + custom_attributes?: Record | undefined; + }; + +/** + * Visitors are useful for representing anonymous people that have not yet been identified. They usually represent website visitors. Visitors are not visible in Intercom platform. The Visitors resource provides methods to fetch, update, convert and delete. + */ +export interface Visitor { + /** Value is 'visitor' */ + type: "visitor"; + /** The Intercom defined id representing the Visitor. */ + id: string; + /** Automatically generated identifier for the Visitor. */ + user_id: string; + /** Identifies if this visitor is anonymous. */ + anonymous?: boolean; + /** The email of the visitor. */ + email?: string; + /** The phone number of the visitor. */ + phone?: string; + /** The name of the visitor. */ + name?: string; + /** The pseudonym of the visitor. */ + pseudonym?: string; + avatar?: Visitor.Avatar; + /** The id of the app the visitor is associated with. */ + app_id?: string; + companies?: Visitor.Companies; + location_data?: Visitor.LocationData; + /** The time the Lead last recorded making a request. */ + las_request_at?: number; + /** The time the Visitor was added to Intercom. */ + created_at?: number; + /** The time the Visitor was added to Intercom. */ + remote_created_at?: number; + /** The time the Visitor signed up for your product. */ + signed_up_at?: number; + /** The last time the Visitor was updated. */ + updated_at?: number; + /** The number of sessions the Visitor has had. */ + session_count?: number; + social_profiles?: Visitor.SocialProfiles; + /** The id of the admin that owns the Visitor. */ + owner_id?: string; + /** Whether the Visitor is unsubscribed from emails. */ + unsubscribed_from_emails?: boolean; + /** Identifies if this visitor has marked an email as spam. */ + marked_email_as_spam?: boolean; + /** Identifies if this visitor has had a hard bounce. */ + has_hard_bounced?: boolean; + tags?: Visitor.Tags; + segments?: Visitor.Segments; + /** The custom attributes you have set on the Visitor. */ + custom_attributes?: Record; + /** The referer of the visitor. */ + referrer?: string; + /** The utm_campaign of the visitor. */ + utm_campaign?: string; + /** The utm_content of the visitor. */ + utm_content?: string; + /** The utm_medium of the visitor. */ + utm_medium?: string; + /** The utm_source of the visitor. */ + utm_source?: string; + /** The utm_term of the visitor. */ + utm_term?: string; + /** Identifies if this visitor has do not track enabled. */ + do_not_track?: boolean; +} + +export namespace Visitor { + export interface Avatar { + /** */ + type?: string; + /** This object represents the avatar associated with the visitor. */ + image_url?: string; + } + + export interface Companies { + /** The type of the object */ + type?: "company.list"; + companies?: Intercom.Company[]; + } + + export interface LocationData { + /** */ + type?: string; + /** The city name of the visitor. */ + city_name?: string; + /** The continent code of the visitor. */ + continent_code?: string; + /** The country code of the visitor. */ + country_code?: string; + /** The country name of the visitor. */ + country_name?: string; + /** The postal code of the visitor. */ + postal_code?: string; + /** The region name of the visitor. */ + region_name?: string; + /** The timezone of the visitor. */ + timezone?: string; + } + + export interface SocialProfiles { + /** The type of the object */ + type?: "social_profile.list"; + social_profiles?: string[]; + } + + export interface Tags { + /** The type of the object */ + type?: "tag.list"; + tags?: Tags.Tags.Item[]; + } + + export namespace Tags { + export type Tags = Tags.Item[]; + + export namespace Tags { + export interface Item { + /** The type of the object */ + type?: "tag"; + /** The id of the tag. */ + id?: string; + /** The name of the tag. */ + name?: string; + } + } + } + + export interface Segments { + /** The type of the object */ + type?: "segment.list"; + segments?: string[]; + } +} + +/** + * Response returned when an object is deleted + */ +export interface VisitorDeletedObject { + /** The unique identifier for the visitor which is given by Intercom. */ + id?: string; + /** The type of object which was deleted */ + type?: "visitor"; + /** Automatically generated identifier for the Visitor. */ + user_id?: string; +} + +export interface UpdateArticleRequestBody { + parent_type?: UpdateArticleRequestBody.ParentType; +} + +export namespace UpdateArticleRequestBody { + export const ParentType = { + Collection: "collection", + Section: "section", + } as const; + export type ParentType = (typeof ParentType)[keyof typeof ParentType]; +} + +export interface OffsetPages { + /** the type of object `offset_pages` */ + type: "offset_pages"; + /** The current offset */ + page?: number; + next?: string; + /** Number of results per page */ + per_page?: number; + /** Total number of pages */ + total_pages?: number; +} + +export type CreateContactRequestTwo = unknown; + +export type CreateDataEventRequestTwo = unknown; + +export type UpdateVisitorRequestOne = unknown; diff --git a/src/api/version.ts b/src/api/version.ts index 54e211cb..b3c8bff4 100644 --- a/src/api/version.ts +++ b/src/api/version.ts @@ -22,4 +22,4 @@ export type IntercomVersion = | "2.12" | "2.13" | "2.14" - | "Unstable"; + | "Preview"; diff --git a/src/core/exports.ts b/src/core/exports.ts index d2774491..c21f0569 100644 --- a/src/core/exports.ts +++ b/src/core/exports.ts @@ -1,2 +1,3 @@ +export * from "./file/exports.js"; export * from "./logging/exports.js"; export * from "./pagination/exports.js"; diff --git a/src/core/file/exports.ts b/src/core/file/exports.ts new file mode 100644 index 00000000..3b0b3967 --- /dev/null +++ b/src/core/file/exports.ts @@ -0,0 +1 @@ +export type { Uploadable } from "./types.js"; diff --git a/src/core/file/file.ts b/src/core/file/file.ts new file mode 100644 index 00000000..0bacc484 --- /dev/null +++ b/src/core/file/file.ts @@ -0,0 +1,217 @@ +import type { Uploadable } from "./types.js"; + +export async function toBinaryUploadRequest( + file: Uploadable, +): Promise<{ body: Uploadable.FileLike; headers?: Record }> { + const { data, filename, contentLength, contentType } = await getFileWithMetadata(file); + const request = { + body: data, + headers: {} as Record, + }; + if (filename) { + request.headers["Content-Disposition"] = `attachment; filename="${filename}"`; + } + if (contentType) { + request.headers["Content-Type"] = contentType; + } + if (contentLength != null) { + request.headers["Content-Length"] = contentLength.toString(); + } + return request; +} + +export async function toMultipartDataPart( + file: Uploadable, +): Promise<{ data: Uploadable.FileLike; filename?: string; contentType?: string }> { + const { data, filename, contentType } = await getFileWithMetadata(file, { + noSniffFileSize: true, + }); + return { + data, + filename, + contentType, + }; +} + +async function getFileWithMetadata( + file: Uploadable, + { noSniffFileSize }: { noSniffFileSize?: boolean } = {}, +): Promise { + if (isFileLike(file)) { + return getFileWithMetadata( + { + data: file, + }, + { noSniffFileSize }, + ); + } + + if ("path" in file) { + const fs = await import("fs"); + if (!fs || !fs.createReadStream) { + throw new Error("File path uploads are not supported in this environment."); + } + const data = fs.createReadStream(file.path); + const contentLength = + file.contentLength ?? (noSniffFileSize === true ? undefined : await tryGetFileSizeFromPath(file.path)); + const filename = file.filename ?? getNameFromPath(file.path); + return { + data, + filename, + contentType: file.contentType, + contentLength, + }; + } + if ("data" in file) { + const data = file.data; + const contentLength = + file.contentLength ?? + (await tryGetContentLengthFromFileLike(data, { + noSniffFileSize, + })); + const filename = file.filename ?? tryGetNameFromFileLike(data); + return { + data, + filename, + contentType: file.contentType ?? tryGetContentTypeFromFileLike(data), + contentLength, + }; + } + + throw new Error(`Invalid FileUpload of type ${typeof file}: ${JSON.stringify(file)}`); +} + +function isFileLike(value: unknown): value is Uploadable.FileLike { + return ( + isBuffer(value) || + isArrayBufferView(value) || + isArrayBuffer(value) || + isUint8Array(value) || + isBlob(value) || + isFile(value) || + isStreamLike(value) || + isReadableStream(value) + ); +} + +async function tryGetFileSizeFromPath(path: string): Promise { + try { + const fs = await import("fs"); + if (!fs || !fs.promises || !fs.promises.stat) { + return undefined; + } + const fileStat = await fs.promises.stat(path); + return fileStat.size; + } catch (_fallbackError) { + return undefined; + } +} + +function tryGetNameFromFileLike(data: Uploadable.FileLike): string | undefined { + if (isNamedValue(data)) { + return data.name; + } + if (isPathedValue(data)) { + return getNameFromPath(data.path.toString()); + } + return undefined; +} + +async function tryGetContentLengthFromFileLike( + data: Uploadable.FileLike, + { noSniffFileSize }: { noSniffFileSize?: boolean } = {}, +): Promise { + if (isBuffer(data)) { + return data.length; + } + if (isArrayBufferView(data)) { + return data.byteLength; + } + if (isArrayBuffer(data)) { + return data.byteLength; + } + if (isBlob(data)) { + return data.size; + } + if (isFile(data)) { + return data.size; + } + if (noSniffFileSize === true) { + return undefined; + } + if (isPathedValue(data)) { + return await tryGetFileSizeFromPath(data.path.toString()); + } + return undefined; +} + +function tryGetContentTypeFromFileLike(data: Uploadable.FileLike): string | undefined { + if (isBlob(data)) { + return data.type; + } + if (isFile(data)) { + return data.type; + } + + return undefined; +} + +function getNameFromPath(path: string): string | undefined { + const lastForwardSlash = path.lastIndexOf("/"); + const lastBackSlash = path.lastIndexOf("\\"); + const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash); + return lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path; +} + +type NamedValue = { + name: string; +} & unknown; + +type PathedValue = { + path: string | { toString(): string }; +} & unknown; + +type StreamLike = { + read?: () => unknown; + pipe?: (dest: unknown) => unknown; +} & unknown; + +function isNamedValue(value: unknown): value is NamedValue { + return typeof value === "object" && value != null && "name" in value; +} + +function isPathedValue(value: unknown): value is PathedValue { + return typeof value === "object" && value != null && "path" in value; +} + +function isStreamLike(value: unknown): value is StreamLike { + return typeof value === "object" && value != null && ("read" in value || "pipe" in value); +} + +function isReadableStream(value: unknown): value is ReadableStream { + return typeof value === "object" && value != null && "getReader" in value; +} + +function isBuffer(value: unknown): value is Buffer { + return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value); +} + +function isArrayBufferView(value: unknown): value is ArrayBufferView { + return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(value); +} + +function isArrayBuffer(value: unknown): value is ArrayBuffer { + return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer; +} + +function isUint8Array(value: unknown): value is Uint8Array { + return typeof Uint8Array !== "undefined" && value instanceof Uint8Array; +} + +function isBlob(value: unknown): value is Blob { + return typeof Blob !== "undefined" && value instanceof Blob; +} + +function isFile(value: unknown): value is File { + return typeof File !== "undefined" && value instanceof File; +} diff --git a/src/core/file/index.ts b/src/core/file/index.ts new file mode 100644 index 00000000..fc16dd52 --- /dev/null +++ b/src/core/file/index.ts @@ -0,0 +1,2 @@ +export * from "./file.js"; +export * from "./types.js"; diff --git a/src/core/file/types.ts b/src/core/file/types.ts new file mode 100644 index 00000000..531b6927 --- /dev/null +++ b/src/core/file/types.ts @@ -0,0 +1,81 @@ +/** + * A file that can be uploaded. Can be a file-like object (stream, buffer, blob, etc.), + * a path to a file, or an object with a file-like object and metadata. + */ +export type Uploadable = Uploadable.FileLike | Uploadable.FromPath | Uploadable.WithMetadata; + +export namespace Uploadable { + /** + * Various file-like objects that can be used to upload a file. + */ + export type FileLike = + | ArrayBuffer + | ArrayBufferLike + | ArrayBufferView + | Uint8Array + | import("buffer").Buffer + | import("buffer").Blob + | import("buffer").File + | import("stream").Readable + | import("stream/web").ReadableStream + | globalThis.Blob + | globalThis.File + | ReadableStream; + + /** + * A file path with optional metadata, used for uploading a file from the file system. + */ + export type FromPath = { + /** The path to the file to upload */ + path: string; + /** + * Optional override for the file name (defaults to basename of path). + * This is used to set the `Content-Disposition` header in upload requests. + */ + filename?: string; + /** + * Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain'). + * This is used to set the `Content-Type` header in upload requests. + */ + contentType?: string; + /** + * Optional file size in bytes. + * If not provided, the file size will be determined from the file system. + * The content length is used to set the `Content-Length` header in upload requests. + */ + contentLength?: number; + }; + + /** + * A file-like object with metadata, used for uploading files. + */ + export type WithMetadata = { + /** The file data */ + data: FileLike; + /** + * Optional override for the file name (defaults to basename of path). + * This is used to set the `Content-Disposition` header in upload requests. + */ + filename?: string; + /** + * Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain'). + * This is used to set the `Content-Type` header in upload requests. + * + * If not provided, the content type may be determined from the data itself. + * * If the data is a `File`, `Blob`, or similar, the content type will be determined from the file itself, if the type is set. + * * Any other data type will not have a content type set, and the upload request will use `Content-Type: application/octet-stream` instead. + */ + contentType?: string; + /** + * Optional file size in bytes. + * The content length is used to set the `Content-Length` header in upload requests. + * If the content length is not provided and cannot be determined, the upload request will not include the `Content-Length` header, but will use `Transfer-Encoding: chunked` instead. + * + * If not provided, the file size will be determined depending on the data type. + * * If the data is of type `fs.ReadStream` (`createReadStream`), the size will be determined from the file system. + * * If the data is a `Buffer`, `ArrayBuffer`, `Uint8Array`, `Blob`, `File`, or similar, the size will be determined from the data itself. + * * If the data is a `Readable` or `ReadableStream`, the size will not be determined. + */ + contentLength?: number; + }; +} diff --git a/src/core/form-data-utils/FormDataWrapper.ts b/src/core/form-data-utils/FormDataWrapper.ts new file mode 100644 index 00000000..bea0cf82 --- /dev/null +++ b/src/core/form-data-utils/FormDataWrapper.ts @@ -0,0 +1,140 @@ +import { toMultipartDataPart, type Uploadable } from "../../core/file/index.js"; +import { toJson } from "../../core/json.js"; +import { RUNTIME } from "../runtime/index.js"; + +interface FormDataRequest { + body: Body; + headers: Record; + duplex?: "half"; +} + +export async function newFormData(): Promise { + return new FormDataWrapper(); +} + +export class FormDataWrapper { + private fd: FormData = new FormData(); + + public async setup(): Promise { + // noop + } + + public append(key: string, value: unknown): void { + this.fd.append(key, String(value)); + } + + public async appendFile(key: string, value: Uploadable): Promise { + const { data, filename, contentType } = await toMultipartDataPart(value); + const blob = await convertToBlob(data, contentType); + if (filename) { + this.fd.append(key, blob, filename); + } else { + this.fd.append(key, blob); + } + } + + public getRequest(): FormDataRequest { + return { + body: this.fd, + headers: {}, + duplex: "half" as const, + }; + } +} + +type StreamLike = { + read?: () => unknown; + pipe?: (dest: unknown) => unknown; +} & unknown; + +function isStreamLike(value: unknown): value is StreamLike { + return typeof value === "object" && value != null && ("read" in value || "pipe" in value); +} + +function isReadableStream(value: unknown): value is ReadableStream { + return typeof value === "object" && value != null && "getReader" in value; +} + +function isBuffer(value: unknown): value is Buffer { + return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value); +} + +function isArrayBufferView(value: unknown): value is ArrayBufferView { + return ArrayBuffer.isView(value); +} + +async function streamToBuffer(stream: unknown): Promise { + if (RUNTIME.type === "node") { + const { Readable } = await import("stream"); + + if (stream instanceof Readable) { + const chunks: Buffer[] = []; + for await (const chunk of stream) { + chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); + } + return Buffer.concat(chunks); + } + } + + if (isReadableStream(stream)) { + const reader = stream.getReader(); + const chunks: Uint8Array[] = []; + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + chunks.push(value); + } + } finally { + reader.releaseLock(); + } + + const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + + return Buffer.from(result); + } + + throw new Error( + `Unsupported stream type: ${typeof stream}. Expected Node.js Readable stream or Web ReadableStream.`, + ); +} + +async function convertToBlob(value: unknown, contentType?: string): Promise { + if (isStreamLike(value) || isReadableStream(value)) { + const buffer = await streamToBuffer(value); + return new Blob([buffer], { type: contentType }); + } + + if (value instanceof Blob) { + return value; + } + + if (isBuffer(value)) { + return new Blob([value], { type: contentType }); + } + + if (value instanceof ArrayBuffer) { + return new Blob([value], { type: contentType }); + } + + if (isArrayBufferView(value)) { + return new Blob([value], { type: contentType }); + } + + if (typeof value === "string") { + return new Blob([value], { type: contentType }); + } + + if (typeof value === "object" && value !== null) { + return new Blob([toJson(value)], { type: contentType ?? "application/json" }); + } + + return new Blob([String(value)], { type: contentType }); +} diff --git a/src/core/form-data-utils/encodeAsFormParameter.ts b/src/core/form-data-utils/encodeAsFormParameter.ts new file mode 100644 index 00000000..cfc67413 --- /dev/null +++ b/src/core/form-data-utils/encodeAsFormParameter.ts @@ -0,0 +1,12 @@ +import { toQueryString } from "../url/qs.js"; + +export function encodeAsFormParameter(value: unknown): Record { + const stringified = toQueryString(value, { encode: false }); + + const keyValuePairs = stringified.split("&").map((pair) => { + const [key, value] = pair.split("="); + return [key, value] as const; + }); + + return Object.fromEntries(keyValuePairs); +} diff --git a/src/core/form-data-utils/index.ts b/src/core/form-data-utils/index.ts new file mode 100644 index 00000000..1188f80c --- /dev/null +++ b/src/core/form-data-utils/index.ts @@ -0,0 +1,2 @@ +export { encodeAsFormParameter } from "./encodeAsFormParameter.js"; +export * from "./FormDataWrapper.js"; diff --git a/src/core/index.ts b/src/core/index.ts index f25662a5..7b3d0dd9 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,6 +1,8 @@ export * from "./auth/index.js"; export * from "./base64.js"; export * from "./fetcher/index.js"; +export * as file from "./file/index.js"; +export * from "./form-data-utils/index.js"; export * as logging from "./logging/index.js"; export * from "./pagination/index.js"; export * from "./runtime/index.js"; diff --git a/src/version.ts b/src/version.ts index 948f7433..55ac974e 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const SDK_VERSION = "7.0.3"; +export const SDK_VERSION = "7.0.5-beta.0"; diff --git a/tests/unit/file/file.test.ts b/tests/unit/file/file.test.ts new file mode 100644 index 00000000..d7c4570b --- /dev/null +++ b/tests/unit/file/file.test.ts @@ -0,0 +1,498 @@ +import fs from "fs"; +import { join } from "path"; +import { Readable } from "stream"; +import { toBinaryUploadRequest, type Uploadable } from "../../../src/core/file/index"; + +describe("toBinaryUploadRequest", () => { + const TEST_FILE_PATH = join(__dirname, "..", "test-file.txt"); + + beforeEach(() => { + vi.clearAllMocks(); + }); + + describe("Buffer input", () => { + it("should handle Buffer with all metadata", async () => { + const buffer = Buffer.from("test data"); + const input: Uploadable.WithMetadata = { + data: buffer, + filename: "test.txt", + contentType: "text/plain", + contentLength: 42, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(buffer); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="test.txt"', + "Content-Type": "text/plain", + "Content-Length": "42", + }); + }); + + it("should handle Buffer without metadata", async () => { + const buffer = Buffer.from("test data"); + const input: Uploadable.WithMetadata = { + data: buffer, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(buffer); + expect(result.headers).toEqual({ + "Content-Length": "9", // buffer.length + }); + }); + + it("should handle Buffer passed directly", async () => { + const buffer = Buffer.from("test data"); + + const result = await toBinaryUploadRequest(buffer); + + expect(result.body).toBe(buffer); + expect(result.headers).toEqual({ + "Content-Length": "9", // buffer.length + }); + }); + }); + + describe("ArrayBuffer input", () => { + it("should handle ArrayBuffer with metadata", async () => { + const arrayBuffer = new ArrayBuffer(10); + const input: Uploadable.WithMetadata = { + data: arrayBuffer, + filename: "data.bin", + contentType: "application/octet-stream", + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(arrayBuffer); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="data.bin"', + "Content-Type": "application/octet-stream", + "Content-Length": "10", // arrayBuffer.byteLength + }); + }); + + it("should handle ArrayBuffer passed directly", async () => { + const arrayBuffer = new ArrayBuffer(10); + + const result = await toBinaryUploadRequest(arrayBuffer); + + expect(result.body).toBe(arrayBuffer); + expect(result.headers).toEqual({ + "Content-Length": "10", // arrayBuffer.byteLength + }); + }); + }); + + describe("Uint8Array input", () => { + it("should handle Uint8Array with metadata", async () => { + const uint8Array = new Uint8Array([1, 2, 3, 4, 5]); + const input: Uploadable.WithMetadata = { + data: uint8Array, + filename: "bytes.bin", + contentType: "application/octet-stream", + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(uint8Array); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="bytes.bin"', + "Content-Type": "application/octet-stream", + "Content-Length": "5", // uint8Array.byteLength + }); + }); + + it("should handle Uint8Array passed directly", async () => { + const uint8Array = new Uint8Array([1, 2, 3, 4, 5]); + + const result = await toBinaryUploadRequest(uint8Array); + + expect(result.body).toBe(uint8Array); + expect(result.headers).toEqual({ + "Content-Length": "5", // uint8Array.byteLength + }); + }); + }); + + describe("Blob input", () => { + it("should handle Blob with metadata", async () => { + const blob = new Blob(["test content"], { type: "text/plain" }); + const input: Uploadable.WithMetadata = { + data: blob, + filename: "override.txt", + contentType: "text/html", // Override blob's type + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(blob); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="override.txt"', + "Content-Type": "text/html", // Should use provided contentType + "Content-Length": "12", // blob.size + }); + }); + + it("should handle Blob with intrinsic type", async () => { + const blob = new Blob(["test content"], { type: "application/json" }); + const input: Uploadable.WithMetadata = { + data: blob, + filename: "data.json", + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(blob); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="data.json"', + "Content-Type": "application/json", // Should use blob's type + "Content-Length": "12", // blob.size + }); + }); + + it("should handle Blob passed directly", async () => { + const blob = new Blob(["test content"], { type: "text/plain" }); + + const result = await toBinaryUploadRequest(blob); + + expect(result.body).toBe(blob); + expect(result.headers).toEqual({ + "Content-Type": "text/plain", // Should use blob's type + "Content-Length": "12", // blob.size + }); + }); + }); + + describe("File input", () => { + it("should handle File with metadata", async () => { + const file = new File(["file content"], "original.txt", { type: "text/plain" }); + const input: Uploadable.WithMetadata = { + data: file, + filename: "renamed.txt", + contentType: "text/html", // Override file's type + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(file); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="renamed.txt"', + "Content-Type": "text/html", // Should use provided contentType + "Content-Length": "12", // file.size + }); + }); + + it("should handle File with intrinsic properties", async () => { + const file = new File(["file content"], "test.json", { type: "application/json" }); + const input: Uploadable.WithMetadata = { + data: file, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(file); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="test.json"', // Should use file's name + "Content-Type": "application/json", // Should use file's type + "Content-Length": "12", // file.size + }); + }); + + it("should handle File passed directly", async () => { + const file = new File(["file content"], "direct.txt", { type: "text/plain" }); + + const result = await toBinaryUploadRequest(file); + + expect(result.body).toBe(file); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="direct.txt"', + "Content-Type": "text/plain", + "Content-Length": "12", // file.size + }); + }); + }); + + describe("ReadableStream input", () => { + it("should handle ReadableStream with metadata", async () => { + const stream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("stream data")); + controller.close(); + }, + }); + const input: Uploadable.WithMetadata = { + data: stream, + filename: "stream.txt", + contentType: "text/plain", + contentLength: 100, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(stream); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="stream.txt"', + "Content-Type": "text/plain", + "Content-Length": "100", // Should use provided contentLength + }); + }); + + it("should handle ReadableStream without size", async () => { + const stream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("stream data")); + controller.close(); + }, + }); + const input: Uploadable.WithMetadata = { + data: stream, + filename: "stream.txt", + contentType: "text/plain", + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(stream); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="stream.txt"', + "Content-Type": "text/plain", + // No Content-Length header since it cannot be determined from ReadableStream + }); + }); + + it("should handle ReadableStream passed directly", async () => { + const stream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("stream data")); + controller.close(); + }, + }); + + const result = await toBinaryUploadRequest(stream); + + expect(result.body).toBe(stream); + expect(result.headers).toEqual({ + // No headers since no metadata provided and cannot be determined + }); + }); + }); + + describe("Node.js Readable stream input", () => { + it("should handle Readable stream with metadata", async () => { + const readable = new Readable({ + read() { + this.push("readable data"); + this.push(null); + }, + }); + const input: Uploadable.WithMetadata = { + data: readable, + filename: "readable.txt", + contentType: "text/plain", + contentLength: 50, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(readable); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="readable.txt"', + "Content-Type": "text/plain", + "Content-Length": "50", // Should use provided contentLength + }); + }); + + it("should handle Readable stream without size", async () => { + const readable = new Readable({ + read() { + this.push("readable data"); + this.push(null); + }, + }); + const input: Uploadable.WithMetadata = { + data: readable, + filename: "readable.txt", + contentType: "text/plain", + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(readable); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="readable.txt"', + "Content-Type": "text/plain", + // No Content-Length header since it cannot be determined from Readable + }); + }); + + it("should handle Readable stream passed directly", async () => { + const readable = new Readable({ + read() { + this.push("readable data"); + this.push(null); + }, + }); + + const result = await toBinaryUploadRequest(readable); + + expect(result.body).toBe(readable); + expect(result.headers).toEqual({ + // No headers since no metadata provided and cannot be determined + }); + }); + }); + + describe("File path input (FromPath type)", () => { + it("should handle file path with all metadata", async () => { + const input: Uploadable.FromPath = { + path: TEST_FILE_PATH, + filename: "custom.txt", + contentType: "text/html", + contentLength: 42, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBeInstanceOf(fs.ReadStream); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="custom.txt"', + "Content-Type": "text/html", + "Content-Length": "42", // Should use provided contentLength + }); + }); + + it("should handle file path with minimal metadata", async () => { + const input: Uploadable.FromPath = { + path: TEST_FILE_PATH, + contentType: "text/plain", + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBeInstanceOf(fs.ReadStream); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="test-file.txt"', // Should extract from path + "Content-Type": "text/plain", + "Content-Length": "21", // Should determine from file system (test file is 21 bytes) + }); + }); + + it("should handle file path with no metadata", async () => { + const input: Uploadable.FromPath = { + path: TEST_FILE_PATH, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBeInstanceOf(fs.ReadStream); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="test-file.txt"', // Should extract from path + "Content-Length": "21", // Should determine from file system (test file is 21 bytes) + }); + }); + }); + + describe("ArrayBufferView input", () => { + it("should handle ArrayBufferView with metadata", async () => { + const arrayBuffer = new ArrayBuffer(10); + const arrayBufferView = new Int8Array(arrayBuffer); + const input: Uploadable.WithMetadata = { + data: arrayBufferView, + filename: "view.bin", + contentType: "application/octet-stream", + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(arrayBufferView); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="view.bin"', + "Content-Type": "application/octet-stream", + "Content-Length": "10", // arrayBufferView.byteLength + }); + }); + + it("should handle ArrayBufferView passed directly", async () => { + const arrayBuffer = new ArrayBuffer(10); + const arrayBufferView = new Int8Array(arrayBuffer); + + const result = await toBinaryUploadRequest(arrayBufferView); + + expect(result.body).toBe(arrayBufferView); + expect(result.headers).toEqual({ + "Content-Length": "10", // arrayBufferView.byteLength + }); + }); + }); + + describe("Edge cases", () => { + it("should handle empty headers when no metadata is available", async () => { + const buffer = Buffer.from(""); + const input: Uploadable.WithMetadata = { + data: buffer, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(buffer); + expect(result.headers).toEqual({ + "Content-Length": "0", + }); + }); + + it("should handle zero contentLength", async () => { + const buffer = Buffer.from("test"); + const input: Uploadable.WithMetadata = { + data: buffer, + contentLength: 0, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(buffer); + expect(result.headers).toEqual({ + "Content-Length": "0", // Should use provided 0 + }); + }); + + it("should handle null filename", async () => { + const buffer = Buffer.from("test"); + const input: Uploadable.WithMetadata = { + data: buffer, + filename: undefined, + contentType: "text/plain", + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(buffer); + expect(result.headers).toEqual({ + "Content-Type": "text/plain", + "Content-Length": "4", + // No Content-Disposition since filename is undefined + }); + }); + + it("should handle null contentType", async () => { + const buffer = Buffer.from("test"); + const input: Uploadable.WithMetadata = { + data: buffer, + filename: "test.txt", + contentType: undefined, + }; + + const result = await toBinaryUploadRequest(input); + + expect(result.body).toBe(buffer); + expect(result.headers).toEqual({ + "Content-Disposition": 'attachment; filename="test.txt"', + "Content-Length": "4", + // No Content-Type since contentType is undefined + }); + }); + }); +}); diff --git a/tests/unit/form-data-utils/encodeAsFormParameter.test.ts b/tests/unit/form-data-utils/encodeAsFormParameter.test.ts new file mode 100644 index 00000000..d4b0c450 --- /dev/null +++ b/tests/unit/form-data-utils/encodeAsFormParameter.test.ts @@ -0,0 +1,344 @@ +import { encodeAsFormParameter } from "../../../src/core/form-data-utils/encodeAsFormParameter"; + +describe("encodeAsFormParameter", () => { + describe("Basic functionality", () => { + it("should return empty object for null/undefined", () => { + expect(encodeAsFormParameter(null)).toEqual({}); + expect(encodeAsFormParameter(undefined)).toEqual({}); + }); + + it("should return empty object for primitive values", () => { + expect(encodeAsFormParameter("hello")).toEqual({}); + expect(encodeAsFormParameter(42)).toEqual({}); + expect(encodeAsFormParameter(true)).toEqual({}); + }); + + it("should handle simple key-value pairs", () => { + const obj = { name: "John", age: 30 }; + expect(encodeAsFormParameter(obj)).toEqual({ + name: "John", + age: "30", + }); + }); + + it("should handle empty objects", () => { + expect(encodeAsFormParameter({})).toEqual({}); + }); + }); + + describe("Array handling", () => { + it("should handle arrays with indices format (default)", () => { + const obj = { items: ["a", "b", "c"] }; + expect(encodeAsFormParameter(obj)).toEqual({ + "items[0]": "a", + "items[1]": "b", + "items[2]": "c", + }); + }); + + it("should handle empty arrays", () => { + const obj = { items: [] }; + expect(encodeAsFormParameter(obj)).toEqual({}); + }); + + it("should handle arrays with mixed types", () => { + const obj = { mixed: ["string", 42, true, false] }; + expect(encodeAsFormParameter(obj)).toEqual({ + "mixed[0]": "string", + "mixed[1]": "42", + "mixed[2]": "true", + "mixed[3]": "false", + }); + }); + + it("should handle arrays with objects", () => { + const obj = { users: [{ name: "John" }, { name: "Jane" }] }; + expect(encodeAsFormParameter(obj)).toEqual({ + "users[0][name]": "John", + "users[1][name]": "Jane", + }); + }); + + it("should handle arrays with null/undefined values", () => { + const obj = { items: ["a", null, "c", undefined, "e"] }; + expect(encodeAsFormParameter(obj)).toEqual({ + "items[0]": "a", + "items[1]": "", + "items[2]": "c", + "items[4]": "e", + }); + }); + }); + + describe("Nested objects", () => { + it("should handle nested objects", () => { + const obj = { user: { name: "John", age: 30 } }; + expect(encodeAsFormParameter(obj)).toEqual({ + "user[name]": "John", + "user[age]": "30", + }); + }); + + it("should handle deeply nested objects", () => { + const obj = { user: { profile: { name: "John", settings: { theme: "dark" } } } }; + expect(encodeAsFormParameter(obj)).toEqual({ + "user[profile][name]": "John", + "user[profile][settings][theme]": "dark", + }); + }); + + it("should handle empty nested objects", () => { + const obj = { user: {} }; + expect(encodeAsFormParameter(obj)).toEqual({}); + }); + }); + + describe("Special characters and encoding", () => { + it("should not encode values (encode: false is used)", () => { + const obj = { name: "John Doe", email: "john@example.com" }; + expect(encodeAsFormParameter(obj)).toEqual({ + name: "John Doe", + email: "john@example.com", + }); + }); + + it("should not encode special characters in keys", () => { + const obj = { "user name": "John", "email[primary]": "john@example.com" }; + expect(encodeAsFormParameter(obj)).toEqual({ + "user name": "John", + "email[primary]": "john@example.com", + }); + }); + + it("should handle values that contain special characters", () => { + const obj = { + query: "search term with spaces", + filter: "category:electronics", + }; + expect(encodeAsFormParameter(obj)).toEqual({ + query: "search term with spaces", + filter: "category:electronics", + }); + }); + + it("should handle ampersand and equals characters (edge case)", () => { + // Note: Values containing & and = may be problematic because + // encodeAsFormParameter splits on these characters when parsing the stringified result + const obj = { + message: "Hello & welcome", + equation: "x = y + z", + }; + // This demonstrates the limitation - ampersands and equals signs in values + // will cause the parameter to be split incorrectly + const result = encodeAsFormParameter(obj); + + // We expect this to be parsed incorrectly due to the implementation + expect(result.message).toBe("Hello "); + expect(result[" welcome"]).toBeUndefined(); + expect(result.equation).toBe("x "); + expect(result[" y + z"]).toBeUndefined(); + }); + }); + + describe("Form data specific scenarios", () => { + it("should handle file upload metadata", () => { + const metadata = { + file: { + name: "document.pdf", + size: 1024, + type: "application/pdf", + }, + options: { + compress: true, + quality: 0.8, + }, + }; + expect(encodeAsFormParameter(metadata)).toEqual({ + "file[name]": "document.pdf", + "file[size]": "1024", + "file[type]": "application/pdf", + "options[compress]": "true", + "options[quality]": "0.8", + }); + }); + + it("should handle form validation data", () => { + const formData = { + fields: ["name", "email", "phone"], + validation: { + required: ["name", "email"], + patterns: { + email: "^[^@]+@[^@]+\\.[^@]+$", + phone: "^\\+?[1-9]\\d{1,14}$", + }, + }, + }; + expect(encodeAsFormParameter(formData)).toEqual({ + "fields[0]": "name", + "fields[1]": "email", + "fields[2]": "phone", + "validation[required][0]": "name", + "validation[required][1]": "email", + "validation[patterns][email]": "^[^@]+@[^@]+\\.[^@]+$", + "validation[patterns][phone]": "^\\+?[1-9]\\d{1,14}$", + }); + }); + + it("should handle search/filter parameters", () => { + const searchParams = { + filters: { + status: ["active", "pending"], + category: { + type: "electronics", + subcategories: ["phones", "laptops"], + }, + }, + sort: { field: "name", direction: "asc" }, + pagination: { page: 1, limit: 20 }, + }; + expect(encodeAsFormParameter(searchParams)).toEqual({ + "filters[status][0]": "active", + "filters[status][1]": "pending", + "filters[category][type]": "electronics", + "filters[category][subcategories][0]": "phones", + "filters[category][subcategories][1]": "laptops", + "sort[field]": "name", + "sort[direction]": "asc", + "pagination[page]": "1", + "pagination[limit]": "20", + }); + }); + }); + + describe("Edge cases", () => { + it("should handle boolean values", () => { + const obj = { enabled: true, disabled: false }; + expect(encodeAsFormParameter(obj)).toEqual({ + enabled: "true", + disabled: "false", + }); + }); + + it("should handle empty strings", () => { + const obj = { name: "", description: "test" }; + expect(encodeAsFormParameter(obj)).toEqual({ + name: "", + description: "test", + }); + }); + + it("should handle zero values", () => { + const obj = { count: 0, price: 0.0 }; + expect(encodeAsFormParameter(obj)).toEqual({ + count: "0", + price: "0", + }); + }); + + it("should handle numeric keys", () => { + const obj = { "0": "zero", "1": "one" }; + expect(encodeAsFormParameter(obj)).toEqual({ + "0": "zero", + "1": "one", + }); + }); + + it("should handle objects with null/undefined values", () => { + const obj = { name: "John", age: null, email: undefined, active: true }; + expect(encodeAsFormParameter(obj)).toEqual({ + name: "John", + age: "", + active: "true", + }); + }); + }); + + describe("Integration with form submission", () => { + it("should produce form-compatible key-value pairs", () => { + const formObject = { + username: "john_doe", + preferences: { + theme: "dark", + notifications: ["email", "push"], + settings: { + autoSave: true, + timeout: 300, + }, + }, + }; + + const result = encodeAsFormParameter(formObject); + + // Verify all values are strings (as required for form data) + Object.values(result).forEach((value) => { + expect(typeof value).toBe("string"); + }); + + // Verify the structure can be reconstructed + expect(result).toEqual({ + username: "john_doe", + "preferences[theme]": "dark", + "preferences[notifications][0]": "email", + "preferences[notifications][1]": "push", + "preferences[settings][autoSave]": "true", + "preferences[settings][timeout]": "300", + }); + }); + + it("should handle complex nested arrays for API parameters", () => { + const apiParams = { + query: { + filters: [ + { field: "status", operator: "eq", value: "active" }, + { field: "created", operator: "gte", value: "2023-01-01" }, + ], + sort: [ + { field: "name", direction: "asc" }, + { field: "created", direction: "desc" }, + ], + }, + }; + + const result = encodeAsFormParameter(apiParams); + expect(result).toEqual({ + "query[filters][0][field]": "status", + "query[filters][0][operator]": "eq", + "query[filters][0][value]": "active", + "query[filters][1][field]": "created", + "query[filters][1][operator]": "gte", + "query[filters][1][value]": "2023-01-01", + "query[sort][0][field]": "name", + "query[sort][0][direction]": "asc", + "query[sort][1][field]": "created", + "query[sort][1][direction]": "desc", + }); + }); + }); + + describe("Error cases and malformed input", () => { + it("should handle circular references gracefully", () => { + const obj: any = { name: "test" }; + obj.self = obj; + + // This will throw a RangeError due to stack overflow - this is expected behavior + expect(() => encodeAsFormParameter(obj)).toThrow("Maximum call stack size exceeded"); + }); + + it("should handle very deeply nested objects", () => { + let deepObj: any = { value: "deep" }; + for (let i = 0; i < 100; i++) { + deepObj = { level: deepObj }; + } + + expect(() => encodeAsFormParameter(deepObj)).not.toThrow(); + const result = encodeAsFormParameter(deepObj); + expect(Object.keys(result).length).toBeGreaterThan(0); + }); + + it("should handle empty string splitting edge case", () => { + // Test what happens when qs returns an empty string + const result = encodeAsFormParameter({}); + expect(result).toEqual({}); + }); + }); +}); diff --git a/tests/unit/form-data-utils/formDataWrapper.test.ts b/tests/unit/form-data-utils/formDataWrapper.test.ts new file mode 100644 index 00000000..47705084 --- /dev/null +++ b/tests/unit/form-data-utils/formDataWrapper.test.ts @@ -0,0 +1,346 @@ +import { Blob, File } from "buffer"; +import { join } from "path"; +/* eslint-disable @typescript-eslint/ban-ts-comment */ +import { Readable } from "stream"; +import { FormDataWrapper, newFormData } from "../../../src/core/form-data-utils/FormDataWrapper"; + +// Helper function to serialize FormData to string for inspection +async function serializeFormData(formData: FormData): Promise { + const request = new Request("http://localhost", { + method: "POST", + body: formData, + }); + + const buffer = await request.arrayBuffer(); + return new TextDecoder().decode(buffer); +} + +describe("FormDataWrapper", () => { + let formData: FormDataWrapper; + + beforeEach(async () => { + formData = new FormDataWrapper(); + await formData.setup(); + }); + + it("Upload file by path", async () => { + await formData.appendFile("file", { + path: join(__dirname, "..", "test-file.txt"), + }); + + const serialized = await serializeFormData(formData.getRequest().body); + + expect(serialized).toContain('Content-Disposition: form-data; name="file"'); + expect(serialized).toContain('filename="test-file.txt"'); + expect(serialized).toContain("This is a test file!"); + }); + + it("Upload file by path with filename", async () => { + await formData.appendFile("file", { + path: join(__dirname, "..", "test-file.txt"), + filename: "custom-file.txt", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + + expect(serialized).toContain('Content-Disposition: form-data; name="file"'); + expect(serialized).toContain('filename="custom-file.txt"'); + expect(serialized).toContain("This is a test file!"); + }); + + describe("Stream handling", () => { + it("serializes Node.js Readable stream with filename", async () => { + const stream = Readable.from(["file content"]); + await formData.appendFile("file", { + data: stream, + filename: "testfile.txt", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + + expect(serialized).toContain('Content-Disposition: form-data; name="file"'); + expect(serialized).toContain('filename="testfile.txt"'); + expect(serialized).toContain("file content"); + }); + + it("auto-detects filename from stream path property", async () => { + const stream = Readable.from(["file content"]); + (stream as { path?: string }).path = "/test/path/testfile.txt"; + + await formData.appendFile("file", stream); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="testfile.txt"'); + }); + + it("handles Windows-style paths", async () => { + const stream = Readable.from(["file content"]); + (stream as { path?: string }).path = "C:\\test\\path\\testfile.txt"; + + await formData.appendFile("file", stream); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="testfile.txt"'); + }); + + it("handles empty streams", async () => { + const stream = Readable.from([]); + await formData.appendFile("file", { + data: stream, + filename: "empty.txt", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="empty.txt"'); + expect(serialized).toMatch(/------formdata-undici-\w+|------WebKitFormBoundary\w+/); + }); + + it("serializes Web ReadableStream with filename", async () => { + const stream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("web stream content")); + controller.close(); + }, + }); + + await formData.appendFile("file", { + data: stream, + filename: "webstream.txt", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="webstream.txt"'); + expect(serialized).toContain("web stream content"); + }); + + it("handles empty Web ReadableStream", async () => { + const stream = new ReadableStream({ + start(controller) { + controller.close(); + }, + }); + + await formData.appendFile("file", { + data: stream, + filename: "empty.txt", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="empty.txt"'); + expect(serialized).toMatch(/------formdata-undici-\w+|------WebKitFormBoundary\w+/); + }); + }); + + describe("Blob and File types", () => { + it("serializes Blob with specified filename", async () => { + const blob = new Blob(["file content"], { type: "text/plain" }); + await formData.appendFile("file", { + data: blob, + filename: "testfile.txt", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="testfile.txt"'); + expect(serialized).toContain("Content-Type: text/plain"); + expect(serialized).toContain("file content"); + }); + + it("uses default filename for Blob without explicit filename", async () => { + const blob = new Blob(["file content"], { type: "text/plain" }); + await formData.appendFile("file", blob); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="blob"'); + }); + + it("preserves File object filename", async () => { + if (typeof File !== "undefined") { + const file = new File(["file content"], "original.txt", { type: "text/plain" }); + await formData.appendFile("file", file); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="original.txt"'); + expect(serialized).toContain("file content"); + } + }); + + it("allows filename override for File objects", async () => { + if (typeof File !== "undefined") { + const file = new File(["file content"], "original.txt", { type: "text/plain" }); + await formData.appendFile("file", { + data: file, + filename: "override.txt", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="override.txt"'); + expect(serialized).not.toContain('filename="original.txt"'); + } + }); + }); + + describe("Binary data types", () => { + it("serializes ArrayBuffer with filename", async () => { + const arrayBuffer = new ArrayBuffer(8); + new Uint8Array(arrayBuffer).set([1, 2, 3, 4, 5, 6, 7, 8]); + + await formData.appendFile("file", { + data: arrayBuffer, + filename: "binary.bin", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="binary.bin"'); + expect(serialized).toMatch(/------formdata-undici-\w+|------WebKitFormBoundary\w+/); + }); + + it("serializes Uint8Array with filename", async () => { + const uint8Array = new Uint8Array([72, 101, 108, 108, 111]); // "Hello" + await formData.appendFile("file", { + data: uint8Array, + filename: "binary.bin", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="binary.bin"'); + expect(serialized).toContain("Hello"); + }); + + it("serializes other typed arrays", async () => { + const int16Array = new Int16Array([1000, 2000, 3000]); + await formData.appendFile("file", { + data: int16Array, + filename: "numbers.bin", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="numbers.bin"'); + }); + + it("serializes Buffer data with filename", async () => { + if (typeof Buffer !== "undefined" && typeof Buffer.isBuffer === "function") { + const buffer = Buffer.from("test content"); + await formData.appendFile("file", { + data: buffer, + filename: "test.txt", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="test.txt"'); + expect(serialized).toContain("test content"); + } + }); + }); + + describe("Text and primitive types", () => { + it("serializes string as regular form field", async () => { + formData.append("text", "test string"); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('name="text"'); + expect(serialized).not.toContain("filename="); + expect(serialized).toContain("test string"); + }); + + it("serializes numbers and booleans as strings", async () => { + formData.append("number", 12345); + formData.append("flag", true); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain("12345"); + expect(serialized).toContain("true"); + }); + }); + + describe("Edge cases and error handling", () => { + it("handles empty filename gracefully", async () => { + await formData.appendFile("file", { + data: new Blob(["content"], { type: "text/plain" }), + filename: "", + }); + + const serialized = await serializeFormData(formData.getRequest().body); + expect(serialized).toContain('filename="blob"'); // Default fallback + }); + + it("handles multiple files in single form", async () => { + await formData.appendFile("file1", { + data: new Blob(["content1"], { type: "text/plain" }), + filename: "file1.txt", + }); + await formData.appendFile("file2", { + data: new Blob(["content2"], { type: "text/plain" }), + filename: "file2.txt", + }); + formData.append("text", "regular field"); + + const serialized = await serializeFormData(formData.getRequest().body); + + expect(serialized).toContain('filename="file1.txt"'); + expect(serialized).toContain('filename="file2.txt"'); + expect(serialized).toContain('name="text"'); + expect(serialized).not.toContain('filename="text"'); + }); + }); + + describe("Request structure", () => { + it("returns correct request structure", async () => { + await formData.appendFile("file", { + data: new Blob(["content"], { type: "text/plain" }), + filename: "test.txt", + }); + + const request = formData.getRequest(); + + expect(request).toHaveProperty("body"); + expect(request).toHaveProperty("headers"); + expect(request).toHaveProperty("duplex"); + expect(request.body).toBeInstanceOf(FormData); + expect(request.headers).toEqual({}); + expect(request.duplex).toBe("half"); + }); + + it("generates proper multipart boundary structure", async () => { + await formData.appendFile("file", { + data: new Blob(["test content"], { type: "text/plain" }), + filename: "test.txt", + }); + formData.append("field", "value"); + + const serialized = await serializeFormData(formData.getRequest().body); + + expect(serialized).toMatch(/------formdata-undici-\w+|------WebKitFormBoundary\w+/); + expect(serialized).toContain("Content-Disposition: form-data;"); + expect(serialized).toMatch(/------formdata-undici-\w+--|------WebKitFormBoundary\w+--/); + }); + }); + + describe("Factory function", () => { + it("returns FormDataWrapper instance", async () => { + const formData = await newFormData(); + expect(formData).toBeInstanceOf(FormDataWrapper); + }); + + it("creates independent instances", async () => { + const formData1 = await newFormData(); + const formData2 = await newFormData(); + + await formData1.setup(); + await formData2.setup(); + + formData1.append("test1", "value1"); + formData2.append("test2", "value2"); + + const request1 = formData1.getRequest() as { body: FormData }; + const request2 = formData2.getRequest() as { body: FormData }; + + const entries1 = Array.from(request1.body.entries()); + const entries2 = Array.from(request2.body.entries()); + + expect(entries1).toHaveLength(1); + expect(entries2).toHaveLength(1); + expect(entries1[0][0]).toBe("test1"); + expect(entries2[0][0]).toBe("test2"); + }); + }); +}); diff --git a/tests/unit/test-file.txt b/tests/unit/test-file.txt new file mode 100644 index 00000000..c66d471e --- /dev/null +++ b/tests/unit/test-file.txt @@ -0,0 +1 @@ +This is a test file! diff --git a/tests/wire/admins.test.ts b/tests/wire/admins.test.ts index 0f4be795..094ccf9e 100644 --- a/tests/wire/admins.test.ts +++ b/tests/wire/admins.test.ts @@ -359,6 +359,13 @@ describe("AdminsClient", () => { source: "admin update from web - Admin id: 93", update_by: 93, update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { occupancy_window_minutes: { before: 15, after: 30 } }, conversation_assignment_limit: 15, ticket_assignment_limit: 20, team_assignment_limit: 50, @@ -384,6 +391,13 @@ describe("AdminsClient", () => { source: "admin update from web - Admin id: 93", update_by: 93, update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { occupancy_window_minutes: { before: 15, after: 30 } }, conversation_assignment_limit: 15, ticket_assignment_limit: 20, team_assignment_limit: 50, @@ -442,6 +456,18 @@ describe("AdminsClient", () => { source: "admin update from web - Admin id: 93", update_by: 93, update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { + occupancy_window_minutes: { + before: 15, + after: 30, + }, + }, conversation_assignment_limit: 15, ticket_assignment_limit: 20, team_assignment_limit: 50, @@ -476,6 +502,18 @@ describe("AdminsClient", () => { source: "admin update from web - Admin id: 93", update_by: 93, update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { + occupancy_window_minutes: { + before: 15, + after: 30, + }, + }, conversation_assignment_limit: 15, ticket_assignment_limit: 20, team_assignment_limit: 50, @@ -553,7 +591,9 @@ describe("AdminsClient", () => { }; server.mockEndpoint().get("/admins").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.admins.list(); + const response = await client.admins.list({ + display_avatar: true, + }); expect(response).toEqual({ type: "admin.list", admins: [ diff --git a/tests/wire/aiContent.test.ts b/tests/wire/aiContent.test.ts index fad0e33d..76e97091 100644 --- a/tests/wire/aiContent.test.ts +++ b/tests/wire/aiContent.test.ts @@ -401,6 +401,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/3", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 42, @@ -417,6 +418,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/2", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 41, @@ -433,6 +435,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/1", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 40, @@ -465,6 +468,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/3", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 42, @@ -481,6 +485,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/2", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 41, @@ -497,6 +502,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/1", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 40, @@ -550,6 +556,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 44, @@ -582,6 +589,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 44, @@ -638,6 +646,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/6", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 46, @@ -665,6 +674,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/6", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 46, @@ -724,6 +734,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 47, @@ -757,6 +768,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 47, @@ -814,6 +826,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/5", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 45, @@ -841,6 +854,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/5", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 45, diff --git a/tests/wire/articles.test.ts b/tests/wire/articles.test.ts index 35387d31..8a5f12d9 100644 --- a/tests/wire/articles.test.ts +++ b/tests/wire/articles.test.ts @@ -445,6 +445,13 @@ describe("ArticlesClient", () => { url: "url", }, }, + tags: { + type: "tag.list", + tags: [ + { type: "tag", id: "id", name: "name", applied_at: 1, applied_by: {} }, + { type: "tag", id: "id", name: "name", applied_at: 1, applied_by: {} }, + ], + }, }, { type: "article", @@ -872,6 +879,13 @@ describe("ArticlesClient", () => { url: "url", }, }, + tags: { + type: "tag.list", + tags: [ + { type: "tag", id: "id", name: "name", applied_at: 1, applied_by: {} }, + { type: "tag", id: "id", name: "name", applied_at: 1, applied_by: {} }, + ], + }, }, ], }; @@ -1316,6 +1330,25 @@ describe("ArticlesClient", () => { url: "url", }, }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "id", + name: "name", + applied_at: 1, + applied_by: {}, + }, + { + type: "tag", + id: "id", + name: "name", + applied_at: 1, + applied_by: {}, + }, + ], + }, }, { type: "article", @@ -1743,6 +1776,25 @@ describe("ArticlesClient", () => { url: "url", }, }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "id", + name: "name", + applied_at: 1, + applied_by: {}, + }, + { + type: "tag", + id: "id", + name: "name", + applied_at: 1, + applied_by: {}, + }, + ], + }, }, ], }; @@ -2229,6 +2281,7 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, statistics: { type: "article_statistics", views: 0, @@ -2692,6 +2745,17 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, statistics: { type: "article_statistics", views: 0, @@ -3145,6 +3209,7 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, statistics: { type: "article_statistics", views: 0, @@ -3597,6 +3662,17 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, statistics: { type: "article_statistics", views: 0, @@ -4078,6 +4154,7 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, statistics: { type: "article_statistics", views: 0, @@ -4519,6 +4596,17 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, statistics: { type: "article_statistics", views: 0, @@ -5004,6 +5092,7 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, statistics: { type: "article_statistics", views: 0, @@ -5454,6 +5543,17 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, statistics: { type: "article_statistics", views: 0, @@ -5901,6 +6001,7 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, statistics: { type: "article_statistics", views: 0, @@ -6351,6 +6452,17 @@ describe("ArticlesClient", () => { url: "http://intercom.test/help/en/articles/3-default-language", }, }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, statistics: { type: "article_statistics", views: 0, @@ -6504,6 +6616,10 @@ describe("ArticlesClient", () => { parent_ids: [18, 19], parent_type: "collection", default_locale: "en", + tags: { + type: "tag.list", + tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], + }, }, ], highlights: [{ article_id: "123" }], @@ -6544,6 +6660,17 @@ describe("ArticlesClient", () => { parent_ids: [18, 19], parent_type: "collection", default_locale: "en", + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, }, ], highlights: [ diff --git a/tests/wire/awayStatusReasons.test.ts b/tests/wire/awayStatusReasons.test.ts index f89aa99c..e337d9c2 100644 --- a/tests/wire/awayStatusReasons.test.ts +++ b/tests/wire/awayStatusReasons.test.ts @@ -14,18 +14,21 @@ describe("AwayStatusReasonsClient", () => { environment: server.baseUrl, }); - const rawResponseBody = [ - { - type: "away_status_reason", - id: "id", - label: "On a break", - emoji: "☕", - order: 1, - deleted: false, - created_at: 1734537243, - updated_at: 1734537243, - }, - ]; + const rawResponseBody = { + type: "list", + data: [ + { + type: "away_status_reason", + id: "id", + label: "On a break", + emoji: "☕", + order: 1, + deleted: false, + created_at: 1734537243, + updated_at: 1734537243, + }, + ], + }; server .mockEndpoint() .get("/away_status_reasons") @@ -35,18 +38,21 @@ describe("AwayStatusReasonsClient", () => { .build(); const response = await client.awayStatusReasons.listAwayStatusReasons(); - expect(response).toEqual([ - { - type: "away_status_reason", - id: "id", - label: "On a break", - emoji: "\u2615", - order: 1, - deleted: false, - created_at: 1734537243, - updated_at: 1734537243, - }, - ]); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "away_status_reason", + id: "id", + label: "On a break", + emoji: "\u2615", + order: 1, + deleted: false, + created_at: 1734537243, + updated_at: 1734537243, + }, + ], + }); }); test("listAwayStatusReasons (2)", async () => { diff --git a/tests/wire/companies.test.ts b/tests/wire/companies.test.ts index 90524081..23c09029 100644 --- a/tests/wire/companies.test.ts +++ b/tests/wire/companies.test.ts @@ -37,6 +37,19 @@ describe("CompaniesClient", () => { session_count: 100, user_count: 100, custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 }, + segments: { + segments: [ + { + type: "segment", + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + person_type: "contact", + count: 3, + }, + ], + }, }, ], }; @@ -87,6 +100,19 @@ describe("CompaniesClient", () => { monthly_spend: 155.5, team_mates: 9, }, + segments: { + segments: [ + { + type: "segment", + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + person_type: "contact", + count: 3, + }, + ], + }, }, ], }); @@ -152,16 +178,18 @@ describe("CompaniesClient", () => { monthly_spend: 0, session_count: 0, user_count: 0, - custom_attributes: { creation_source: "api" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + custom_attributes: { industry: "manufacturing" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -203,13 +231,15 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 0, custom_attributes: { - creation_source: "api", + industry: "manufacturing", }, tags: { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -217,10 +247,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -254,16 +286,18 @@ describe("CompaniesClient", () => { monthly_spend: 0, session_count: 0, user_count: 0, - custom_attributes: { creation_source: "api" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + custom_attributes: { industry: "manufacturing" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -294,13 +328,15 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 0, custom_attributes: { - creation_source: "api", + industry: "manufacturing", }, tags: { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -308,10 +344,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -380,15 +418,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -433,7 +473,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -441,10 +483,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -529,15 +573,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -587,7 +633,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -595,10 +643,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -633,15 +683,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -687,7 +739,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -695,10 +749,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1184,15 +1240,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 4, custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1245,15 +1303,24 @@ describe("CompaniesClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1326,15 +1393,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 4, custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1388,15 +1457,24 @@ describe("CompaniesClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1476,15 +1554,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1531,7 +1611,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -1539,10 +1621,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1577,15 +1661,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1632,7 +1718,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -1640,10 +1728,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1678,15 +1768,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1733,7 +1825,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -1741,10 +1835,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1860,15 +1956,17 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 0, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], @@ -1914,7 +2012,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -1922,10 +2022,12 @@ describe("CompaniesClient", () => { type: "segment.list", segments: [ { + type: "segment", id: "56203d253cba154d39010062", name: "Active", created_at: 1394621988, updated_at: 1394622004, + person_type: "contact", count: 3, }, ], diff --git a/tests/wire/contacts.test.ts b/tests/wire/contacts.test.ts index 2f74a99a..233669a0 100644 --- a/tests/wire/contacts.test.ts +++ b/tests/wire/contacts.test.ts @@ -35,6 +35,19 @@ describe("ContactsClient", () => { session_count: 100, user_count: 100, custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 }, + segments: { + segments: [ + { + type: "segment", + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + person_type: "contact", + count: 3, + }, + ], + }, }, ], total_count: 1, @@ -77,6 +90,19 @@ describe("ContactsClient", () => { monthly_spend: 155.5, team_mates: 9, }, + segments: { + segments: [ + { + type: "segment", + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + person_type: "contact", + count: 3, + }, + ], + }, }, ], total_count: 1, @@ -731,7 +757,7 @@ describe("ContactsClient", () => { id: "80", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }, ], }; @@ -755,8 +781,8 @@ describe("ContactsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }, ], @@ -1680,7 +1706,7 @@ describe("ContactsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = {}; + const rawRequestBody = { from: "from", into: "into" }; const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; server .mockEndpoint() @@ -1692,7 +1718,10 @@ describe("ContactsClient", () => { .build(); await expect(async () => { - return await client.contacts.mergeLeadInUser(); + return await client.contacts.mergeLeadInUser({ + from: "from", + into: "into", + }); }).rejects.toThrow(Intercom.UnauthorizedError); }); diff --git a/tests/wire/conversations.test.ts b/tests/wire/conversations.test.ts index 77dab803..a69262fd 100644 --- a/tests/wire/conversations.test.ts +++ b/tests/wire/conversations.test.ts @@ -29,9 +29,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], @@ -99,8 +98,12 @@ describe("ConversationsClient", () => { handling_time: 2310, adjusted_handling_time: 1800, }, - conversation_parts: { total_count: 1 }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [{ type: "ticket", id: "7583" }], + }, ai_agent_participated: false, ai_agent: { source_title: "My AI Workflow", @@ -143,9 +146,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -244,15 +246,13 @@ describe("ConversationsClient", () => { handling_time: 2310, adjusted_handling_time: 1800, }, - conversation_parts: { - total_count: 1, - }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -537,9 +537,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -620,9 +619,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -640,7 +637,6 @@ describe("ConversationsClient", () => { created_at: 1663597223, updated_at: 1663597260, notified_at: 1663597260, - assigned_to: { type: "contact", id: "1a2b3c" }, author: { type: "admin", id: "274", @@ -771,7 +767,7 @@ describe("ConversationsClient", () => { ], total_count: 4, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -814,9 +810,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -927,7 +922,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -955,10 +950,6 @@ describe("ConversationsClient", () => { created_at: 1663597223, updated_at: 1663597260, notified_at: 1663597260, - assigned_to: { - type: "contact", - id: "1a2b3c", - }, author: { type: "admin", id: "274", @@ -1135,6 +1126,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -1264,9 +1256,8 @@ describe("ConversationsClient", () => { state: "closed", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -1336,9 +1327,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -1415,7 +1404,7 @@ describe("ConversationsClient", () => { ], total_count: 2, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -1470,9 +1459,8 @@ describe("ConversationsClient", () => { state: "closed", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -1580,7 +1568,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -1677,6 +1665,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -1727,9 +1716,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -1815,9 +1803,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -1835,6 +1821,25 @@ describe("ConversationsClient", () => { created_at: 1663597223, updated_at: 1663597260, notified_at: 1663597260, + author: { + type: "admin", + id: "274", + name: "Operator", + email: "operator+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, app_package_code: "test-integration", @@ -1842,7 +1847,7 @@ describe("ConversationsClient", () => { ], total_count: 0, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -1894,9 +1899,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -2020,7 +2024,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -2048,6 +2052,25 @@ describe("ConversationsClient", () => { created_at: 1663597223, updated_at: 1663597260, notified_at: 1663597260, + author: { + type: "admin", + id: "274", + name: "Operator", + email: "operator+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, app_package_code: "test-integration", @@ -2061,6 +2084,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -2115,9 +2139,8 @@ describe("ConversationsClient", () => { state: "closed", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -2187,9 +2210,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -2266,7 +2287,7 @@ describe("ConversationsClient", () => { ], total_count: 2, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -2321,9 +2342,8 @@ describe("ConversationsClient", () => { state: "closed", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -2431,7 +2451,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -2528,6 +2548,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -2740,9 +2761,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], @@ -2810,8 +2830,12 @@ describe("ConversationsClient", () => { handling_time: 2310, adjusted_handling_time: 1800, }, - conversation_parts: { total_count: 1 }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [{ type: "ticket", id: "7583" }], + }, ai_agent_participated: false, ai_agent: { source_title: "My AI Workflow", @@ -2855,9 +2879,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -2956,15 +2979,13 @@ describe("ConversationsClient", () => { handling_time: 2310, adjusted_handling_time: 1800, }, - conversation_parts: { - total_count: 1, - }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -3039,9 +3060,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -3111,9 +3131,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -3158,7 +3176,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -3212,9 +3230,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -3321,7 +3338,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -3384,6 +3401,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -3439,9 +3457,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -3511,9 +3528,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -3558,7 +3573,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -3612,9 +3627,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -3721,7 +3735,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -3784,6 +3798,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -3842,9 +3857,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -3914,9 +3928,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -3961,7 +3973,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -4024,9 +4036,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -4133,7 +4144,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -4196,6 +4207,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -4252,9 +4264,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -4324,9 +4335,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -4371,7 +4380,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -4431,9 +4440,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -4540,7 +4548,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -4603,6 +4611,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -4658,9 +4667,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -4730,9 +4738,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -4777,7 +4783,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -4831,9 +4837,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -4940,7 +4945,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -5003,6 +5008,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -5058,9 +5064,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -5130,9 +5135,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -5177,7 +5180,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -5231,9 +5234,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -5340,7 +5342,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -5403,6 +5405,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -5458,9 +5461,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -5530,9 +5532,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -5577,7 +5577,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -5631,9 +5631,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -5740,7 +5739,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -5803,6 +5802,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -5858,9 +5858,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -5930,9 +5929,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -5977,7 +5974,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -6031,9 +6028,8 @@ describe("ConversationsClient", () => { state: "open", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -6140,7 +6136,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -6203,6 +6199,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -6364,9 +6361,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -6436,9 +6432,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -6483,7 +6477,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -6536,9 +6530,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -6645,7 +6638,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -6708,6 +6701,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -6758,9 +6752,8 @@ describe("ConversationsClient", () => { state: "snoozed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -6830,9 +6823,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -6877,7 +6868,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -6930,9 +6921,8 @@ describe("ConversationsClient", () => { state: "snoozed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -7039,7 +7029,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -7102,6 +7092,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -7152,9 +7143,8 @@ describe("ConversationsClient", () => { state: "open", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -7224,9 +7214,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -7271,7 +7259,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -7323,9 +7311,8 @@ describe("ConversationsClient", () => { state: "open", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -7432,7 +7419,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -7495,6 +7482,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -7546,8 +7534,7 @@ describe("ConversationsClient", () => { read: false, priority: "not_priority", admin_assignee_id: 991267715, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -7617,9 +7604,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -7665,7 +7650,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -7720,8 +7705,7 @@ describe("ConversationsClient", () => { read: false, priority: "not_priority", admin_assignee_id: 991267715, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -7828,7 +7812,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -7895,6 +7879,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -7945,9 +7930,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -8017,9 +8001,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -8064,7 +8046,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -8117,9 +8099,8 @@ describe("ConversationsClient", () => { state: "closed", read: false, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -8226,7 +8207,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -8289,6 +8270,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -8420,1870 +8402,148 @@ describe("ConversationsClient", () => { environment: server.baseUrl, }); const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19b1bb69f9f2193bbd4" } }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, + const rawResponseBody = { customers: [{ type: "user", id: "6762f19b1bb69f9f2193bbd4" }] }; + server + .mockEndpoint() + .post("/conversations/123/customers") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.conversations.attachContactAsAdmin({ + conversation_id: "123", + admin_id: "12345", + customer: { + intercom_user_id: "6762f19b1bb69f9f2193bbd4", }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f19b1bb69f9f2193bbd4", }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", + ], + }); + }); + + test("attachContactAsAdmin (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19e1bb69f9f2193bbd5" } }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f19b1bb69f9f2193bbd4" }] }; + server + .mockEndpoint() + .post("/conversations/123/customers") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.conversations.attachContactAsAdmin({ + conversation_id: "123", + admin_id: "12345", + customer: { + intercom_user_id: "6762f19e1bb69f9f2193bbd5", }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

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

Okay!

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

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, + customers: [ + { + type: "user", + id: "6762f1b41bb69f9f2193bbe0", }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], + ], + }); + }); + + test("detachContactAsAdmin (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "5017690" }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f1b41bb69f9f2193bbe0" }] }; + server + .mockEndpoint() + .delete("/conversations/123/customers/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.conversations.detachContactAsAdmin({ + conversation_id: "123", + contact_id: "123", + admin_id: "5017690", + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f1b41bb69f9f2193bbe0", }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], + ], + }); + }); + + test("detachContactAsAdmin (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "5017690" }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f1b41bb69f9f2193bbe0" }] }; + server + .mockEndpoint() + .delete("/conversations/123/customers/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.conversations.detachContactAsAdmin({ + conversation_id: "123", + contact_id: "123", + admin_id: "5017690", + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f1b41bb69f9f2193bbe0", }, - }, + ], }); }); @@ -10778,9 +8816,8 @@ describe("ConversationsClient", () => { state: "open", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -10850,9 +8887,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -10897,7 +8932,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -10947,9 +8982,8 @@ describe("ConversationsClient", () => { state: "open", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -11056,7 +9090,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -11119,6 +9153,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -11173,9 +9208,8 @@ describe("ConversationsClient", () => { state: "open", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -11245,9 +9279,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -11292,7 +9324,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -11342,9 +9374,8 @@ describe("ConversationsClient", () => { state: "open", read: true, priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -11451,7 +9482,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -11514,6 +9545,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -11653,7 +9685,7 @@ describe("ConversationsClient", () => { updated_at: 1734537737, open: true, snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -11790,6 +9822,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -11908,7 +9941,7 @@ describe("ConversationsClient", () => { updated_at: 1734537737, open: true, snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -12045,6 +10078,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -12166,8 +10200,7 @@ describe("ConversationsClient", () => { read: false, priority: "not_priority", admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, @@ -12237,9 +10270,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -12284,7 +10315,7 @@ describe("ConversationsClient", () => { ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -12332,8 +10363,7 @@ describe("ConversationsClient", () => { read: false, priority: "not_priority", admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + team_assignee_id: 5017691, tags: { type: "tag.list", tags: [ @@ -12440,7 +10470,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -12504,6 +10534,7 @@ describe("ConversationsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], diff --git a/tests/wire/customChannelEvents.test.ts b/tests/wire/customChannelEvents.test.ts deleted file mode 100644 index f259cba1..00000000 --- a/tests/wire/customChannelEvents.test.ts +++ /dev/null @@ -1,790 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("CustomChannelEventsClient", () => { - test("notifyNewConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - expect(response).toEqual({ - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }); - }); - - test("notifyNewConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("notifyNewConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("notifyNewConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("notifyNewConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); - - test("notifyNewMessage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - expect(response).toEqual({ - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }); - }); - - test("notifyNewMessage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("notifyNewMessage (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("notifyNewMessage (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("notifyNewMessage (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); - - test("notifyQuickReplySelected (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "evt_67890", - external_conversation_id: "conv_13579", - contact: { type: "user", external_id: "user_003", name: "Alice Example", email: "alice@example.com" }, - quick_reply_option_id: "1234", - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customChannelEvents.notifyQuickReplySelected({ - event_id: "evt_67890", - external_conversation_id: "conv_13579", - contact: { - type: "user", - external_id: "user_003", - name: "Alice Example", - email: "alice@example.com", - }, - quick_reply_option_id: "1234", - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyQuickReplySelected (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("notifyQuickReplySelected (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("notifyQuickReplySelected (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("notifyQuickReplySelected (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); - - test("notifyAttributeCollected (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - expect(response).toEqual({ - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }); - }); - - test("notifyAttributeCollected (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("notifyAttributeCollected (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("notifyAttributeCollected (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("notifyAttributeCollected (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/finAgent.test.ts b/tests/wire/finAgent.test.ts new file mode 100644 index 00000000..86ce7353 --- /dev/null +++ b/tests/wire/finAgent.test.ts @@ -0,0 +1,973 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../src/api/index"; +import { IntercomClient } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; + +describe("FinAgentClient", () => { + test("startFinConversation (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How can I see my account details?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How can I see my account details?", timestamp: "2025-01-24T10:01:20Z" }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + attributes: { plan_type: "Pro", subscription_status: "active" }, + }, + conversation_metadata: { + history: [ + { author: "user", body: "I need help", timestamp: "2025-01-24T10:00:01Z" }, + { author: "agent", body: "What do you need help with?", timestamp: "2025-01-24T10:01:00Z" }, + ], + attributes: { priority_level: "high", department: "sales" }, + }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + attributes: { + plan_type: "Pro", + subscription_status: "active", + }, + }, + conversation_metadata: { + history: [ + { + author: "user", + body: "I need help", + timestamp: "2025-01-24T10:00:01Z", + }, + { + author: "agent", + body: "What do you need help with?", + timestamp: "2025-01-24T10:01:00Z", + }, + ], + attributes: { + priority_level: "high", + department: "sales", + }, + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "Here is a screenshot of the issue", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + attachments: [ + { type: "url", url: "https://example.com/document.pdf" }, + { + type: "file", + name: "screenshot.png", + content_type: "image/png", + data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...", + }, + ], + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "Here is a screenshot of the issue", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + attachments: [ + { + type: "url", + url: "https://example.com/document.pdf", + }, + { + type: "file", + name: "screenshot.png", + content_type: "image/png", + data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...", + }, + ], + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How can I see my account details?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How can I see my account details?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body", timestamp: "2024-01-15T09:30:00Z" }, + user: { id: "id" }, + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.finAgent.startFinConversation({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + timestamp: "2024-01-15T09:30:00Z", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.BadRequestError); + }); + + test("startFinConversation (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body", timestamp: "2024-01-15T09:30:00Z" }, + user: { id: "id" }, + }; + const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.finAgent.startFinConversation({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + timestamp: "2024-01-15T09:30:00Z", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.UnauthorizedError); + }); + + test("replyToFin (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "123456", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.replyToFin({ + conversation_id: "123456", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "123456", + message: { author: "user", body: "Here's the invoice you asked for.", timestamp: "2025-01-24T09:01:00Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + attachments: [{ type: "url", url: "https://example.com/invoice.pdf" }], + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.replyToFin({ + conversation_id: "123456", + message: { + author: "user", + body: "Here's the invoice you asked for.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + attachments: [ + { + type: "url", + url: "https://example.com/invoice.pdf", + }, + ], + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "123456", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.replyToFin({ + conversation_id: "123456", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "123456", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.replyToFin({ + conversation_id: "123456", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body", timestamp: "2024-01-15T09:30:00Z" }, + user: { id: "id" }, + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.finAgent.replyToFin({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + timestamp: "2024-01-15T09:30:00Z", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.BadRequestError); + }); + + test("replyToFin (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body", timestamp: "2024-01-15T09:30:00Z" }, + user: { id: "id" }, + }; + const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.finAgent.replyToFin({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + timestamp: "2024-01-15T09:30:00Z", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.UnauthorizedError); + }); + + test("submitFinCsat (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "ext-123", rating: "amazing" }; + const rawResponseBody = { conversation_id: "ext-123", rating: "amazing", status: "rated" }; + server + .mockEndpoint() + .post("/fin/csat") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.submitFinCsat({ + conversation_id: "ext-123", + rating: "amazing", + }); + expect(response).toEqual({ + conversation_id: "ext-123", + rating: "amazing", + status: "rated", + }); + }); + + test("submitFinCsat (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + rating: "amazing", + remark: "Fin solved my problem in seconds.", + }; + const rawResponseBody = { conversation_id: "ext-123", rating: "amazing", status: "rated" }; + server + .mockEndpoint() + .post("/fin/csat") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.finAgent.submitFinCsat({ + conversation_id: "ext-123", + rating: "amazing", + remark: "Fin solved my problem in seconds.", + }); + expect(response).toEqual({ + conversation_id: "ext-123", + rating: "amazing", + status: "rated", + }); + }); + + test("submitFinCsat (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "conversation_id", rating: "terrible" }; + const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/csat") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.finAgent.submitFinCsat({ + conversation_id: "conversation_id", + rating: "terrible", + }); + }).rejects.toThrow(Intercom.UnauthorizedError); + }); + + test("submitFinCsat (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "conversation_id", rating: "terrible" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/csat") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.finAgent.submitFinCsat({ + conversation_id: "conversation_id", + rating: "terrible", + }); + }).rejects.toThrow(Intercom.UnprocessableEntityError); + }); +}); diff --git a/tests/wire/preview/admins.test.ts b/tests/wire/preview/admins.test.ts new file mode 100644 index 00000000..c1f64e50 --- /dev/null +++ b/tests/wire/preview/admins.test.ts @@ -0,0 +1,1296 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("AdminsClient", () => { + test("identifyAdmin", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "admin", + id: "991267459", + name: "Ciaran1 Lee", + email: "admin1@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + has_inbox_seat: true, + team_ids: [814865], + avatar: { + type: "avatar", + image_url: "https://static.intercomassets.com/assets/default-avatars/admins/128.png", + }, + email_verified: true, + role: { type: "role", id: "1", name: "Support Agent" }, + app: { + type: "app", + id_code: "this_is_an_id1_that_should_be_at_least_40", + name: "MyApp 1", + region: "US", + timezone: "America/Los_Angeles", + created_at: 1734537243, + identity_verification: false, + }, + }; + server.mockEndpoint().get("/me").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.admins.identifyAdmin(); + expect(response).toEqual({ + type: "admin", + id: "991267459", + name: "Ciaran1 Lee", + email: "admin1@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + has_inbox_seat: true, + team_ids: [814865], + avatar: { + type: "avatar", + image_url: "https://static.intercomassets.com/assets/default-avatars/admins/128.png", + }, + email_verified: true, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + app: { + type: "app", + id_code: "this_is_an_id1_that_should_be_at_least_40", + name: "MyApp 1", + region: "US", + timezone: "America/Los_Angeles", + created_at: 1734537243, + identity_verification: false, + }, + }); + }); + + test("setAwayAdmin (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true, away_status_reason_id: 12345 }; + const rawResponseBody = { + type: "admin", + id: "991267460", + name: "Ciaran2 Lee", + email: "admin2@email.com", + job_title: "Associate", + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, + }; + server + .mockEndpoint() + .put("/admins/1/away") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.admins.setAwayAdmin({ + id: 1, + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345, + }); + expect(response).toEqual({ + type: "admin", + id: "991267460", + name: "Ciaran2 Lee", + email: "admin2@email.com", + job_title: "Associate", + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { + primary_team_ids: [814865], + secondary_team_ids: [493881], + }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + }); + }); + + test("setAwayAdmin (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; + const rawResponseBody = { + type: "admin", + id: "991267460", + name: "Ciaran2 Lee", + email: "admin2@email.com", + job_title: "Associate", + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, + }; + server + .mockEndpoint() + .put("/admins/1/away") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.admins.setAwayAdmin({ + id: 1, + away_mode_enabled: true, + away_mode_reassign: true, + }); + expect(response).toEqual({ + type: "admin", + id: "991267460", + name: "Ciaran2 Lee", + email: "admin2@email.com", + job_title: "Associate", + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { + primary_team_ids: [814865], + secondary_team_ids: [493881], + }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + }); + }); + + test("setAwayAdmin (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; + const rawResponseBody = { + type: "admin", + id: "991267460", + name: "Ciaran2 Lee", + email: "admin2@email.com", + job_title: "Associate", + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, + }; + server + .mockEndpoint() + .put("/admins/1/away") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.admins.setAwayAdmin({ + id: 1, + away_mode_enabled: true, + away_mode_reassign: true, + }); + expect(response).toEqual({ + type: "admin", + id: "991267460", + name: "Ciaran2 Lee", + email: "admin2@email.com", + job_title: "Associate", + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { + primary_team_ids: [814865], + secondary_team_ids: [493881], + }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + }); + }); + + test("setAwayAdmin (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/admins/1/away") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.admins.setAwayAdmin({ + id: 1, + away_mode_enabled: true, + away_mode_reassign: true, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("setAwayAdmin (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/admins/1/away") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.admins.setAwayAdmin({ + id: 1, + away_mode_enabled: true, + away_mode_reassign: true, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("setAwayAdmin (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/admins/1/away") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.admins.setAwayAdmin({ + id: 1, + away_mode_enabled: true, + away_mode_reassign: true, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listActivityLogs (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "activity_log.list", + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 20, + total_pages: 1, + }, + activity_logs: [ + { + id: "fca05814-4b72-4dce-ad4f-77a786a2c136", + performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, + metadata: { + sign_in_method: "email_password", + external_id: "f3b87a2e09d514c6c2e79b9a", + away_mode: true, + away_status_reason: "😌 On a break", + reassign_conversations: false, + source: "admin update from web - Admin id: 93", + update_by: 93, + update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { occupancy_window_minutes: { before: 15, after: 30 } }, + conversation_assignment_limit: 15, + ticket_assignment_limit: 20, + }, + created_at: 1734537253, + activity_type: "app_name_change", + activity_description: "Ciaran5 Lee changed your app name from before to after.", + }, + { + id: "f48c653b-0185-48ac-a276-23d11006bafb", + performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, + metadata: { + sign_in_method: "email_password", + external_id: "f3b87a2e09d514c6c2e79b9a", + away_mode: true, + away_status_reason: "😌 On a break", + reassign_conversations: false, + source: "admin update from web - Admin id: 93", + update_by: 93, + update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { occupancy_window_minutes: { before: 15, after: 30 } }, + conversation_assignment_limit: 15, + ticket_assignment_limit: 20, + }, + created_at: 1734537253, + activity_type: "message_state_change", + activity_description: + "Ciaran5 Lee changed your Initial message title message from Initial message title to Eventual message title.", + }, + ], + }; + server + .mockEndpoint() + .get("/admins/activity_logs") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.admins.listActivityLogs({ + created_at_after: "1677253093", + created_at_before: "1677861493", + }); + expect(response).toEqual({ + type: "activity_log.list", + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 20, + total_pages: 1, + }, + activity_logs: [ + { + id: "fca05814-4b72-4dce-ad4f-77a786a2c136", + performed_by: { + type: "admin", + id: "991267464", + email: "admin5@email.com", + ip: "127.0.0.1", + }, + metadata: { + sign_in_method: "email_password", + external_id: "f3b87a2e09d514c6c2e79b9a", + away_mode: true, + away_status_reason: "\uD83D\uDE0C On a break", + reassign_conversations: false, + source: "admin update from web - Admin id: 93", + update_by: 93, + update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { + occupancy_window_minutes: { + before: 15, + after: 30, + }, + }, + conversation_assignment_limit: 15, + ticket_assignment_limit: 20, + }, + created_at: 1734537253, + activity_type: "app_name_change", + activity_description: "Ciaran5 Lee changed your app name from before to after.", + }, + { + id: "f48c653b-0185-48ac-a276-23d11006bafb", + performed_by: { + type: "admin", + id: "991267464", + email: "admin5@email.com", + ip: "127.0.0.1", + }, + metadata: { + sign_in_method: "email_password", + external_id: "f3b87a2e09d514c6c2e79b9a", + away_mode: true, + away_status_reason: "\uD83D\uDE0C On a break", + reassign_conversations: false, + source: "admin update from web - Admin id: 93", + update_by: 93, + update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { + occupancy_window_minutes: { + before: 15, + after: 30, + }, + }, + conversation_assignment_limit: 15, + ticket_assignment_limit: 20, + }, + created_at: 1734537253, + activity_type: "message_state_change", + activity_description: + "Ciaran5 Lee changed your Initial message title message from Initial message title to Eventual message title.", + }, + ], + }); + }); + + test("listActivityLogs (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/admins/activity_logs") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.admins.listActivityLogs({ + created_at_after: "created_at_after", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("searchActivityLogs (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + created_at_after: 1677253093, + created_at_before: 1677861493, + event_types: ["app_name_change", "message_state_change"], + }; + const rawResponseBody = { + type: "activity_log.list", + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 20, + total_pages: 1, + }, + activity_logs: [ + { + id: "fca05814-4b72-4dce-ad4f-77a786a2c136", + performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, + metadata: { + sign_in_method: "email_password", + external_id: "f3b87a2e09d514c6c2e79b9a", + away_mode: true, + away_status_reason: "😌 On a break", + reassign_conversations: false, + source: "admin update from web - Admin id: 93", + update_by: 93, + update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { occupancy_window_minutes: { before: 15, after: 30 } }, + conversation_assignment_limit: 15, + ticket_assignment_limit: 20, + }, + created_at: 1734537253, + activity_type: "app_name_change", + activity_description: "Ciaran5 Lee changed your app name from before to after.", + }, + ], + }; + server + .mockEndpoint() + .post("/admins/activity_logs/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.admins.searchActivityLogs({ + created_at_after: 1677253093, + created_at_before: 1677861493, + event_types: ["app_name_change", "message_state_change"], + }); + expect(response).toEqual({ + type: "activity_log.list", + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 20, + total_pages: 1, + }, + activity_logs: [ + { + id: "fca05814-4b72-4dce-ad4f-77a786a2c136", + performed_by: { + type: "admin", + id: "991267464", + email: "admin5@email.com", + ip: "127.0.0.1", + }, + metadata: { + sign_in_method: "email_password", + external_id: "f3b87a2e09d514c6c2e79b9a", + away_mode: true, + away_status_reason: "\uD83D\uDE0C On a break", + reassign_conversations: false, + source: "admin update from web - Admin id: 93", + update_by: 93, + update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { + occupancy_window_minutes: { + before: 15, + after: 30, + }, + }, + conversation_assignment_limit: 15, + ticket_assignment_limit: 20, + }, + created_at: 1734537253, + activity_type: "app_name_change", + activity_description: "Ciaran5 Lee changed your app name from before to after.", + }, + ], + }); + }); + + test("searchActivityLogs (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { created_at_after: 1677253093, created_at_before: 1677861493 }; + const rawResponseBody = { + type: "activity_log.list", + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 20, + total_pages: 1, + }, + activity_logs: [ + { + id: "fca05814-4b72-4dce-ad4f-77a786a2c136", + performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, + metadata: { + sign_in_method: "email_password", + external_id: "f3b87a2e09d514c6c2e79b9a", + away_mode: true, + away_status_reason: "😌 On a break", + reassign_conversations: false, + source: "admin update from web - Admin id: 93", + update_by: 93, + update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { occupancy_window_minutes: { before: 15, after: 30 } }, + conversation_assignment_limit: 15, + ticket_assignment_limit: 20, + }, + created_at: 1734537253, + activity_type: "app_name_change", + activity_description: "Ciaran5 Lee changed your app name from before to after.", + }, + ], + }; + server + .mockEndpoint() + .post("/admins/activity_logs/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.admins.searchActivityLogs({ + created_at_after: 1677253093, + created_at_before: 1677861493, + }); + expect(response).toEqual({ + type: "activity_log.list", + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 20, + total_pages: 1, + }, + activity_logs: [ + { + id: "fca05814-4b72-4dce-ad4f-77a786a2c136", + performed_by: { + type: "admin", + id: "991267464", + email: "admin5@email.com", + ip: "127.0.0.1", + }, + metadata: { + sign_in_method: "email_password", + external_id: "f3b87a2e09d514c6c2e79b9a", + away_mode: true, + away_status_reason: "\uD83D\uDE0C On a break", + reassign_conversations: false, + source: "admin update from web - Admin id: 93", + update_by: 93, + update_by_name: "Joe Example", + previous_state: "idle", + new_state: "occupied", + threshold_minutes: 15, + last_activity_at: 1671028894, + auto: true, + setting_type: "teammate_occupancy", + changes: { + occupancy_window_minutes: { + before: 15, + after: 30, + }, + }, + conversation_assignment_limit: 15, + ticket_assignment_limit: 20, + }, + created_at: 1734537253, + activity_type: "app_name_change", + activity_description: "Ciaran5 Lee changed your app name from before to after.", + }, + ], + }); + }); + + test("searchActivityLogs (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { created_at_after: 1 }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/admins/activity_logs/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.admins.searchActivityLogs({ + created_at_after: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listActivityLogEventTypes (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "activity_log_event_type.list", + event_types: [ + "admin_conversation_assignment_limit_change", + "admin_ticket_assignment_limit_change", + "admin_avatar_change", + "admin_away_mode_change", + "admin_deletion", + "admin_deprovisioned", + "admin_impersonation_end", + "admin_impersonation_start", + "admin_invite_change", + "admin_invite_creation", + "admin_invite_deletion", + "admin_login_failure", + "admin_login_success", + "admin_logout", + "admin_occupancy_setting_change", + "admin_occupancy_state_change", + "admin_password_reset_request", + "admin_password_reset_success", + "admin_permission_change", + "admin_provisioned", + "admin_two_factor_auth_change", + "admin_unauthorized_sign_in_method", + "app_admin_join", + "app_authentication_method_change", + "app_data_deletion", + "app_data_export", + "app_google_sso_domain_change", + "app_identity_verification_change", + "app_name_change", + "app_outbound_address_change", + "app_package_installation", + "app_package_token_regeneration", + "app_package_uninstallation", + "app_team_creation", + "app_team_deletion", + "app_team_membership_modification", + "app_timezone_change", + "app_webhook_creation", + "app_webhook_deletion", + "articles_in_messenger_enabled_change", + "bulk_delete", + "bulk_export", + "campaign_deletion", + "campaign_state_change", + "conversation_part_deletion", + "conversation_pdf_export", + "conversation_topic_change", + "conversation_topic_creation", + "conversation_topic_deletion", + "help_center_settings_change", + "inbound_conversations_change", + "inbox_access_change", + "inbox_bulk_action", + "message_deletion", + "message_state_change", + "messenger_look_and_feel_change", + "messenger_search_required_change", + "messenger_spaces_change", + "office_hours_change", + "role_change", + "role_creation", + "role_deletion", + "ruleset_activation_title_preview", + "ruleset_creation", + "ruleset_deletion", + "search_browse_enabled_change", + "search_browse_required_change", + "seat_change", + "seat_revoke", + "security_settings_change", + "temporary_expectation_change", + "upfront_email_collection_change", + "welcome_message_change", + "hide_csat_from_agents_setting_change", + ], + }; + server + .mockEndpoint() + .get("/admins/activity_log_event_types") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.admins.listActivityLogEventTypes(); + expect(response).toEqual({ + type: "activity_log_event_type.list", + event_types: [ + "admin_conversation_assignment_limit_change", + "admin_ticket_assignment_limit_change", + "admin_avatar_change", + "admin_away_mode_change", + "admin_deletion", + "admin_deprovisioned", + "admin_impersonation_end", + "admin_impersonation_start", + "admin_invite_change", + "admin_invite_creation", + "admin_invite_deletion", + "admin_login_failure", + "admin_login_success", + "admin_logout", + "admin_occupancy_setting_change", + "admin_occupancy_state_change", + "admin_password_reset_request", + "admin_password_reset_success", + "admin_permission_change", + "admin_provisioned", + "admin_two_factor_auth_change", + "admin_unauthorized_sign_in_method", + "app_admin_join", + "app_authentication_method_change", + "app_data_deletion", + "app_data_export", + "app_google_sso_domain_change", + "app_identity_verification_change", + "app_name_change", + "app_outbound_address_change", + "app_package_installation", + "app_package_token_regeneration", + "app_package_uninstallation", + "app_team_creation", + "app_team_deletion", + "app_team_membership_modification", + "app_timezone_change", + "app_webhook_creation", + "app_webhook_deletion", + "articles_in_messenger_enabled_change", + "bulk_delete", + "bulk_export", + "campaign_deletion", + "campaign_state_change", + "conversation_part_deletion", + "conversation_pdf_export", + "conversation_topic_change", + "conversation_topic_creation", + "conversation_topic_deletion", + "help_center_settings_change", + "inbound_conversations_change", + "inbox_access_change", + "inbox_bulk_action", + "message_deletion", + "message_state_change", + "messenger_look_and_feel_change", + "messenger_search_required_change", + "messenger_spaces_change", + "office_hours_change", + "role_change", + "role_creation", + "role_deletion", + "ruleset_activation_title_preview", + "ruleset_creation", + "ruleset_deletion", + "search_browse_enabled_change", + "search_browse_required_change", + "seat_change", + "seat_revoke", + "security_settings_change", + "temporary_expectation_change", + "upfront_email_collection_change", + "welcome_message_change", + "hide_csat_from_agents_setting_change", + ], + }); + }); + + test("listActivityLogEventTypes (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/admins/activity_log_event_types") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.admins.listActivityLogEventTypes(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listAdmins (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "admin.list", + admins: [ + { + type: "admin", + id: "991267466", + name: "Ciaran7 Lee", + email: "admin7@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, + }, + ], + }; + server.mockEndpoint().get("/admins").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.admins.listAdmins({ + display_avatar: true, + }); + expect(response).toEqual({ + type: "admin.list", + admins: [ + { + type: "admin", + id: "991267466", + name: "Ciaran7 Lee", + email: "admin7@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { + primary_team_ids: [814865], + secondary_team_ids: [493881], + }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + }, + ], + }); + }); + + test("listAdmins (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/admins").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.admins.listAdmins(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveAdmin (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "admin", + id: "991267468", + name: "Ciaran9 Lee", + email: "admin9@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, + }; + server.mockEndpoint().get("/admins/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.admins.retrieveAdmin({ + id: 1, + }); + expect(response).toEqual({ + type: "admin", + id: "991267468", + name: "Ciaran9 Lee", + email: "admin9@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { + primary_team_ids: [814865], + secondary_team_ids: [493881], + }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + }); + }); + + test("retrieveAdmin (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/admins/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.admins.retrieveAdmin({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveAdmin (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/admins/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.admins.retrieveAdmin({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("removeAdmin (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "123", object: "admin", removed: "true" }; + server.mockEndpoint().delete("/admins/remove").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.admins.removeAdmin({ + admin_id: 1, + reassign_messages_admin_id: 1, + reassign_owner_admin_id: 1, + reassign_articles_author_id: 1, + reassign_conversations_admin_id: 1, + }); + expect(response).toEqual({ + id: "123", + object: "admin", + removed: "true", + }); + }); + + test("removeAdmin (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/admins/remove").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.admins.removeAdmin({ + admin_id: 1, + reassign_messages_admin_id: 1, + reassign_owner_admin_id: 1, + reassign_articles_author_id: 1, + reassign_conversations_admin_id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("removeAdmin (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/admins/remove").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.admins.removeAdmin({ + admin_id: 1, + reassign_messages_admin_id: 1, + reassign_owner_admin_id: 1, + reassign_articles_author_id: 1, + reassign_conversations_admin_id: 1, + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("removeAdmin (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().delete("/admins/remove").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.admins.removeAdmin({ + admin_id: 1, + reassign_messages_admin_id: 1, + reassign_owner_admin_id: 1, + reassign_articles_author_id: 1, + reassign_conversations_admin_id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("removeAdmin (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/admins/remove").respondWith().statusCode(405).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.admins.removeAdmin({ + admin_id: 1, + reassign_messages_admin_id: 1, + reassign_owner_admin_id: 1, + reassign_articles_author_id: 1, + reassign_conversations_admin_id: 1, + }); + }).rejects.toThrow(Intercom.preview.MethodNotAllowedError); + }); +}); diff --git a/tests/wire/unstable/aiContent.test.ts b/tests/wire/preview/aiContent.test.ts similarity index 89% rename from tests/wire/unstable/aiContent.test.ts rename to tests/wire/preview/aiContent.test.ts index 4c0c8a22..46b7ea60 100644 --- a/tests/wire/unstable/aiContent.test.ts +++ b/tests/wire/preview/aiContent.test.ts @@ -28,6 +28,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/1", created_at: 1734537259, updated_at: 1734537259, + audience_ids: [5678], }, { type: "content_import_source", @@ -38,6 +39,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/2", created_at: 1734537259, updated_at: 1734537259, + audience_ids: [5678], }, { type: "content_import_source", @@ -48,6 +50,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/3", created_at: 1734537259, updated_at: 1734537259, + audience_ids: [5678], }, ], }; @@ -59,7 +62,7 @@ describe("AiContentClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.aiContent.listContentImportSources(); + const response = await client.preview.aiContent.listContentImportSources(); expect(response).toEqual({ type: "list", pages: { @@ -80,6 +83,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/1", created_at: 1734537259, updated_at: 1734537259, + audience_ids: [5678], }, { type: "content_import_source", @@ -90,6 +94,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/2", created_at: 1734537259, updated_at: 1734537259, + audience_ids: [5678], }, { type: "content_import_source", @@ -100,6 +105,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/3", created_at: 1734537259, updated_at: 1734537259, + audience_ids: [5678], }, ], }); @@ -124,8 +130,8 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.listContentImportSources(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.aiContent.listContentImportSources(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createContentImportSource (1)", async () => { @@ -146,6 +152,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", created_at: 1734537261, updated_at: 1734537261, + audience_ids: [5678], }; server .mockEndpoint() @@ -156,7 +163,7 @@ describe("AiContentClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.aiContent.createContentImportSource({ + const response = await client.preview.aiContent.createContentImportSource({ url: "https://www.example.com", }); expect(response).toEqual({ @@ -168,6 +175,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", created_at: 1734537261, updated_at: 1734537261, + audience_ids: [5678], }); }); @@ -191,10 +199,10 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.createContentImportSource({ + return await client.preview.aiContent.createContentImportSource({ url: "url", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("getContentImportSource (1)", async () => { @@ -215,6 +223,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/5", created_at: 1734537265, updated_at: 1734537265, + audience_ids: [5678], }; server .mockEndpoint() @@ -224,7 +233,7 @@ describe("AiContentClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.aiContent.getContentImportSource({ + const response = await client.preview.aiContent.getContentImportSource({ id: "id", }); expect(response).toEqual({ @@ -236,6 +245,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/5", created_at: 1734537265, updated_at: 1734537265, + audience_ids: [5678], }); }); @@ -258,10 +268,10 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.getContentImportSource({ + return await client.preview.aiContent.getContentImportSource({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateContentImportSource (1)", async () => { @@ -282,6 +292,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", created_at: 1734537267, updated_at: 1734537267, + audience_ids: [5678], }; server .mockEndpoint() @@ -292,7 +303,7 @@ describe("AiContentClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.aiContent.updateContentImportSource({ + const response = await client.preview.aiContent.updateContentImportSource({ id: "id", sync_behavior: "api", url: "https://www.example.com", @@ -306,6 +317,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", created_at: 1734537267, updated_at: 1734537267, + audience_ids: [5678], }); }); @@ -329,12 +341,12 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.updateContentImportSource({ + return await client.preview.aiContent.updateContentImportSource({ id: "id", sync_behavior: "api", url: "url", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteContentImportSource (1)", async () => { @@ -348,7 +360,7 @@ describe("AiContentClient", () => { server.mockEndpoint().delete("/ai/content_import_sources/id").respondWith().statusCode(200).build(); - const response = await client.unstable.aiContent.deleteContentImportSource({ + const response = await client.preview.aiContent.deleteContentImportSource({ id: "id", }); expect(response).toEqual(undefined); @@ -373,10 +385,10 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.deleteContentImportSource({ + return await client.preview.aiContent.deleteContentImportSource({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("listExternalPages (1)", async () => { @@ -401,6 +413,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/3", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 42, @@ -417,6 +430,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/2", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 41, @@ -433,6 +447,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/1", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 40, @@ -445,7 +460,7 @@ describe("AiContentClient", () => { }; server.mockEndpoint().get("/ai/external_pages").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.aiContent.listExternalPages(); + const response = await client.preview.aiContent.listExternalPages(); expect(response).toEqual({ type: "list", pages: { @@ -465,6 +480,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/3", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 42, @@ -481,6 +497,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/2", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 41, @@ -497,6 +514,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/1", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 40, @@ -522,8 +540,8 @@ describe("AiContentClient", () => { server.mockEndpoint().get("/ai/external_pages").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.aiContent.listExternalPages(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.aiContent.listExternalPages(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createExternalPage (1)", async () => { @@ -550,6 +568,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 44, @@ -567,7 +586,7 @@ describe("AiContentClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.aiContent.createExternalPage({ + const response = await client.preview.aiContent.createExternalPage({ title: "Test", html: "

Test

", url: "https://www.example.com", @@ -582,6 +601,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 44, @@ -612,13 +632,13 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.createExternalPage({ + return await client.preview.aiContent.createExternalPage({ title: "title", html: "html", source_id: 1, external_id: "external_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("getExternalPage (1)", async () => { @@ -638,6 +658,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/6", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 46, @@ -654,7 +675,7 @@ describe("AiContentClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.aiContent.getExternalPage({ + const response = await client.preview.aiContent.getExternalPage({ id: "id", }); expect(response).toEqual({ @@ -665,6 +686,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/6", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 46, @@ -694,10 +716,10 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.getExternalPage({ + return await client.preview.aiContent.getExternalPage({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateExternalPage (1)", async () => { @@ -724,6 +746,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 47, @@ -741,7 +764,7 @@ describe("AiContentClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.aiContent.updateExternalPage({ + const response = await client.preview.aiContent.updateExternalPage({ id: "id", title: "Test", html: "

Test

", @@ -757,6 +780,7 @@ describe("AiContentClient", () => { url: "https://www.example.com", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 47, @@ -787,14 +811,14 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.updateExternalPage({ + return await client.preview.aiContent.updateExternalPage({ id: "id", title: "title", html: "html", url: "url", source_id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteExternalPage (1)", async () => { @@ -814,6 +838,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/5", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 45, @@ -830,7 +855,7 @@ describe("AiContentClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.aiContent.deleteExternalPage({ + const response = await client.preview.aiContent.deleteExternalPage({ id: "id", }); expect(response).toEqual({ @@ -841,6 +866,7 @@ describe("AiContentClient", () => { url: "https://support.example.com/us/5", ai_agent_availability: true, ai_copilot_availability: true, + ai_sales_agent_availability: true, fin_availability: true, locale: "en", source_id: 45, @@ -870,9 +896,9 @@ describe("AiContentClient", () => { .build(); await expect(async () => { - return await client.unstable.aiContent.deleteExternalPage({ + return await client.preview.aiContent.deleteExternalPage({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/preview/articles.test.ts b/tests/wire/preview/articles.test.ts new file mode 100644 index 00000000..6b4fa497 --- /dev/null +++ b/tests/wire/preview/articles.test.ts @@ -0,0 +1,9186 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ArticlesClient", () => { + test("listArticles (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 25, + total_pages: 1, + }, + total_count: 1, + data: [ + { + type: "article", + id: "39", + workspace_id: "this_is_an_id64_that_should_be_at_least_4", + title: "This is the article title", + description: "", + body: "", + body_markdown: "", + author_id: 991267492, + state: "published", + created_at: 1734537283, + updated_at: 1734537283, + has_unpublished_changes: false, + draft_updated_at: 1672928610, + url: "http://help-center.test/myapp-64/en/articles/39-this-is-the-article-title", + parent_ids: [18, 19], + default_locale: "en", + tags: { + type: "tag.list", + tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], + }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + }, + ], + }; + server.mockEndpoint().get("/articles").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.articles.listArticles(); + expect(response).toEqual({ + type: "list", + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 25, + total_pages: 1, + }, + total_count: 1, + data: [ + { + type: "article", + id: "39", + workspace_id: "this_is_an_id64_that_should_be_at_least_4", + title: "This is the article title", + description: "", + body: "", + body_markdown: "", + author_id: 991267492, + state: "published", + created_at: 1734537283, + updated_at: 1734537283, + has_unpublished_changes: false, + draft_updated_at: 1672928610, + url: "http://help-center.test/myapp-64/en/articles/39-this-is-the-article-title", + parent_ids: [18, 19], + default_locale: "en", + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + }, + ], + }); + }); + + test("listArticles (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/articles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.listArticles(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createArticle (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { key: "value" }; + const rawResponseBody = { + statistics: { + type: "article_statistics", + views: 1, + conversions: 1, + reactions: 1, + happy_reaction_percentage: 1.1, + neutral_reaction_percentage: 1.1, + sad_reaction_percentage: 1.1, + fin_involvements: 1, + fin_resolutions: 1, + fin_resolution_rate: 1.1, + }, + type: "article", + id: "id", + workspace_id: "workspace_id", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + parent_ids: [1, 1], + default_locale: "default_locale", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + bg: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + bs: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ca: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + cs: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + da: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + de: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + el: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + en: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + es: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + et: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + fi: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + fr: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + he: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + hr: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + hu: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + id: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + it: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ja: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ko: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + lt: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + lv: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + mn: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + nb: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + nl: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + pl: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + pt: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ro: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ru: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + sl: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + sr: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + sv: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + tr: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + vi: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + "pt-BR": { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + "zh-CN": { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + "zh-TW": { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + }, + tags: { + type: "tag.list", + tags: [ + { type: "type", id: "id", name: "name", applied_at: 1, applied_by: { type: "type", id: "id" } }, + { type: "type", id: "id", name: "name", applied_at: 1, applied_by: { type: "type", id: "id" } }, + ], + }, + folder_id: 1, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + exclude_from_article_suggestions: true, + help_center_audience: "everyone", + scheduled_publish_at: 1, + scheduled_unpublish_at: 1, + }; + server + .mockEndpoint() + .post("/articles") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.articles.createArticle({ + key: "value", + }); + expect(response).toEqual({ + statistics: { + type: "article_statistics", + views: 1, + conversions: 1, + reactions: 1, + happy_reaction_percentage: 1.1, + neutral_reaction_percentage: 1.1, + sad_reaction_percentage: 1.1, + fin_involvements: 1, + fin_resolutions: 1, + fin_resolution_rate: 1.1, + }, + type: "article", + id: "id", + workspace_id: "workspace_id", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + parent_ids: [1, 1], + default_locale: "default_locale", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + bg: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + bs: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ca: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + cs: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + da: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + de: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + el: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + en: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + es: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + et: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + fi: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + fr: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + he: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + hr: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + hu: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + id: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + it: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ja: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ko: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + lt: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + lv: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + mn: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + nb: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + nl: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + pl: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + pt: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ro: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + ru: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + sl: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + sr: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + sv: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + tr: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + vi: { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + "pt-BR": { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + "zh-CN": { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + "zh-TW": { + type: "article_content", + title: "title", + description: "description", + body: "body", + body_markdown: "body_markdown", + author_id: 1, + state: "published", + created_at: 1, + updated_at: 1, + has_unpublished_changes: true, + draft_updated_at: 1, + url: "url", + audience_ids: [1, 1], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "type", + id: "id", + name: "name", + applied_at: 1, + applied_by: { + type: "type", + id: "id", + }, + }, + { + type: "type", + id: "id", + name: "name", + applied_at: 1, + applied_by: { + type: "type", + id: "id", + }, + }, + ], + }, + folder_id: 1, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 1, + updated_by_id: 1, + exclude_from_article_suggestions: true, + help_center_audience: "everyone", + scheduled_publish_at: 1, + scheduled_unpublish_at: 1, + }); + }); + + test("createArticle (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { key: "value" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/articles") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.createArticle({ + key: "value", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("createArticle (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { key: "value" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/articles") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.createArticle({ + key: "value", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveArticle (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "article", + id: "45", + workspace_id: "this_is_an_id74_that_should_be_at_least_4", + title: "This is the article title", + description: "", + body: "", + body_markdown: "", + author_id: 991267502, + state: "published", + created_at: 1734537292, + updated_at: 1734537292, + has_unpublished_changes: false, + draft_updated_at: 1672928610, + url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", + parent_ids: [18, 19], + default_locale: "en", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bg: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ca: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + cs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + da: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + de: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + el: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + en: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + es: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + et: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + he: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hu: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + id: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + it: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ja: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ko: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + mn: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nb: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ro: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ru: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + tr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + vi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "pt-BR": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-CN": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-TW": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + statistics: { + type: "article_statistics", + views: 0, + conversions: 0, + reactions: 0, + happy_reaction_percentage: 0, + neutral_reaction_percentage: 0, + sad_reaction_percentage: 0, + fin_involvements: 10, + fin_resolutions: 8, + fin_resolution_rate: 80, + }, + }; + server.mockEndpoint().get("/articles/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.articles.retrieveArticle({ + id: 1, + }); + expect(response).toEqual({ + type: "article", + id: "45", + workspace_id: "this_is_an_id74_that_should_be_at_least_4", + title: "This is the article title", + description: "", + body: "", + body_markdown: "", + author_id: 991267502, + state: "published", + created_at: 1734537292, + updated_at: 1734537292, + has_unpublished_changes: false, + draft_updated_at: 1672928610, + url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", + parent_ids: [18, 19], + default_locale: "en", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bg: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ca: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + cs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + da: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + de: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + el: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + en: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + es: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + et: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + he: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hu: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + id: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + it: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ja: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ko: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + mn: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nb: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ro: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ru: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + tr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + vi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "pt-BR": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-CN": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-TW": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + statistics: { + type: "article_statistics", + views: 0, + conversions: 0, + reactions: 0, + happy_reaction_percentage: 0, + neutral_reaction_percentage: 0, + sad_reaction_percentage: 0, + fin_involvements: 10, + fin_resolutions: 8, + fin_resolution_rate: 80, + }, + }); + }); + + test("retrieveArticle (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/articles/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.retrieveArticle({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveArticle (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/articles/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.retrieveArticle({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteArticle (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "51", object: "article", deleted: true }; + server.mockEndpoint().delete("/articles/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.articles.deleteArticle({ + id: 1, + }); + expect(response).toEqual({ + id: "51", + object: "article", + deleted: true, + }); + }); + + test("deleteArticle (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/articles/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.deleteArticle({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteArticle (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().delete("/articles/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.deleteArticle({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("retrieveArticleDraft (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "article", + id: "45", + workspace_id: "this_is_an_id74_that_should_be_at_least_4", + title: "This is the draft title", + description: "", + body: '

Unpublished changes staged as a draft

', + body_markdown: "Unpublished changes staged as a draft\n", + author_id: 991267502, + state: "published", + created_at: 1734537292, + updated_at: 1734537292, + has_unpublished_changes: true, + draft_updated_at: 1734537292, + url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", + parent_ids: [18, 19], + default_locale: "en", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bg: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ca: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + cs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + da: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + de: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + el: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + en: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + es: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + et: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + he: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hu: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + id: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + it: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ja: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ko: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + mn: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nb: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ro: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ru: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + tr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + vi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "pt-BR": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-CN": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-TW": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + statistics: { + type: "article_statistics", + views: 10, + conversions: 0, + reactions: 10, + happy_reaction_percentage: 40, + neutral_reaction_percentage: 40, + sad_reaction_percentage: 20, + fin_involvements: 10, + fin_resolutions: 8, + fin_resolution_rate: 80, + }, + }; + server.mockEndpoint().get("/articles/1/draft").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.articles.retrieveArticleDraft({ + id: 1, + }); + expect(response).toEqual({ + type: "article", + id: "45", + workspace_id: "this_is_an_id74_that_should_be_at_least_4", + title: "This is the draft title", + description: "", + body: '

Unpublished changes staged as a draft

', + body_markdown: "Unpublished changes staged as a draft\n", + author_id: 991267502, + state: "published", + created_at: 1734537292, + updated_at: 1734537292, + has_unpublished_changes: true, + draft_updated_at: 1734537292, + url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", + parent_ids: [18, 19], + default_locale: "en", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bg: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ca: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + cs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + da: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + de: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + el: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + en: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + es: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + et: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + he: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hu: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + id: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + it: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ja: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ko: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + mn: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nb: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ro: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ru: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + tr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + vi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "pt-BR": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-CN": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-TW": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + statistics: { + type: "article_statistics", + views: 10, + conversions: 0, + reactions: 10, + happy_reaction_percentage: 40, + neutral_reaction_percentage: 40, + sad_reaction_percentage: 20, + fin_involvements: 10, + fin_resolutions: 8, + fin_resolution_rate: 80, + }, + }); + }); + + test("retrieveArticleDraft (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/articles/1/draft").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.retrieveArticleDraft({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveArticleDraft (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/articles/1/draft").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.retrieveArticleDraft({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("stageArticleDraft (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { title: "Christmas is here!", body: "

New gifts in store for the jolly season

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

New gifts in store for the jolly season

', + body_markdown: "New gifts in store for the jolly season\n", + author_id: 991267508, + state: "published", + created_at: 1734537297, + updated_at: 1734537298, + has_unpublished_changes: true, + draft_updated_at: 1734537298, + url: "http://help-center.test/myapp-80/en/articles/48-christmas-is-here", + parent_ids: [18, 19], + default_locale: "en", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bg: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ca: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + cs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + da: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + de: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + el: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + en: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + es: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + et: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + he: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hu: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + id: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + it: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ja: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ko: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + mn: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nb: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ro: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ru: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + tr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + vi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "pt-BR": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-CN": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-TW": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + statistics: { + type: "article_statistics", + views: 10, + conversions: 0, + reactions: 10, + happy_reaction_percentage: 40, + neutral_reaction_percentage: 40, + sad_reaction_percentage: 20, + fin_involvements: 10, + fin_resolutions: 8, + fin_resolution_rate: 80, + }, + }; + server + .mockEndpoint() + .put("/articles/1/draft") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.articles.stageArticleDraft({ + id: 1, + body: { + title: "Christmas is here!", + body: "

New gifts in store for the jolly season

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

New gifts in store for the jolly season

', + body_markdown: "New gifts in store for the jolly season\n", + author_id: 991267508, + state: "published", + created_at: 1734537297, + updated_at: 1734537298, + has_unpublished_changes: true, + draft_updated_at: 1734537298, + url: "http://help-center.test/myapp-80/en/articles/48-christmas-is-here", + parent_ids: [18, 19], + default_locale: "en", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bg: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ca: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + cs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + da: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + de: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + el: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + en: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + es: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + et: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + he: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hu: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + id: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + it: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ja: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ko: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + mn: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nb: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ro: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ru: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + tr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + vi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "pt-BR": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-CN": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-TW": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + statistics: { + type: "article_statistics", + views: 10, + conversions: 0, + reactions: 10, + happy_reaction_percentage: 40, + neutral_reaction_percentage: 40, + sad_reaction_percentage: 20, + fin_involvements: 10, + fin_resolutions: 8, + fin_resolution_rate: 80, + }, + }); + }); + + test("stageArticleDraft (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().put("/articles/1/draft").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.stageArticleDraft({ + id: 1, + body: undefined, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("stageArticleDraft (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().put("/articles/1/draft").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.stageArticleDraft({ + id: 1, + body: undefined, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("stageArticleDraft (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().put("/articles/1/draft").respondWith().statusCode(422).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.stageArticleDraft({ + id: 1, + body: undefined, + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("publishArticleDraft (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { locales: ["en", "fr"] }; + const rawResponseBody = { + type: "article", + id: "48", + workspace_id: "this_is_an_id80_that_should_be_at_least_4", + title: "Christmas is here!", + description: "", + body: '

New gifts in store for the jolly season

', + body_markdown: "New gifts in store for the jolly season\n", + author_id: 991267508, + state: "published", + created_at: 1734537297, + updated_at: 1734537299, + has_unpublished_changes: false, + draft_updated_at: 1672928610, + url: "http://help-center.test/myapp-80/en/articles/48-christmas-is-here", + parent_ids: [18, 19], + default_locale: "en", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bg: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ca: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + cs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + da: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + de: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + el: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + en: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + es: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + et: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + he: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hu: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + id: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + it: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ja: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ko: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + mn: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nb: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ro: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ru: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + tr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + vi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "pt-BR": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-CN": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-TW": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + statistics: { + type: "article_statistics", + views: 10, + conversions: 0, + reactions: 10, + happy_reaction_percentage: 40, + neutral_reaction_percentage: 40, + sad_reaction_percentage: 20, + fin_involvements: 10, + fin_resolutions: 8, + fin_resolution_rate: 80, + }, + }; + server + .mockEndpoint() + .post("/articles/1/draft/publish") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.articles.publishArticleDraft({ + id: 1, + body: { + locales: ["en", "fr"], + }, + }); + expect(response).toEqual({ + type: "article", + id: "48", + workspace_id: "this_is_an_id80_that_should_be_at_least_4", + title: "Christmas is here!", + description: "", + body: '

New gifts in store for the jolly season

', + body_markdown: "New gifts in store for the jolly season\n", + author_id: 991267508, + state: "published", + created_at: 1734537297, + updated_at: 1734537299, + has_unpublished_changes: false, + draft_updated_at: 1672928610, + url: "http://help-center.test/myapp-80/en/articles/48-christmas-is-here", + parent_ids: [18, 19], + default_locale: "en", + translated_content: { + type: "article_translated_content", + ar: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bg: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + bs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ca: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + cs: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + da: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + de: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + el: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + en: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + es: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + et: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + fr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + he: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + hu: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + id: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + it: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ja: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ko: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + lv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + mn: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nb: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + nl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + pt: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ro: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + ru: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sl: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + sv: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + tr: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + vi: { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "pt-BR": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-CN": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + "zh-TW": { + type: "article_content", + title: "How to create a new article", + description: "This article will show you how to create a new article.", + body: "This is the body of the article.", + body_markdown: "# How to create a new article\n\nThis is the body of the article.\n", + author_id: 1, + state: "published", + created_at: 1663597223, + updated_at: 1663597260, + has_unpublished_changes: false, + draft_updated_at: 1663597260, + url: "http://intercom.test/help/en/articles/3-default-language", + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + help_center_audience: "everyone", + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + statistics: { + type: "article_statistics", + views: 10, + conversions: 0, + reactions: 10, + happy_reaction_percentage: 40, + neutral_reaction_percentage: 40, + sad_reaction_percentage: 20, + fin_involvements: 10, + fin_resolutions: 8, + fin_resolution_rate: 80, + }, + }); + }); + + test("publishArticleDraft (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/articles/1/draft/publish") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.publishArticleDraft({ + id: 1, + body: undefined, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("publishArticleDraft (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/articles/1/draft/publish") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.publishArticleDraft({ + id: 1, + body: undefined, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("publishArticleDraft (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/articles/1/draft/publish") + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.publishArticleDraft({ + id: 1, + body: undefined, + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("listVersions (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 25, + total_pages: 1, + }, + total_count: 2, + data: [ + { + type: "article_version", + id: "301", + article_id: "123", + title: "This is the article title", + description: "", + author_id: "991267502", + created_by_id: "5017691", + created_via: "web", + from_version_id: "300", + state: "published", + created_at: 1734537292, + }, + { + type: "article_version", + id: "300", + article_id: "123", + title: "This was the earlier title", + description: "", + author_id: "991267502", + created_by_id: "5017691", + created_via: "api", + from_version_id: "300", + state: "draft", + created_at: 1734530000, + }, + ], + }; + server + .mockEndpoint({ once: false }) + .get("/articles/1/versions") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const expected = { + type: "list", + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 25, + total_pages: 1, + }, + total_count: 2, + data: [ + { + type: "article_version", + id: "301", + article_id: "123", + title: "This is the article title", + description: "", + author_id: "991267502", + created_by_id: "5017691", + created_via: "web", + from_version_id: "300", + state: "published", + created_at: 1734537292, + }, + { + type: "article_version", + id: "300", + article_id: "123", + title: "This was the earlier title", + description: "", + author_id: "991267502", + created_by_id: "5017691", + created_via: "api", + from_version_id: "300", + state: "draft", + created_at: 1734530000, + }, + ], + }; + const page = await client.preview.articles.listVersions({ + article_id: 1, + page: 1, + per_page: 1, + locale: "en", + }); + + expect(expected.data).toEqual(page.data); + expect(page.hasNextPage()).toBe(true); + const nextPage = await page.getNextPage(); + expect(expected.data).toEqual(nextPage.data); + }); + + test("listVersions (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint({ once: false }) + .get("/articles/1/versions") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.listVersions({ + article_id: 1, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("listVersions (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint({ once: false }) + .get("/articles/1/versions") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.listVersions({ + article_id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listVersions (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint({ once: false }) + .get("/articles/1/versions") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.listVersions({ + article_id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("findVersion (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "article_version", + id: "301", + article_id: "123", + title: "This is the article title", + description: "", + body: '

Body of this version

', + body_markdown: "Body of this version\n", + author_id: "991267502", + created_by_id: "5017691", + created_via: "web", + from_version_id: "300", + state: "published", + created_at: 1734537292, + updated_at: 1734537292, + }; + server + .mockEndpoint() + .get("/articles/1/versions/301") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.articles.findVersion({ + article_id: 1, + id: "301", + locale: "en", + }); + expect(response).toEqual({ + type: "article_version", + id: "301", + article_id: "123", + title: "This is the article title", + description: "", + body: '

Body of this version

', + body_markdown: "Body of this version\n", + author_id: "991267502", + created_by_id: "5017691", + created_via: "web", + from_version_id: "300", + state: "published", + created_at: 1734537292, + updated_at: 1734537292, + }); + }); + + test("findVersion (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/articles/1/versions/id") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.findVersion({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("findVersion (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/articles/1/versions/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.findVersion({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("findVersion (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/articles/1/versions/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.findVersion({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("attachTagToArticle (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "7522907" }; + const rawResponseBody = { + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { type: "admin", id: "1234" }, + }; + server + .mockEndpoint() + .post("/articles/1/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.articles.attachTagToArticle({ + article_id: 1, + id: "7522907", + }); + expect(response).toEqual({ + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { + type: "admin", + id: "1234", + }, + }); + }); + + test("attachTagToArticle (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/articles/1/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.attachTagToArticle({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("attachTagToArticle (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/articles/1/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.attachTagToArticle({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("attachTagToArticle (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/articles/1/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.attachTagToArticle({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("detachTagFromArticle (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { type: "contact", id: "1a2b3c" }, + }; + server + .mockEndpoint() + .delete("/articles/1/tags/7522907") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.articles.detachTagFromArticle({ + article_id: 1, + id: "7522907", + }); + expect(response).toEqual({ + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { + type: "contact", + id: "1a2b3c", + }, + }); + }); + + test("detachTagFromArticle (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/articles/1/tags/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.detachTagFromArticle({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("detachTagFromArticle (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/articles/1/tags/id") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.detachTagFromArticle({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("detachTagFromArticle (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/articles/1/tags/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.articles.detachTagFromArticle({ + article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("searchArticles (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + total_count: 1, + data: { + articles: [ + { + type: "article", + id: "55", + workspace_id: "this_is_an_id92_that_should_be_at_least_4", + title: "Title 1", + description: "", + body: "", + body_markdown: "", + author_id: 991267521, + state: "draft", + created_at: 1734537306, + updated_at: 1734537306, + has_unpublished_changes: false, + draft_updated_at: 1672928610, + url: "http://intercom.test/help/en/articles/3-default-language", + parent_ids: [18, 19], + default_locale: "en", + tags: { + type: "tag.list", + tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], + }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + }, + ], + highlights: [{ article_id: "123" }], + }, + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 10, + total_pages: 1, + }, + }; + server.mockEndpoint().get("/articles/search").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.articles.searchArticles({ + phrase: "Getting started", + state: "published", + help_center_id: 1, + highlight: true, + }); + expect(response).toEqual({ + type: "list", + total_count: 1, + data: { + articles: [ + { + type: "article", + id: "55", + workspace_id: "this_is_an_id92_that_should_be_at_least_4", + title: "Title 1", + description: "", + body: "", + body_markdown: "", + author_id: 991267521, + state: "draft", + created_at: 1734537306, + updated_at: 1734537306, + has_unpublished_changes: false, + draft_updated_at: 1672928610, + url: "http://intercom.test/help/en/articles/3-default-language", + parent_ids: [18, 19], + default_locale: "en", + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + folder_id: 6, + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_by_id: 5017691, + updated_by_id: 5017691, + exclude_from_article_suggestions: false, + scheduled_publish_at: 1769443200, + scheduled_unpublish_at: 1769443200, + }, + ], + highlights: [ + { + article_id: "123", + }, + ], + }, + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 10, + total_pages: 1, + }, + }); + }); + + test("searchArticles (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/articles/search").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.articles.searchArticles(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); +}); diff --git a/tests/wire/preview/audiences.test.ts b/tests/wire/preview/audiences.test.ts new file mode 100644 index 00000000..cbf2949b --- /dev/null +++ b/tests/wire/preview/audiences.test.ts @@ -0,0 +1,542 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("AudiencesClient", () => { + test("listAudiences (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "audience", + id: "123", + name: "VIP Customers", + predicates: [{ attribute: "company.name", type: "string", comparison: "contains", value: "Acme" }], + role_predicates: [{ attribute: "role", type: "role", comparison: "eq", value: "user" }], + created_at: 1717200000, + updated_at: 1717200000, + }, + { + type: "audience", + id: "456", + name: "Enterprise Accounts", + predicates: [ + { attribute: "custom_attributes.plan", type: "string", comparison: "eq", value: "enterprise" }, + ], + role_predicates: [{ attribute: "role", type: "role", comparison: "eq", value: "user" }], + created_at: 1717200000, + updated_at: 1717200000, + }, + ], + total_count: 2, + page: 1, + per_page: 50, + total_pages: 1, + }; + server.mockEndpoint().get("/audiences").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.audiences.listAudiences({ + page: 1, + per_page: 1, + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "audience", + id: "123", + name: "VIP Customers", + predicates: [ + { + attribute: "company.name", + type: "string", + comparison: "contains", + value: "Acme", + }, + ], + role_predicates: [ + { + attribute: "role", + type: "role", + comparison: "eq", + value: "user", + }, + ], + created_at: 1717200000, + updated_at: 1717200000, + }, + { + type: "audience", + id: "456", + name: "Enterprise Accounts", + predicates: [ + { + attribute: "custom_attributes.plan", + type: "string", + comparison: "eq", + value: "enterprise", + }, + ], + role_predicates: [ + { + attribute: "role", + type: "role", + comparison: "eq", + value: "user", + }, + ], + created_at: 1717200000, + updated_at: 1717200000, + }, + ], + total_count: 2, + page: 1, + per_page: 50, + total_pages: 1, + }); + }); + + test("listAudiences (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/audiences").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.audiences.listAudiences(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createAudience (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + name: "VIP Customers", + predicates: [{ attribute: "company.name", type: "string", comparison: "contains", value: "Acme" }], + role_predicates: [{ attribute: "role", type: "role", comparison: "eq", value: "user" }], + }; + const rawResponseBody = { + type: "audience", + id: "789", + name: "VIP Customers", + predicates: [{ attribute: "company.name", type: "string", comparison: "contains", value: "Acme" }], + role_predicates: [{ attribute: "role", type: "role", comparison: "eq", value: "user" }], + created_at: 1717200000, + updated_at: 1717200000, + }; + server + .mockEndpoint() + .post("/audiences") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.audiences.createAudience({ + name: "VIP Customers", + predicates: [ + { + attribute: "company.name", + type: "string", + comparison: "contains", + value: "Acme", + }, + ], + role_predicates: [ + { + attribute: "role", + type: "role", + comparison: "eq", + value: "user", + }, + ], + }); + expect(response).toEqual({ + type: "audience", + id: "789", + name: "VIP Customers", + predicates: [ + { + attribute: "company.name", + type: "string", + comparison: "contains", + value: "Acme", + }, + ], + role_predicates: [ + { + attribute: "role", + type: "role", + comparison: "eq", + value: "user", + }, + ], + created_at: 1717200000, + updated_at: 1717200000, + }); + }); + + test("createAudience (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/audiences") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.audiences.createAudience({ + name: "name", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createAudience (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/audiences") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.audiences.createAudience({ + name: "name", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("retrieveAudience (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "audience", + id: "123", + name: "VIP Customers", + predicates: [{ attribute: "company.name", type: "string", comparison: "contains", value: "Acme" }], + role_predicates: [{ attribute: "role", type: "role", comparison: "eq", value: "user" }], + created_at: 1717200000, + updated_at: 1717200000, + }; + server.mockEndpoint().get("/audiences/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.audiences.retrieveAudience({ + id: "123", + }); + expect(response).toEqual({ + type: "audience", + id: "123", + name: "VIP Customers", + predicates: [ + { + attribute: "company.name", + type: "string", + comparison: "contains", + value: "Acme", + }, + ], + role_predicates: [ + { + attribute: "role", + type: "role", + comparison: "eq", + value: "user", + }, + ], + created_at: 1717200000, + updated_at: 1717200000, + }); + }); + + test("retrieveAudience (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/audiences/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.audiences.retrieveAudience({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveAudience (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/audiences/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.audiences.retrieveAudience({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateAudience (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + name: "Enterprise Accounts", + predicates: [ + { attribute: "custom_attributes.plan", type: "string", comparison: "eq", value: "enterprise" }, + ], + }; + const rawResponseBody = { + type: "audience", + id: "123", + name: "Enterprise Accounts", + predicates: [ + { attribute: "custom_attributes.plan", type: "string", comparison: "eq", value: "enterprise" }, + ], + role_predicates: [{ attribute: "role", type: "role", comparison: "eq", value: "user" }], + created_at: 1717200000, + updated_at: 1717200100, + }; + server + .mockEndpoint() + .put("/audiences/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.audiences.updateAudience({ + id: "123", + name: "Enterprise Accounts", + predicates: [ + { + attribute: "custom_attributes.plan", + type: "string", + comparison: "eq", + value: "enterprise", + }, + ], + }); + expect(response).toEqual({ + type: "audience", + id: "123", + name: "Enterprise Accounts", + predicates: [ + { + attribute: "custom_attributes.plan", + type: "string", + comparison: "eq", + value: "enterprise", + }, + ], + role_predicates: [ + { + attribute: "role", + type: "role", + comparison: "eq", + value: "user", + }, + ], + created_at: 1717200000, + updated_at: 1717200100, + }); + }); + + test("updateAudience (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/audiences/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.audiences.updateAudience({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateAudience (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/audiences/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.audiences.updateAudience({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateAudience (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/audiences/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.audiences.updateAudience({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("deleteAudience (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/audiences/123").respondWith().statusCode(200).build(); + + const response = await client.preview.audiences.deleteAudience({ + id: "123", + }); + expect(response).toEqual(undefined); + }); + + test("deleteAudience (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/audiences/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.audiences.deleteAudience({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteAudience (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().delete("/audiences/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.audiences.deleteAudience({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); +}); diff --git a/tests/wire/preview/authTokens.test.ts b/tests/wire/preview/authTokens.test.ts new file mode 100644 index 00000000..f6ef5119 --- /dev/null +++ b/tests/wire/preview/authTokens.test.ts @@ -0,0 +1,477 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("AuthTokensClient", () => { + test("listAuthTokens (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "auth_token", + id: "12345", + name: "Fulfilment API key", + description: "Used by the order status connector", + token_type: "text", + request_header_key: "Authorization", + token_prefix: "Bearer", + domain: "api.fulfilment.example.com", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + }, + ], + pages: { type: "pages", per_page: 20, next: { starting_after: "WzE3MDc1OTQ3MTUuMCwxMjM0NV0=" } }, + }; + server.mockEndpoint().get("/auth_tokens").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.authTokens.listAuthTokens({ + per_page: 1, + starting_after: "starting_after", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "auth_token", + id: "12345", + name: "Fulfilment API key", + description: "Used by the order status connector", + token_type: "text", + request_header_key: "Authorization", + token_prefix: "Bearer", + domain: "api.fulfilment.example.com", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + }, + ], + pages: { + type: "pages", + per_page: 20, + next: { + starting_after: "WzE3MDc1OTQ3MTUuMCwxMjM0NV0=", + }, + }, + }); + }); + + test("listAuthTokens (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/auth_tokens").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.authTokens.listAuthTokens(); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("listAuthTokens (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/auth_tokens").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.authTokens.listAuthTokens(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createAuthToken (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + name: "Fulfilment API key", + token_value: "sk_live_9f3c2a7b41e8", + request_header_key: "Authorization", + token_prefix: "Bearer", + description: "Used by the order status connector", + domain: "api.fulfilment.example.com", + }; + const rawResponseBody = { + type: "auth_token", + id: "12345", + name: "Fulfilment API key", + description: "Used by the order status connector", + token_type: "text", + request_header_key: "Authorization", + token_prefix: "Bearer", + domain: "api.fulfilment.example.com", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2025-11-15T09:30:00Z", + }; + server + .mockEndpoint() + .post("/auth_tokens") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.authTokens.createAuthToken({ + name: "Fulfilment API key", + token_value: "sk_live_9f3c2a7b41e8", + request_header_key: "Authorization", + token_prefix: "Bearer", + description: "Used by the order status connector", + domain: "api.fulfilment.example.com", + }); + expect(response).toEqual({ + type: "auth_token", + id: "12345", + name: "Fulfilment API key", + description: "Used by the order status connector", + token_type: "text", + request_header_key: "Authorization", + token_prefix: "Bearer", + domain: "api.fulfilment.example.com", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2025-11-15T09:30:00Z", + }); + }); + + test("createAuthToken (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name", token_value: "token_value", request_header_key: "request_header_key" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/auth_tokens") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.authTokens.createAuthToken({ + name: "name", + token_value: "token_value", + request_header_key: "request_header_key", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("createAuthToken (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name", token_value: "token_value", request_header_key: "request_header_key" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/auth_tokens") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.authTokens.createAuthToken({ + name: "name", + token_value: "token_value", + request_header_key: "request_header_key", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createAuthToken (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name", token_value: "token_value", request_header_key: "request_header_key" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/auth_tokens") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.authTokens.createAuthToken({ + name: "name", + token_value: "token_value", + request_header_key: "request_header_key", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("retrieveAuthToken (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "auth_token", + id: "12345", + name: "Fulfilment API key", + description: "Used by the order status connector", + token_type: "text", + request_header_key: "Authorization", + token_prefix: "Bearer", + domain: "api.fulfilment.example.com", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + }; + server.mockEndpoint().get("/auth_tokens/12345").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.authTokens.retrieveAuthToken({ + id: "12345", + }); + expect(response).toEqual({ + type: "auth_token", + id: "12345", + name: "Fulfilment API key", + description: "Used by the order status connector", + token_type: "text", + request_header_key: "Authorization", + token_prefix: "Bearer", + domain: "api.fulfilment.example.com", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + }); + }); + + test("retrieveAuthToken (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/auth_tokens/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.authTokens.retrieveAuthToken({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveAuthToken (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/auth_tokens/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.authTokens.retrieveAuthToken({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateAuthToken (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + name: "Fulfilment API key (rotated host)", + description: "Used by the order status connector", + }; + const rawResponseBody = { + type: "auth_token", + id: "12345", + name: "Fulfilment API key (rotated host)", + description: "Used by the order status connector", + token_type: "text", + request_header_key: "Authorization", + token_prefix: "Bearer", + domain: "api.fulfilment.example.com", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + }; + server + .mockEndpoint() + .patch("/auth_tokens/12345") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.authTokens.updateAuthToken({ + id: "12345", + name: "Fulfilment API key (rotated host)", + description: "Used by the order status connector", + }); + expect(response).toEqual({ + type: "auth_token", + id: "12345", + name: "Fulfilment API key (rotated host)", + description: "Used by the order status connector", + token_type: "text", + request_header_key: "Authorization", + token_prefix: "Bearer", + domain: "api.fulfilment.example.com", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + }); + }); + + test("updateAuthToken (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .patch("/auth_tokens/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.authTokens.updateAuthToken({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("updateAuthToken (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .patch("/auth_tokens/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.authTokens.updateAuthToken({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateAuthToken (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .patch("/auth_tokens/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.authTokens.updateAuthToken({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("updateAuthToken (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .patch("/auth_tokens/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.authTokens.updateAuthToken({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); +}); diff --git a/tests/wire/unstable/awayStatusReasons.test.ts b/tests/wire/preview/awayStatusReasons.test.ts similarity index 55% rename from tests/wire/unstable/awayStatusReasons.test.ts rename to tests/wire/preview/awayStatusReasons.test.ts index f0416817..93284788 100644 --- a/tests/wire/unstable/awayStatusReasons.test.ts +++ b/tests/wire/preview/awayStatusReasons.test.ts @@ -14,18 +14,21 @@ describe("AwayStatusReasonsClient", () => { environment: server.baseUrl, }); - const rawResponseBody = [ - { - type: "away_status_reason", - id: "id", - label: "On a break", - emoji: "☕", - order: 1, - deleted: false, - created_at: 1734537243, - updated_at: 1734537243, - }, - ]; + const rawResponseBody = { + type: "list", + data: [ + { + type: "away_status_reason", + id: "id", + label: "On a break", + emoji: "☕", + order: 1, + deleted: false, + created_at: 1734537243, + updated_at: 1734537243, + }, + ], + }; server .mockEndpoint() .get("/away_status_reasons") @@ -34,19 +37,22 @@ describe("AwayStatusReasonsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.awayStatusReasons.listAwayStatusReasons(); - expect(response).toEqual([ - { - type: "away_status_reason", - id: "id", - label: "On a break", - emoji: "\u2615", - order: 1, - deleted: false, - created_at: 1734537243, - updated_at: 1734537243, - }, - ]); + const response = await client.preview.awayStatusReasons.listAwayStatusReasons(); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "away_status_reason", + id: "id", + label: "On a break", + emoji: "\u2615", + order: 1, + deleted: false, + created_at: 1734537243, + updated_at: 1734537243, + }, + ], + }); }); test("listAwayStatusReasons (2)", async () => { @@ -68,7 +74,7 @@ describe("AwayStatusReasonsClient", () => { .build(); await expect(async () => { - return await client.unstable.awayStatusReasons.listAwayStatusReasons(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.awayStatusReasons.listAwayStatusReasons(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/preview/banners.test.ts b/tests/wire/preview/banners.test.ts new file mode 100644 index 00000000..479ce728 --- /dev/null +++ b/tests/wire/preview/banners.test.ts @@ -0,0 +1,161 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("BannersClient", () => { + test("listContactBanners (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "banner", + id: "486517", + view_id: "645719311", + title: "Hi there", + body: '

Hi there!

', + style: "inline", + position: "top", + show_dismiss_button: true, + action: { + type: "url", + label: "Learn more", + target: "https://www.intercom.com/pricing", + tour_id: "12345", + tour_url: "https://app.intercom.com/tours/12345", + }, + client_targeting: [{ key: "value" }], + created_at: 1780580493, + }, + ], + }; + server + .mockEndpoint() + .get("/contacts/id/banners") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.banners.listContactBanners({ + id: "id", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "banner", + id: "486517", + view_id: "645719311", + title: "Hi there", + body: '

Hi there!

', + style: "inline", + position: "top", + show_dismiss_button: true, + action: { + type: "url", + label: "Learn more", + target: "https://www.intercom.com/pricing", + tour_id: "12345", + tour_url: "https://app.intercom.com/tours/12345", + }, + client_targeting: [ + { + key: "value", + }, + ], + created_at: 1780580493, + }, + ], + }); + }); + + test("listContactBanners (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/contacts/id/banners") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.banners.listContactBanners({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("dismissContactBanner (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "banner_dismiss", view_id: "645719311", dismissed: true }; + server + .mockEndpoint() + .post("/contacts/id/banners/view_id/dismiss") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.banners.dismissContactBanner({ + id: "id", + view_id: "view_id", + }); + expect(response).toEqual({ + type: "banner_dismiss", + view_id: "645719311", + dismissed: true, + }); + }); + + test("dismissContactBanner (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/contacts/id/banners/view_id/dismiss") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.banners.dismissContactBanner({ + id: "id", + view_id: "view_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); +}); diff --git a/tests/wire/unstable/brands.test.ts b/tests/wire/preview/brands.test.ts similarity index 90% rename from tests/wire/unstable/brands.test.ts rename to tests/wire/preview/brands.test.ts index 5dfe7df0..4f8b9a47 100644 --- a/tests/wire/unstable/brands.test.ts +++ b/tests/wire/preview/brands.test.ts @@ -41,7 +41,7 @@ describe("BrandsClient", () => { }; server.mockEndpoint().get("/brands").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.brands.listBrands(); + const response = await client.preview.brands.listBrands(); expect(response).toEqual({ type: "list", data: [ @@ -82,8 +82,8 @@ describe("BrandsClient", () => { server.mockEndpoint().get("/brands").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.brands.listBrands(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.brands.listBrands(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveBrand (1)", async () => { @@ -107,7 +107,7 @@ describe("BrandsClient", () => { }; server.mockEndpoint().get("/brands/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.brands.retrieveBrand({ + const response = await client.preview.brands.retrieveBrand({ id: "id", }); expect(response).toEqual({ @@ -135,10 +135,10 @@ describe("BrandsClient", () => { server.mockEndpoint().get("/brands/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.brands.retrieveBrand({ + return await client.preview.brands.retrieveBrand({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveBrand (3)", async () => { @@ -154,9 +154,9 @@ describe("BrandsClient", () => { server.mockEndpoint().get("/brands/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.brands.retrieveBrand({ + return await client.preview.brands.retrieveBrand({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/unstable/calls.test.ts b/tests/wire/preview/calls.test.ts similarity index 80% rename from tests/wire/unstable/calls.test.ts rename to tests/wire/preview/calls.test.ts index 4840a470..7125fbcc 100644 --- a/tests/wire/unstable/calls.test.ts +++ b/tests/wire/preview/calls.test.ts @@ -37,6 +37,10 @@ describe("CallsClient", () => { phone: "+15551234567", fin_recording_url: "fin_recording_url", fin_transcription_url: "fin_transcription_url", + duration: 900, + talk_time: 300, + queue_time: 45, + hold_time: 60, }, ], total_count: 0, @@ -50,7 +54,7 @@ describe("CallsClient", () => { }; server.mockEndpoint().get("/calls").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.calls.listCalls({ + const response = await client.preview.calls.listCalls({ page: 1, per_page: 1, }); @@ -77,6 +81,10 @@ describe("CallsClient", () => { phone: "+15551234567", fin_recording_url: "fin_recording_url", fin_transcription_url: "fin_transcription_url", + duration: 900, + talk_time: 300, + queue_time: 45, + hold_time: 60, }, ], total_count: 0, @@ -106,8 +114,8 @@ describe("CallsClient", () => { server.mockEndpoint().get("/calls").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.calls.listCalls(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.calls.listCalls(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("showCall (1)", async () => { @@ -139,10 +147,14 @@ describe("CallsClient", () => { phone: "+15551234567", fin_recording_url: "https://api.intercom.io/calls/124/recording", fin_transcription_url: "https://api.intercom.io/calls/124/transcript", + duration: 90, + talk_time: 85, + queue_time: 3, + hold_time: 60, }; server.mockEndpoint().get("/calls/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.calls.showCall({ + const response = await client.preview.calls.showCall({ id: "id", }); expect(response).toEqual({ @@ -165,6 +177,10 @@ describe("CallsClient", () => { phone: "+15551234567", fin_recording_url: "https://api.intercom.io/calls/124/recording", fin_transcription_url: "https://api.intercom.io/calls/124/transcript", + duration: 90, + talk_time: 85, + queue_time: 3, + hold_time: 60, }); }); @@ -181,10 +197,10 @@ describe("CallsClient", () => { server.mockEndpoint().get("/calls/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.calls.showCall({ + return await client.preview.calls.showCall({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("showCall (3)", async () => { @@ -200,10 +216,10 @@ describe("CallsClient", () => { server.mockEndpoint().get("/calls/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.calls.showCall({ + return await client.preview.calls.showCall({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("showCallRecording (1)", async () => { @@ -217,7 +233,7 @@ describe("CallsClient", () => { server.mockEndpoint().get("/calls/id/recording").respondWith().statusCode(200).build(); - const response = await client.unstable.calls.showCallRecording({ + const response = await client.preview.calls.showCallRecording({ id: "id", }); expect(response).toEqual(undefined); @@ -242,10 +258,10 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.showCallRecording({ + return await client.preview.calls.showCallRecording({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("showCallRecording (3)", async () => { @@ -267,10 +283,10 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.showCallRecording({ + return await client.preview.calls.showCallRecording({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("listCallsWithTranscripts (1)", async () => { @@ -305,6 +321,10 @@ describe("CallsClient", () => { phone: "+15551234567", fin_recording_url: "fin_recording_url", fin_transcription_url: "fin_transcription_url", + duration: 900, + talk_time: 300, + queue_time: 45, + hold_time: 60, transcript: [{ key: "value" }], transcript_status: "completed", }, @@ -319,7 +339,7 @@ describe("CallsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.calls.listCallsWithTranscripts({ + const response = await client.preview.calls.listCallsWithTranscripts({ conversation_ids: ["64619700005694", "64619700005695"], }); expect(response).toEqual({ @@ -345,6 +365,10 @@ describe("CallsClient", () => { phone: "+15551234567", fin_recording_url: "fin_recording_url", fin_transcription_url: "fin_transcription_url", + duration: 900, + talk_time: 300, + queue_time: 45, + hold_time: 60, transcript: [ { key: "value", @@ -376,10 +400,10 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.listCallsWithTranscripts({ + return await client.preview.calls.listCallsWithTranscripts({ conversation_ids: ["conversation_ids", "conversation_ids"], }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("listCallsWithTranscripts (3)", async () => { @@ -402,10 +426,10 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.listCallsWithTranscripts({ + return await client.preview.calls.listCallsWithTranscripts({ conversation_ids: ["conversation_ids", "conversation_ids"], }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("registerFinVoiceCall (1)", async () => { @@ -438,7 +462,7 @@ describe("CallsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.calls.registerFinVoiceCall({ + const response = await client.preview.calls.registerFinVoiceCall({ phone_number: "+1234567890", call_id: "call-123-abc", }); @@ -483,8 +507,8 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.registerFinVoiceCall(undefined); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + return await client.preview.calls.registerFinVoiceCall(undefined); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("registerFinVoiceCall (3)", async () => { @@ -506,8 +530,8 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.registerFinVoiceCall(undefined); - }).rejects.toThrow(Intercom.unstable.ConflictError); + return await client.preview.calls.registerFinVoiceCall(undefined); + }).rejects.toThrow(Intercom.preview.ConflictError); }); test("collectFinVoiceCallById (1)", async () => { @@ -539,7 +563,7 @@ describe("CallsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.calls.collectFinVoiceCallById({ + const response = await client.preview.calls.collectFinVoiceCallById({ id: 1, }); expect(response).toEqual({ @@ -583,10 +607,10 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.collectFinVoiceCallById({ + return await client.preview.calls.collectFinVoiceCallById({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("collectFinVoiceCallByExternalId (1)", async () => { @@ -618,7 +642,7 @@ describe("CallsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.calls.collectFinVoiceCallByExternalId({ + const response = await client.preview.calls.collectFinVoiceCallByExternalId({ external_id: "external_id", }); expect(response).toEqual({ @@ -662,10 +686,10 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.collectFinVoiceCallByExternalId({ + return await client.preview.calls.collectFinVoiceCallByExternalId({ external_id: "external_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("collectFinVoiceCallByPhoneNumber (1)", async () => { @@ -690,7 +714,7 @@ describe("CallsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ + const response = await client.preview.calls.collectFinVoiceCallByPhoneNumber({ phone_number: "phone_number", }); expect(response).toEqual({ @@ -725,10 +749,10 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ + return await client.preview.calls.collectFinVoiceCallByPhoneNumber({ phone_number: "phone_number", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("collectFinVoiceCallByPhoneNumber (3)", async () => { @@ -750,9 +774,92 @@ describe("CallsClient", () => { .build(); await expect(async () => { - return await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ + return await client.preview.calls.collectFinVoiceCallByPhoneNumber({ phone_number: "phone_number", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("collectFinVoiceCallsByConversationId (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = [ + { + id: 12345, + app_id: 12345, + user_phone_number: "+1234567890", + status: "registered", + intercom_call_id: "1234", + external_call_id: "call-123-abc", + intercom_conversation_id: "5678", + call_transcript: [{ key: "value" }], + call_summary: "Customer called about billing issue...", + intent: [{ key: "value" }], + }, + ]; + server + .mockEndpoint() + .get("/fin_voice/conversation/conversation_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.calls.collectFinVoiceCallsByConversationId({ + conversation_id: "conversation_id", + }); + expect(response).toEqual([ + { + id: 12345, + app_id: 12345, + user_phone_number: "+1234567890", + status: "registered", + intercom_call_id: "1234", + external_call_id: "call-123-abc", + intercom_conversation_id: "5678", + call_transcript: [ + { + key: "value", + }, + ], + call_summary: "Customer called about billing issue...", + intent: [ + { + key: "value", + }, + ], + }, + ]); + }); + + test("collectFinVoiceCallsByConversationId (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/fin_voice/conversation/conversation_id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.calls.collectFinVoiceCallsByConversationId({ + conversation_id: "conversation_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/companies.test.ts b/tests/wire/preview/companies.test.ts similarity index 59% rename from tests/wire/unstable/companies.test.ts rename to tests/wire/preview/companies.test.ts index 646e1411..9d795f7a 100644 --- a/tests/wire/unstable/companies.test.ts +++ b/tests/wire/preview/companies.test.ts @@ -43,7 +43,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 4, custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -62,7 +62,7 @@ describe("CompaniesClient", () => { }; server.mockEndpoint().get("/companies").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.companies.retrieveCompany({ + const response = await client.preview.companies.retrieveCompany({ name: "my company", company_id: "12345", tag_id: "678910", @@ -110,6 +110,13 @@ describe("CompaniesClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -144,8 +151,8 @@ describe("CompaniesClient", () => { server.mockEndpoint().get("/companies").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.retrieveCompany(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.companies.retrieveCompany(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveCompany (3)", async () => { @@ -161,8 +168,8 @@ describe("CompaniesClient", () => { server.mockEndpoint().get("/companies").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.retrieveCompany(); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + return await client.preview.companies.retrieveCompany(); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("createOrUpdateCompany (1)", async () => { @@ -192,7 +199,13 @@ describe("CompaniesClient", () => { session_count: 1, user_count: 1, custom_attributes: { custom_attributes: "custom_attributes" }, - tags: { type: "tag.list", tags: [{ key: "value" }, { key: "value" }] }, + tags: { + type: "tag.list", + tags: [ + { type: "type", id: "id", name: "name" }, + { type: "type", id: "id", name: "name" }, + ], + }, segments: { type: "segment.list", segments: [ @@ -237,6 +250,7 @@ describe("CompaniesClient", () => { team_ids: [1, 1], avatar: "avatar", team_priority_level: {}, + role: {}, }, body: "body", }, @@ -258,6 +272,7 @@ describe("CompaniesClient", () => { team_ids: [1, 1], avatar: "avatar", team_priority_level: {}, + role: {}, }, body: "body", }, @@ -273,7 +288,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.createOrUpdateCompany({ + const response = await client.preview.companies.createOrUpdateCompany({ key: "value", }); expect(response).toEqual({ @@ -304,10 +319,14 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "type", + id: "id", + name: "name", }, { - key: "value", + type: "type", + id: "id", + name: "name", }, ], }, @@ -358,6 +377,7 @@ describe("CompaniesClient", () => { team_ids: [1, 1], avatar: "avatar", team_priority_level: {}, + role: {}, }, body: "body", }, @@ -382,6 +402,7 @@ describe("CompaniesClient", () => { team_ids: [1, 1], avatar: "avatar", team_priority_level: {}, + role: {}, }, body: "body", }, @@ -410,10 +431,10 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.createOrUpdateCompany({ + return await client.preview.companies.createOrUpdateCompany({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("createOrUpdateCompany (3)", async () => { @@ -436,10 +457,10 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.createOrUpdateCompany({ + return await client.preview.companies.createOrUpdateCompany({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("RetrieveACompanyById (1)", async () => { @@ -469,7 +490,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -495,7 +516,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.retrieveACompanyById({ + const response = await client.preview.companies.retrieveACompanyById({ id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", }); expect(response).toEqual({ @@ -526,7 +547,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -569,10 +592,10 @@ describe("CompaniesClient", () => { server.mockEndpoint().get("/companies/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.retrieveACompanyById({ + return await client.preview.companies.retrieveACompanyById({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("RetrieveACompanyById (3)", async () => { @@ -588,10 +611,10 @@ describe("CompaniesClient", () => { server.mockEndpoint().get("/companies/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.retrieveACompanyById({ + return await client.preview.companies.retrieveACompanyById({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("UpdateCompany (1)", async () => { @@ -621,7 +644,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -647,7 +670,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.updateCompany({ + const response = await client.preview.companies.updateCompany({ id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", }); expect(response).toEqual({ @@ -678,7 +701,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -721,10 +746,10 @@ describe("CompaniesClient", () => { server.mockEndpoint().put("/companies/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.updateCompany({ + return await client.preview.companies.updateCompany({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("UpdateCompany (3)", async () => { @@ -740,10 +765,10 @@ describe("CompaniesClient", () => { server.mockEndpoint().put("/companies/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.updateCompany({ + return await client.preview.companies.updateCompany({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("deleteCompany (1)", async () => { @@ -764,7 +789,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.deleteCompany({ + const response = await client.preview.companies.deleteCompany({ id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", }); expect(response).toEqual({ @@ -787,10 +812,10 @@ describe("CompaniesClient", () => { server.mockEndpoint().delete("/companies/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.deleteCompany({ + return await client.preview.companies.deleteCompany({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteCompany (3)", async () => { @@ -806,10 +831,10 @@ describe("CompaniesClient", () => { server.mockEndpoint().delete("/companies/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.deleteCompany({ + return await client.preview.companies.deleteCompany({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("ListAttachedContacts (1)", async () => { @@ -835,7 +860,7 @@ describe("CompaniesClient", () => { phone: "+1123456789", formatted_phone: "+1123456789", name: "John Doe", - owner_id: 123, + owner_id: "321", has_hard_bounced: true, marked_email_as_spam: true, unsubscribed_from_emails: true, @@ -874,6 +899,9 @@ describe("CompaniesClient", () => { has_more: true, }, location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + merge_history: [ + { type: "merge_history", source_contact_id: "5ba682d23d7cf92bef87bfd3", merged_at: 1571672154 }, + ], }, ], total_count: 0, @@ -893,7 +921,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.listAttachedContacts({ + const response = await client.preview.companies.listAttachedContacts({ id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", }); expect(response).toEqual({ @@ -910,7 +938,7 @@ describe("CompaniesClient", () => { phone: "+1123456789", formatted_phone: "+1123456789", name: "John Doe", - owner_id: 123, + owner_id: "321", has_hard_bounced: true, marked_email_as_spam: true, unsubscribed_from_emails: true, @@ -967,6 +995,13 @@ describe("CompaniesClient", () => { region: "Dublin", city: "Dublin", }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + merged_at: 1571672154, + }, + ], }, ], total_count: 0, @@ -1002,10 +1037,10 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.listAttachedContacts({ + return await client.preview.companies.listAttachedContacts({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("ListAttachedContacts (3)", async () => { @@ -1027,10 +1062,10 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.listAttachedContacts({ + return await client.preview.companies.listAttachedContacts({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("ListAttachedSegmentsForCompanies (1)", async () => { @@ -1064,7 +1099,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.listAttachedSegmentsForCompanies({ + const response = await client.preview.companies.listAttachedSegmentsForCompanies({ id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", }); expect(response).toEqual({ @@ -1102,10 +1137,10 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.listAttachedSegmentsForCompanies({ + return await client.preview.companies.listAttachedSegmentsForCompanies({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("ListAttachedSegmentsForCompanies (3)", async () => { @@ -1127,10 +1162,184 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.listAttachedSegmentsForCompanies({ + return await client.preview.companies.listAttachedSegmentsForCompanies({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("searchCompanies (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + query: { operator: "AND", value: [{ field: "name", operator: "=", value: "my-company" }] }, + pagination: { per_page: 5 }, + sort: { field: "name", order: "ascending" }, + }; + const rawResponseBody = { + type: "list", + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 5, + total_pages: 0, + }, + total_count: 0, + data: [ + { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { type: "plan", id: "269315", name: "Pro" }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + }, + ], + }; + server + .mockEndpoint() + .post("/companies/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.companies.searchCompanies({ + query: { + operator: "AND", + value: [ + { + field: "name", + operator: "=", + value: "my-company", + }, + ], + }, + pagination: { + per_page: 5, + }, + sort: { + field: "name", + order: "ascending", + }, + }); + expect(response).toEqual({ + type: "list", + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 5, + total_pages: 0, + }, + total_count: 0, + data: [ + { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + }, + ], + }); + }); + + test("searchCompanies (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { query: {} }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/companies/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.searchCompanies({ + query: {}, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("searchCompanies (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { query: {} }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/companies/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.searchCompanies({ + query: {}, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("listAllCompanies (1)", async () => { @@ -1171,7 +1380,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 4, custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -1190,7 +1399,7 @@ describe("CompaniesClient", () => { }; server.mockEndpoint().post("/companies/list").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.companies.listAllCompanies({ + const response = await client.preview.companies.listAllCompanies({ page: 1, per_page: 1, order: "desc", @@ -1235,6 +1444,13 @@ describe("CompaniesClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -1269,8 +1485,8 @@ describe("CompaniesClient", () => { server.mockEndpoint().post("/companies/list").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.listAllCompanies(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.companies.listAllCompanies(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("scrollOverAllCompanies (1)", async () => { @@ -1303,7 +1519,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 4, custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -1331,7 +1547,7 @@ describe("CompaniesClient", () => { }; server.mockEndpoint().get("/companies/scroll").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.companies.scrollOverAllCompanies({ + const response = await client.preview.companies.scrollOverAllCompanies({ scroll_param: "scroll_param", }); expect(response).toEqual({ @@ -1363,6 +1579,13 @@ describe("CompaniesClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -1409,8 +1632,8 @@ describe("CompaniesClient", () => { server.mockEndpoint().get("/companies/scroll").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.companies.scrollOverAllCompanies(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.companies.scrollOverAllCompanies(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("attachContactToACompany (1)", async () => { @@ -1440,7 +1663,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -1467,7 +1690,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.attachContactToACompany({ + const response = await client.preview.companies.attachContactToACompany({ id: "id", company_id: "6762f09a1bb69f9f2193bb34", }); @@ -1499,7 +1722,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -1556,7 +1781,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -1583,7 +1808,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.attachContactToACompany({ + const response = await client.preview.companies.attachContactToACompany({ id: "id", company_id: "58a430d35458202d41b1e65b", }); @@ -1615,7 +1840,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -1672,7 +1899,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 1, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -1699,7 +1926,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.attachContactToACompany({ + const response = await client.preview.companies.attachContactToACompany({ id: "id", company_id: "123", }); @@ -1731,7 +1958,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -1781,11 +2010,11 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.attachContactToACompany({ + return await client.preview.companies.attachContactToACompany({ id: "id", company_id: "company_id", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("attachContactToACompany (5)", async () => { @@ -1808,11 +2037,11 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.attachContactToACompany({ + return await client.preview.companies.attachContactToACompany({ id: "id", company_id: "company_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("attachContactToACompany (6)", async () => { @@ -1835,11 +2064,11 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.attachContactToACompany({ + return await client.preview.companies.attachContactToACompany({ id: "id", company_id: "company_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("detachContactFromACompany (1)", async () => { @@ -1869,7 +2098,7 @@ describe("CompaniesClient", () => { session_count: 0, user_count: 0, custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -1895,7 +2124,7 @@ describe("CompaniesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.companies.detachContactFromACompany({ + const response = await client.preview.companies.detachContactFromACompany({ contact_id: "58a430d35458202d41b1e65b", id: "58a430d35458202d41b1e65b", }); @@ -1927,7 +2156,9 @@ describe("CompaniesClient", () => { type: "tag.list", tags: [ { - key: "value", + type: "tag", + id: "123456", + name: "Test tag", }, ], }, @@ -1976,11 +2207,11 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.detachContactFromACompany({ + return await client.preview.companies.detachContactFromACompany({ contact_id: "contact_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("detachContactFromACompany (3)", async () => { @@ -2002,10 +2233,929 @@ describe("CompaniesClient", () => { .build(); await expect(async () => { - return await client.unstable.companies.detachContactFromACompany({ + return await client.preview.companies.detachContactFromACompany({ contact_id: "contact_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("BulkCreateCompanies (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + companies: [ + { + company_id: "abc123", + name: "Acme Corp", + plan: "Enterprise", + size: 100, + website: "https://www.example.com", + industry: "Manufacturing", + custom_attributes: { paid_subscriber: true, team_mates: 9 }, + remote_created_at: 1394531169, + monthly_spend: 1000, + update_last_request_at: true, + }, + { company_id: "def456", name: "Example Inc", industry: "Manufacturing" }, + ], + }; + const rawResponseBody = { + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }; + server + .mockEndpoint() + .post("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.companies.bulkCreateCompanies({ + companies: [ + { + company_id: "abc123", + name: "Acme Corp", + plan: "Enterprise", + size: 100, + website: "https://www.example.com", + industry: "Manufacturing", + custom_attributes: { + paid_subscriber: true, + team_mates: 9, + }, + remote_created_at: 1394531169, + monthly_spend: 1000, + update_last_request_at: true, + }, + { + company_id: "def456", + name: "Example Inc", + industry: "Manufacturing", + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }); + }); + + test("BulkCreateCompanies (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ company_id: "abc123", monthly_spend: 1000 }], job: { id: "job_v2_1" } }; + const rawResponseBody = { + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }; + server + .mockEndpoint() + .post("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.companies.bulkCreateCompanies({ + companies: [ + { + company_id: "abc123", + monthly_spend: 1000, + }, + ], + job: { + id: "job_v2_1", + }, + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }); + }); + + test("BulkCreateCompanies (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{}, {}] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkCreateCompanies({ + companies: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("BulkCreateCompanies (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{}, {}] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkCreateCompanies({ + companies: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("BulkCreateCompanies (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{}, {}] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkCreateCompanies({ + companies: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("BulkCreateCompanies (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{}, {}] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkCreateCompanies({ + companies: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("BulkUpdateCompanies (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + companies: [ + { + id: "531ee472cce572a6ec000006", + name: "Acme Corp", + plan: "Enterprise", + size: 100, + website: "https://www.example.com", + industry: "Manufacturing", + custom_attributes: { paid_subscriber: true, team_mates: 9 }, + remote_created_at: 1394531169, + monthly_spend: 1000, + update_last_request_at: true, + }, + { id: "531ee472cce572a6ec000007", name: "Example Inc" }, + ], + }; + const rawResponseBody = { + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }; + server + .mockEndpoint() + .put("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.companies.bulkUpdateCompanies({ + companies: [ + { + id: "531ee472cce572a6ec000006", + name: "Acme Corp", + plan: "Enterprise", + size: 100, + website: "https://www.example.com", + industry: "Manufacturing", + custom_attributes: { + paid_subscriber: true, + team_mates: 9, + }, + remote_created_at: 1394531169, + monthly_spend: 1000, + update_last_request_at: true, + }, + { + id: "531ee472cce572a6ec000007", + name: "Example Inc", + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }); + }); + + test("BulkUpdateCompanies (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + companies: [{ id: "531ee472cce572a6ec000006", monthly_spend: 1000 }], + job: { id: "job_v2_1" }, + }; + const rawResponseBody = { + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }; + server + .mockEndpoint() + .put("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.companies.bulkUpdateCompanies({ + companies: [ + { + id: "531ee472cce572a6ec000006", + monthly_spend: 1000, + }, + ], + job: { + id: "job_v2_1", + }, + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }); + }); + + test("BulkUpdateCompanies (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkUpdateCompanies({ + companies: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("BulkUpdateCompanies (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkUpdateCompanies({ + companies: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("BulkUpdateCompanies (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkUpdateCompanies({ + companies: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("BulkUpdateCompanies (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/companies/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkUpdateCompanies({ + companies: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("BulkDeleteCompanies (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "531ee472cce572a6ec000006" }, { id: "531ee472cce572a6ec000007" }] }; + const rawResponseBody = { + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }; + server + .mockEndpoint() + .post("/companies/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.companies.bulkDeleteCompanies({ + companies: [ + { + id: "531ee472cce572a6ec000006", + }, + { + id: "531ee472cce572a6ec000007", + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }); + }); + + test("BulkDeleteCompanies (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "531ee472cce572a6ec000006" }], job: { id: "job_v2_1" } }; + const rawResponseBody = { + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }; + server + .mockEndpoint() + .post("/companies/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.companies.bulkDeleteCompanies({ + companies: [ + { + id: "531ee472cce572a6ec000006", + }, + ], + job: { + id: "job_v2_1", + }, + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "companies.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }); + }); + + test("BulkDeleteCompanies (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/companies/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkDeleteCompanies({ + companies: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("BulkDeleteCompanies (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/companies/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkDeleteCompanies({ + companies: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("BulkDeleteCompanies (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/companies/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkDeleteCompanies({ + companies: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("BulkDeleteCompanies (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { companies: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/companies/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.companies.bulkDeleteCompanies({ + companies: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("ShowBulkCompaniesJob (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "job_v2_1", + type: "companies.bulk.job", + state: "completed", + created_at: 1713360000, + updated_at: 1713360120, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "completed", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }; + server + .mockEndpoint() + .get("/companies/bulk/job_v2_1") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.companies.showBulkCompaniesJob({ + id: "job_v2_1", + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "companies.bulk.job", + state: "completed", + created_at: 1713360000, + updated_at: 1713360120, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 2, + state: "completed", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/companies/bulk/job_v2_1", + }); + }); + + test("ShowBulkCompaniesJob (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/companies/bulk/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.companies.showBulkCompaniesJob({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/preview/contacts.test.ts b/tests/wire/preview/contacts.test.ts new file mode 100644 index 00000000..ee9f6c34 --- /dev/null +++ b/tests/wire/preview/contacts.test.ts @@ -0,0 +1,5133 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ContactsClient", () => { + test("listCompaniesForAContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + companies: [ + { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { type: "plan", id: "269315", name: "Pro" }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + }, + ], + total_count: 1, + pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, + }; + server + .mockEndpoint() + .get("/contacts/63a07ddf05a32042dffac965/companies") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.listCompaniesForAContact({ + id: "63a07ddf05a32042dffac965", + }); + expect(response).toEqual({ + type: "list", + companies: [ + { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 50, + total_pages: 1, + }, + }); + }); + + test("listCompaniesForAContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/id/companies") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listCompaniesForAContact({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listCompaniesForAContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/contacts/id/companies") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listCompaniesForAContact({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listGrantedCompaniesForAContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + company_ids: ["acme-corp", "1234"], + pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, + total_count: 2, + }; + server + .mockEndpoint() + .get("/contacts/63a07ddf05a32042dffac965/granted_companies") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.listGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + page: 1, + per_page: 1, + order: "asc", + }); + expect(response).toEqual({ + type: "list", + company_ids: ["acme-corp", "1234"], + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 50, + total_pages: 1, + }, + total_count: 2, + }); + }); + + test("listGrantedCompaniesForAContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + company_ids: ["acme-corp"], + pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 0 }, + total_count: 0, + }; + server + .mockEndpoint() + .get("/contacts/63a07ddf05a32042dffac965/granted_companies") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.listGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + page: 1, + per_page: 1, + order: "asc", + }); + expect(response).toEqual({ + type: "list", + company_ids: ["acme-corp"], + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 50, + total_pages: 0, + }, + total_count: 0, + }); + }); + + test("listGrantedCompaniesForAContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/contact_id/granted_companies") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listGrantedCompaniesForAContact({ + contact_id: "contact_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listGrantedCompaniesForAContact (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/contacts/contact_id/granted_companies") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listGrantedCompaniesForAContact({ + contact_id: "contact_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("replaceGrantedCompaniesForAContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["acme-corp", "1234", "globex"] }; + const rawResponseBody = { + type: "list", + company_ids: ["acme-corp", "1234", "globex"], + pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, + total_count: 3, + }; + server + .mockEndpoint() + .put("/contacts/63a07ddf05a32042dffac965/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + company_ids: ["acme-corp", "1234", "globex"], + }); + expect(response).toEqual({ + type: "list", + company_ids: ["acme-corp", "1234", "globex"], + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 50, + total_pages: 1, + }, + total_count: 3, + }); + }); + + test("replaceGrantedCompaniesForAContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["globex"] }; + const rawResponseBody = { + type: "list", + company_ids: ["acme-corp", "1234", "globex"], + pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, + total_count: 3, + }; + server + .mockEndpoint() + .put("/contacts/63a07ddf05a32042dffac965/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + company_ids: ["globex"], + }); + expect(response).toEqual({ + type: "list", + company_ids: ["acme-corp", "1234", "globex"], + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 50, + total_pages: 1, + }, + total_count: 3, + }); + }); + + test("replaceGrantedCompaniesForAContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["acme-corp", "1234"] }; + const rawResponseBody = { + type: "list", + company_ids: ["acme-corp", "1234", "globex"], + pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, + total_count: 3, + }; + server + .mockEndpoint() + .put("/contacts/63a07ddf05a32042dffac965/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + company_ids: ["acme-corp", "1234"], + }); + expect(response).toEqual({ + type: "list", + company_ids: ["acme-corp", "1234", "globex"], + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 50, + total_pages: 1, + }, + total_count: 3, + }); + }); + + test("replaceGrantedCompaniesForAContact (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["acme-corp", "1234", "globex"] }; + const rawResponseBody = { + type: "list", + company_ids: ["acme-corp", "1234", "globex"], + pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, + total_count: 3, + }; + server + .mockEndpoint() + .put("/contacts/63a07ddf05a32042dffac965/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + company_ids: ["acme-corp", "1234", "globex"], + }); + expect(response).toEqual({ + type: "list", + company_ids: ["acme-corp", "1234", "globex"], + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 50, + total_pages: 1, + }, + total_count: 3, + }); + }); + + test("replaceGrantedCompaniesForAContact (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["acme-corp", "1234", "globex"] }; + const rawResponseBody = { + type: "list", + company_ids: ["acme-corp"], + pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, + total_count: 0, + }; + server + .mockEndpoint() + .put("/contacts/63a07ddf05a32042dffac965/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "63a07ddf05a32042dffac965", + company_ids: ["acme-corp", "1234", "globex"], + }); + expect(response).toEqual({ + type: "list", + company_ids: ["acme-corp"], + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 50, + total_pages: 1, + }, + total_count: 0, + }); + }); + + test("replaceGrantedCompaniesForAContact (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["company_ids", "company_ids"] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/contacts/contact_id/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "contact_id", + company_ids: ["company_ids", "company_ids"], + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("replaceGrantedCompaniesForAContact (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["company_ids", "company_ids"] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/contacts/contact_id/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "contact_id", + company_ids: ["company_ids", "company_ids"], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("replaceGrantedCompaniesForAContact (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["company_ids", "company_ids"] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/contacts/contact_id/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "contact_id", + company_ids: ["company_ids", "company_ids"], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("replaceGrantedCompaniesForAContact (9)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { company_ids: ["company_ids", "company_ids"] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/contacts/contact_id/granted_companies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(503) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.replaceGrantedCompaniesForAContact({ + contact_id: "contact_id", + company_ids: ["company_ids", "company_ids"], + }); + }).rejects.toThrow(Intercom.preview.ServiceUnavailableError); + }); + + test("removeGrantedCompanyFromAContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/contacts/63a07ddf05a32042dffac965/granted_companies/acme-corp") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.preview.contacts.removeGrantedCompanyFromAContact({ + contact_id: "63a07ddf05a32042dffac965", + company_id: "acme-corp", + }); + expect(response).toEqual(undefined); + }); + + test("removeGrantedCompanyFromAContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/contacts/contact_id/granted_companies/company_id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.removeGrantedCompanyFromAContact({ + contact_id: "contact_id", + company_id: "company_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("removeGrantedCompanyFromAContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/contacts/contact_id/granted_companies/company_id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.removeGrantedCompanyFromAContact({ + contact_id: "contact_id", + company_id: "company_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listSegmentsForAContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "segment", + id: "6762f0b21bb69f9f2193bb65", + name: "segment", + created_at: 1734537394, + updated_at: 1734537394, + person_type: "user", + count: 3, + }, + ], + }; + server + .mockEndpoint() + .get("/contacts/63a07ddf05a32042dffac965/segments") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.listSegmentsForAContact({ + contact_id: "63a07ddf05a32042dffac965", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "segment", + id: "6762f0b21bb69f9f2193bb65", + name: "segment", + created_at: 1734537394, + updated_at: 1734537394, + person_type: "user", + count: 3, + }, + ], + }); + }); + + test("listSegmentsForAContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/contact_id/segments") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listSegmentsForAContact({ + contact_id: "contact_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listSegmentsForAContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/contacts/contact_id/segments") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listSegmentsForAContact({ + contact_id: "contact_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listSubscriptionsForAContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "subscription", + id: "91", + state: "live", + default_translation: { + name: "Newsletters", + description: "Lorem ipsum dolor sit amet", + locale: "en", + }, + translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], + consent_type: "opt_out", + content_types: ["email"], + }, + { + type: "subscription", + id: "93", + state: "live", + default_translation: { + name: "Newsletters", + description: "Lorem ipsum dolor sit amet", + locale: "en", + }, + translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], + consent_type: "opt_in", + content_types: ["sms_message"], + }, + ], + }; + server + .mockEndpoint() + .get("/contacts/63a07ddf05a32042dffac965/subscriptions") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.listSubscriptionsForAContact({ + contact_id: "63a07ddf05a32042dffac965", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "subscription", + id: "91", + state: "live", + default_translation: { + name: "Newsletters", + description: "Lorem ipsum dolor sit amet", + locale: "en", + }, + translations: [ + { + name: "Newsletters", + description: "Lorem ipsum dolor sit amet", + locale: "en", + }, + ], + consent_type: "opt_out", + content_types: ["email"], + }, + { + type: "subscription", + id: "93", + state: "live", + default_translation: { + name: "Newsletters", + description: "Lorem ipsum dolor sit amet", + locale: "en", + }, + translations: [ + { + name: "Newsletters", + description: "Lorem ipsum dolor sit amet", + locale: "en", + }, + ], + consent_type: "opt_in", + content_types: ["sms_message"], + }, + ], + }); + }); + + test("listSubscriptionsForAContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/contact_id/subscriptions") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listSubscriptionsForAContact({ + contact_id: "contact_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listSubscriptionsForAContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/contacts/contact_id/subscriptions") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listSubscriptionsForAContact({ + contact_id: "contact_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listTagsForAContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "tag", + id: "80", + name: "Manual tag", + applied_at: 1663597223, + applied_by: { type: "admin", id: "456" }, + }, + ], + }; + server + .mockEndpoint() + .get("/contacts/63a07ddf05a32042dffac965/tags") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.listTagsForAContact({ + contact_id: "63a07ddf05a32042dffac965", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "tag", + id: "80", + name: "Manual tag", + applied_at: 1663597223, + applied_by: { + type: "admin", + id: "456", + }, + }, + ], + }); + }); + + test("listTagsForAContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/contact_id/tags") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listTagsForAContact({ + contact_id: "contact_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listTagsForAContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/contacts/contact_id/tags") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listTagsForAContact({ + contact_id: "contact_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listDeletedContacts (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + email: "joe@example.com", + role: "user", + status: "archived", + merged_into_id: "5ba682d23d7cf92bef87bfd9", + updated_at: 1756636800, + }, + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd5", + external_id: "71", + email: "jane@example.com", + role: "user", + status: "merged", + merged_into_id: "5ba682d23d7cf92bef87bfd9", + updated_at: 1756636800, + }, + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd6", + external_id: "70", + email: "joe@example.com", + role: "user", + status: "permanently_deleted", + merged_into_id: "5ba682d23d7cf92bef87bfd9", + updated_at: 1756636800, + }, + ], + total_count: 3, + pages: { type: "pages", page: 1, per_page: 10, total_pages: 1 }, + }; + server.mockEndpoint().get("/contacts/deleted").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.contacts.listDeletedContacts({ + per_page: 1, + page: 1, + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + email: "joe@example.com", + role: "user", + status: "archived", + merged_into_id: "5ba682d23d7cf92bef87bfd9", + updated_at: 1756636800, + }, + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd5", + external_id: "71", + email: "jane@example.com", + role: "user", + status: "merged", + merged_into_id: "5ba682d23d7cf92bef87bfd9", + updated_at: 1756636800, + }, + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd6", + external_id: "70", + email: "joe@example.com", + role: "user", + status: "permanently_deleted", + merged_into_id: "5ba682d23d7cf92bef87bfd9", + updated_at: 1756636800, + }, + ], + total_count: 3, + pages: { + type: "pages", + page: 1, + per_page: 10, + total_pages: 1, + }, + }); + }); + + test("listDeletedContacts (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/contacts/deleted").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.contacts.listDeletedContacts(); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("listDeletedContacts (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/contacts/deleted").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.contacts.listDeletedContacts(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("ShowContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "contact", + id: "6762f0d01bb69f9f2193bb7d", + external_id: "70", + workspace_id: "this_is_an_id283_that_should_be_at_least_", + role: "user", + email: "joe@bloggs.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "Joe Bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537424, + updated_at: 1734537424, + signed_up_at: 1734537424, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { key: "value" }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0d01bb69f9f2193bb7d/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0d01bb69f9f2193bb7d/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], + url: "/contacts/6762f0d01bb69f9f2193bb7d/companies", + total_count: 0, + has_more: false, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + social_profiles: { + data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }; + server + .mockEndpoint() + .get("/contacts/63a07ddf05a32042dffac965") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.showContact({ + id: "63a07ddf05a32042dffac965", + include_merge_history: true, + }); + expect(response).toEqual({ + type: "contact", + id: "6762f0d01bb69f9f2193bb7d", + external_id: "70", + workspace_id: "this_is_an_id283_that_should_be_at_least_", + role: "user", + email: "joe@bloggs.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "Joe Bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537424, + updated_at: 1734537424, + signed_up_at: 1734537424, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + key: "value", + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0d01bb69f9f2193bb7d/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0d01bb69f9f2193bb7d/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [ + { + id: "5ba682d23d7cf92bef87bfd4", + url: "/companies/5ba682d23d7cf92bef87bfd4", + }, + ], + url: "/contacts/6762f0d01bb69f9f2193bb7d/companies", + total_count: 0, + has_more: false, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + social_profiles: { + data: [ + { + type: "social_profile", + name: "Facebook", + url: "http://twitter.com/th1sland", + }, + ], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }); + }); + + test("ShowContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/contacts/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.contacts.showContact({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("ShowContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/contacts/id").respondWith().statusCode(410).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.contacts.showContact({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.GoneError); + }); + + test("UpdateContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { email: "joebloggs@intercom.io", name: "joe bloggs" }; + const rawResponseBody = { + type: "contact", + id: "6762f0cd1bb69f9f2193bb7c", + external_id: "70", + workspace_id: "this_is_an_id279_that_should_be_at_least_", + role: "user", + email: "joebloggs@intercom.io", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "joe bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537421, + updated_at: 1734537422, + signed_up_at: 1734537421, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { key: "value" }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", + total_count: 0, + has_more: false, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + social_profiles: { + data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }; + server + .mockEndpoint() + .put("/contacts/63a07ddf05a32042dffac965") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.updateContact({ + id: "63a07ddf05a32042dffac965", + include_merge_history: true, + email: "joebloggs@intercom.io", + name: "joe bloggs", + }); + expect(response).toEqual({ + type: "contact", + id: "6762f0cd1bb69f9f2193bb7c", + external_id: "70", + workspace_id: "this_is_an_id279_that_should_be_at_least_", + role: "user", + email: "joebloggs@intercom.io", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "joe bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537421, + updated_at: 1734537422, + signed_up_at: 1734537421, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + key: "value", + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [ + { + id: "5ba682d23d7cf92bef87bfd4", + url: "/companies/5ba682d23d7cf92bef87bfd4", + }, + ], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", + total_count: 0, + has_more: false, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + social_profiles: { + data: [ + { + type: "social_profile", + name: "Facebook", + url: "http://twitter.com/th1sland", + }, + ], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }); + }); + + test("UpdateContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { custom_attributes: { order: ["21"] } }; + const rawResponseBody = { + type: "contact", + id: "6762f0cd1bb69f9f2193bb7c", + external_id: "70", + workspace_id: "this_is_an_id279_that_should_be_at_least_", + role: "user", + email: "joebloggs@intercom.io", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "joe bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537421, + updated_at: 1734537422, + signed_up_at: 1734537421, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + order: { + type: "Order.list", + instances: [ + { + id: "21", + external_id: "123", + external_created_at: 1392036272, + external_updated_at: 1392036272, + custom_attributes: { order_number: "ORDER-12345", total_amount: 99.99 }, + type: "Order", + }, + ], + }, + }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", + total_count: 0, + has_more: false, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + social_profiles: { + data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }; + server + .mockEndpoint() + .put("/contacts/63a07ddf05a32042dffac965") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.updateContact({ + id: "63a07ddf05a32042dffac965", + include_merge_history: true, + custom_attributes: { + order: ["21"], + }, + }); + expect(response).toEqual({ + type: "contact", + id: "6762f0cd1bb69f9f2193bb7c", + external_id: "70", + workspace_id: "this_is_an_id279_that_should_be_at_least_", + role: "user", + email: "joebloggs@intercom.io", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "joe bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537421, + updated_at: 1734537422, + signed_up_at: 1734537421, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + order: { + type: "Order.list", + instances: [ + { + id: "21", + external_id: "123", + external_created_at: 1392036272, + external_updated_at: 1392036272, + custom_attributes: { + order_number: "ORDER-12345", + total_amount: 99.99, + }, + type: "Order", + }, + ], + }, + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [ + { + id: "5ba682d23d7cf92bef87bfd4", + url: "/companies/5ba682d23d7cf92bef87bfd4", + }, + ], + url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", + total_count: 0, + has_more: false, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + social_profiles: { + data: [ + { + type: "social_profile", + name: "Facebook", + url: "http://twitter.com/th1sland", + }, + ], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }); + }); + + test("UpdateContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/contacts/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.updateContact({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("DeleteContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", deleted: true }; + server.mockEndpoint().delete("/contacts/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.contacts.deleteContact({ + id: "id", + }); + expect(response).toEqual({ + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + deleted: true, + }); + }); + + test("DeleteContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/contacts/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.contacts.deleteContact({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("MergeContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { from: "6762f0d51bb69f9f2193bb7f", into: "6762f0d51bb69f9f2193bb80" }; + const rawResponseBody = { + type: "contact", + id: "6762f0d51bb69f9f2193bb80", + external_id: "70", + workspace_id: "this_is_an_id291_that_should_be_at_least_", + role: "user", + email: "joe@bloggs.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "Joe Bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537429, + updated_at: 1734537430, + signed_up_at: 1734537429, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { key: "value" }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0d51bb69f9f2193bb80/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0d51bb69f9f2193bb80/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], + url: "/contacts/6762f0d51bb69f9f2193bb80/companies", + total_count: 0, + has_more: false, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + social_profiles: { + data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }; + server + .mockEndpoint() + .post("/contacts/merge") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.mergeContact({ + include_merge_history: true, + from: "6762f0d51bb69f9f2193bb7f", + into: "6762f0d51bb69f9f2193bb80", + }); + expect(response).toEqual({ + type: "contact", + id: "6762f0d51bb69f9f2193bb80", + external_id: "70", + workspace_id: "this_is_an_id291_that_should_be_at_least_", + role: "user", + email: "joe@bloggs.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "Joe Bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537429, + updated_at: 1734537430, + signed_up_at: 1734537429, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + key: "value", + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0d51bb69f9f2193bb80/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0d51bb69f9f2193bb80/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [ + { + id: "5ba682d23d7cf92bef87bfd4", + url: "/companies/5ba682d23d7cf92bef87bfd4", + }, + ], + url: "/contacts/6762f0d51bb69f9f2193bb80/companies", + total_count: 0, + has_more: false, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + social_profiles: { + data: [ + { + type: "social_profile", + name: "Facebook", + url: "http://twitter.com/th1sland", + }, + ], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }); + }); + + test("MergeContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + from: "6762f0d51bb69f9f2193bb7f", + into: "6762f0d51bb69f9f2193bb80", + skip_duplicate_validation: true, + }; + const rawResponseBody = { + type: "contact", + id: "6762f0d51bb69f9f2193bb80", + external_id: "70", + workspace_id: "this_is_an_id291_that_should_be_at_least_", + role: "user", + email: "joe@bloggs.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "Joe Bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537429, + updated_at: 1734537430, + signed_up_at: 1734537429, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { key: "value" }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0d51bb69f9f2193bb80/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0d51bb69f9f2193bb80/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], + url: "/contacts/6762f0d51bb69f9f2193bb80/companies", + total_count: 0, + has_more: false, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + social_profiles: { + data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }; + server + .mockEndpoint() + .post("/contacts/merge") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.mergeContact({ + include_merge_history: true, + from: "6762f0d51bb69f9f2193bb7f", + into: "6762f0d51bb69f9f2193bb80", + skip_duplicate_validation: true, + }); + expect(response).toEqual({ + type: "contact", + id: "6762f0d51bb69f9f2193bb80", + external_id: "70", + workspace_id: "this_is_an_id291_that_should_be_at_least_", + role: "user", + email: "joe@bloggs.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "Joe Bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537429, + updated_at: 1734537430, + signed_up_at: 1734537429, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + key: "value", + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0d51bb69f9f2193bb80/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0d51bb69f9f2193bb80/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [ + { + id: "5ba682d23d7cf92bef87bfd4", + url: "/companies/5ba682d23d7cf92bef87bfd4", + }, + ], + url: "/contacts/6762f0d51bb69f9f2193bb80/companies", + total_count: 0, + has_more: false, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + social_profiles: { + data: [ + { + type: "social_profile", + name: "Facebook", + url: "http://twitter.com/th1sland", + }, + ], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }); + }); + + test("MergeContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { from: "from", into: "into" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/contacts/merge") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.mergeContact({ + from: "from", + into: "into", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("MergeContact (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { from: "from", into: "into" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/contacts/merge") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.mergeContact({ + from: "from", + into: "into", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("PreviewMergeContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { from: "6762f0d51bb69f9f2193bb7f", into: "6762f0d51bb69f9f2193bb80" }; + const rawResponseBody = { + allowed: true, + summary: { + attribute_changes: { + attributes: [ + { field: "name", outcome: "adopted", from_value: "Jo", new_into_value: "Jo" }, + { + field: "companies", + outcome: "merged", + from_value: ["Beta"], + into_value: ["Acme"], + new_into_value: ["Acme", "Beta"], + }, + { + field: "phone", + outcome: "discarded", + from_value: "+1555", + into_value: "+1999", + new_into_value: "+1999", + }, + ], + total_count: 3, + }, + reassignments: { + conversations: { from: 12, into: 5 }, + tickets: { from: 2, into: 1 }, + phone_calls: { from: 1, into: 0 }, + tags: { from: 3, into: 4 }, + notes: { from: 2, into: 6 }, + }, + }, + }; + server + .mockEndpoint() + .post("/contacts/merge/preview") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.previewMergeContact({ + from: "6762f0d51bb69f9f2193bb7f", + into: "6762f0d51bb69f9f2193bb80", + }); + expect(response).toEqual({ + allowed: true, + summary: { + attribute_changes: { + attributes: [ + { + field: "name", + outcome: "adopted", + from_value: "Jo", + new_into_value: "Jo", + }, + { + field: "companies", + outcome: "merged", + from_value: ["Beta"], + into_value: ["Acme"], + new_into_value: ["Acme", "Beta"], + }, + { + field: "phone", + outcome: "discarded", + from_value: "+1555", + into_value: "+1999", + new_into_value: "+1999", + }, + ], + total_count: 3, + }, + reassignments: { + conversations: { + from: 12, + into: 5, + }, + tickets: { + from: 2, + into: 1, + }, + phone_calls: { + from: 1, + into: 0, + }, + tags: { + from: 3, + into: 4, + }, + notes: { + from: 2, + into: 6, + }, + }, + }, + }); + }); + + test("PreviewMergeContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { from: "6762f0d51bb69f9f2193bb7f", into: "6762f0d51bb69f9f2193bb80" }; + const rawResponseBody = { + allowed: false, + reasons: [ + { + code: "no_shared_identifier", + message: + "These contacts don't share a common identifier (email or phone), so they aren't recognised as duplicates. Set skip_duplicate_validation to true to preview the merge anyway.", + }, + ], + }; + server + .mockEndpoint() + .post("/contacts/merge/preview") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.previewMergeContact({ + from: "6762f0d51bb69f9f2193bb7f", + into: "6762f0d51bb69f9f2193bb80", + }); + expect(response).toEqual({ + allowed: false, + reasons: [ + { + code: "no_shared_identifier", + message: + "These contacts don't share a common identifier (email or phone), so they aren't recognised as duplicates. Set skip_duplicate_validation to true to preview the merge anyway.", + }, + ], + }); + }); + + test("PreviewMergeContact (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { from: "from", into: "into" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/contacts/merge/preview") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.previewMergeContact({ + from: "from", + into: "into", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("SearchContacts (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, + pagination: { per_page: 5 }, + sort: { field: "created_at", order: "ascending" }, + }; + const rawResponseBody = { + type: "list", + data: [ + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "f3b87a2e09d514c6c2e79b9a", + workspace_id: "ecahpwf5", + role: "user", + email: "joe@example.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "John Doe", + owner_id: "321", + has_hard_bounced: true, + marked_email_as_spam: true, + unsubscribed_from_emails: true, + created_at: 1571672154, + updated_at: 1571672154, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { key: "value" }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, + notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, + companies: { + url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", + total_count: 100, + has_more: true, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + merge_history: [ + { type: "merge_history", source_contact_id: "5ba682d23d7cf92bef87bfd3", merged_at: 1571672154 }, + ], + }, + ], + total_count: 0, + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 5, + total_pages: 0, + }, + }; + server + .mockEndpoint() + .post("/contacts/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.searchContacts({ + include_merge_history: true, + query: { + operator: "AND", + value: [ + { + field: "created_at", + operator: ">", + value: "1306054154", + }, + ], + }, + pagination: { + per_page: 5, + }, + sort: { + field: "created_at", + order: "ascending", + }, + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "f3b87a2e09d514c6c2e79b9a", + workspace_id: "ecahpwf5", + role: "user", + email: "joe@example.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "John Doe", + owner_id: "321", + has_hard_bounced: true, + marked_email_as_spam: true, + unsubscribed_from_emails: true, + created_at: 1571672154, + updated_at: 1571672154, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + key: "value", + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", + total_count: 100, + has_more: true, + }, + notes: { + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + total_count: 100, + has_more: true, + }, + companies: { + url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", + total_count: 100, + has_more: true, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + merged_at: 1571672154, + }, + ], + }, + ], + total_count: 0, + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 5, + total_pages: 0, + }, + }); + }); + + test("SearchContacts (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { query: {} }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/contacts/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.searchContacts({ + query: {}, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("SearchContacts (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { query: {} }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/contacts/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.searchContacts({ + query: {}, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("ListContactActivities (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "contact_activity", + id: "1717000000000.0000a1", + event_type: "contact.created", + contact_id: "6329bd9ffe4e2e91dc5d6a1e", + external_id: "user-42", + role: "lead", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "duplicate_external_id", + created_at: 1717000000, + }, + { + type: "contact_activity", + id: "1717000100000.0000b2", + event_type: "contact.role_updated", + contact_id: "6329bd9ffe4e2e91dc5d6a1e", + external_id: "user-42", + role: "user", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "duplicate_external_id", + created_at: 1717000100, + }, + { + type: "contact_activity", + id: "1717000200000.0000c3", + event_type: "contact.merged", + contact_id: "6329bd9ffe4e2e91dc5d6a1e", + external_id: "user-42", + role: "user", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "duplicate_external_id", + created_at: 1717000200, + }, + { + type: "contact_activity", + id: "1717000300000.0000d4", + event_type: "contact.merge_failed", + contact_id: "5f7f0d217c3f2e001a4e8b12", + external_id: "user-42", + role: "user", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "Merge source_user cannot have role='user_role'", + created_at: 1717000300, + }, + { + type: "contact_activity", + id: "1717000400000.0000e5", + event_type: "contact.deleted", + contact_id: "6329bd9ffe4e2e91dc5d6a1e", + external_id: "user-42", + role: "user", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "duplicate_external_id", + created_at: 1717000400, + }, + ], + pages: { type: "pages", per_page: 50, next: { starting_after: "1717000400000.0000e5" } }, + }; + server + .mockEndpoint() + .get("/contacts/activities") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.listContactActivities({ + per_page: 1, + starting_after: "starting_after", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "contact_activity", + id: "1717000000000.0000a1", + event_type: "contact.created", + contact_id: "6329bd9ffe4e2e91dc5d6a1e", + external_id: "user-42", + role: "lead", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "duplicate_external_id", + created_at: 1717000000, + }, + { + type: "contact_activity", + id: "1717000100000.0000b2", + event_type: "contact.role_updated", + contact_id: "6329bd9ffe4e2e91dc5d6a1e", + external_id: "user-42", + role: "user", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "duplicate_external_id", + created_at: 1717000100, + }, + { + type: "contact_activity", + id: "1717000200000.0000c3", + event_type: "contact.merged", + contact_id: "6329bd9ffe4e2e91dc5d6a1e", + external_id: "user-42", + role: "user", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "duplicate_external_id", + created_at: 1717000200, + }, + { + type: "contact_activity", + id: "1717000300000.0000d4", + event_type: "contact.merge_failed", + contact_id: "5f7f0d217c3f2e001a4e8b12", + external_id: "user-42", + role: "user", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "Merge source_user cannot have role='user_role'", + created_at: 1717000300, + }, + { + type: "contact_activity", + id: "1717000400000.0000e5", + event_type: "contact.deleted", + contact_id: "6329bd9ffe4e2e91dc5d6a1e", + external_id: "user-42", + role: "user", + merge_source_id: "5f7f0d217c3f2e001a4e8b12", + merge_target_id: "6329bd9ffe4e2e91dc5d6a1e", + failure_reason: "duplicate_external_id", + created_at: 1717000400, + }, + ], + pages: { + type: "pages", + per_page: 50, + next: { + starting_after: "1717000400000.0000e5", + }, + }, + }); + }); + + test("ListContactActivities (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/activities") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listContactActivities(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("ListContacts (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "f3b87a2e09d514c6c2e79b9a", + workspace_id: "ecahpwf5", + role: "user", + email: "joe@example.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "John Doe", + owner_id: "321", + has_hard_bounced: true, + marked_email_as_spam: true, + unsubscribed_from_emails: true, + created_at: 1571672154, + updated_at: 1571672154, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { key: "value" }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, + notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, + companies: { + url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", + total_count: 100, + has_more: true, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + merge_history: [ + { type: "merge_history", source_contact_id: "5ba682d23d7cf92bef87bfd3", merged_at: 1571672154 }, + ], + }, + ], + total_count: 0, + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 10, + total_pages: 0, + }, + }; + server.mockEndpoint().get("/contacts").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.contacts.listContacts({ + include_merge_history: true, + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "f3b87a2e09d514c6c2e79b9a", + workspace_id: "ecahpwf5", + role: "user", + email: "joe@example.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "John Doe", + owner_id: "321", + has_hard_bounced: true, + marked_email_as_spam: true, + unsubscribed_from_emails: true, + created_at: 1571672154, + updated_at: 1571672154, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + key: "value", + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", + total_count: 100, + has_more: true, + }, + notes: { + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + total_count: 100, + has_more: true, + }, + companies: { + url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", + total_count: 100, + has_more: true, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + merged_at: 1571672154, + }, + ], + }, + ], + total_count: 0, + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 10, + total_pages: 0, + }, + }); + }); + + test("ListContacts (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/contacts").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.contacts.listContacts(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("CreateContact (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { email: "joebloggs@intercom.io" }; + const rawResponseBody = { + type: "contact", + id: "6762f0dd1bb69f9f2193bb83", + external_id: "f3b87a2e09d514c6c2e79b9a", + workspace_id: "this_is_an_id303_that_should_be_at_least_", + role: "user", + email: "joebloggs@intercom.io", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "John Doe", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537437, + updated_at: 1734537437, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { key: "value" }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0dd1bb69f9f2193bb83/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0dd1bb69f9f2193bb83/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], + url: "/contacts/6762f0dd1bb69f9f2193bb83/companies", + total_count: 0, + has_more: false, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + social_profiles: { + data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }; + server + .mockEndpoint() + .post("/contacts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.createContact({ + email: "joebloggs@intercom.io", + }); + expect(response).toEqual({ + type: "contact", + id: "6762f0dd1bb69f9f2193bb83", + external_id: "f3b87a2e09d514c6c2e79b9a", + workspace_id: "this_is_an_id303_that_should_be_at_least_", + role: "user", + email: "joebloggs@intercom.io", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "John Doe", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537437, + updated_at: 1734537437, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + key: "value", + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0dd1bb69f9f2193bb83/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0dd1bb69f9f2193bb83/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [ + { + id: "5ba682d23d7cf92bef87bfd4", + url: "/companies/5ba682d23d7cf92bef87bfd4", + }, + ], + url: "/contacts/6762f0dd1bb69f9f2193bb83/companies", + total_count: 0, + has_more: false, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + social_profiles: { + data: [ + { + type: "social_profile", + name: "Facebook", + url: "http://twitter.com/th1sland", + }, + ], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }); + }); + + test("CreateContact (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { key: "value" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/contacts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.createContact({ + key: "value", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("ShowContactByExternalId (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "contact", + id: "6762f0df1bb69f9f2193bb84", + external_id: "70", + workspace_id: "this_is_an_id307_that_should_be_at_least_", + role: "user", + email: "joe@bloggs.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "Joe Bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537439, + updated_at: 1734537439, + signed_up_at: 1734537439, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { key: "value" }, + avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, + tags: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0df1bb69f9f2193bb84/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], + url: "/contacts/6762f0df1bb69f9f2193bb84/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], + url: "/contacts/6762f0df1bb69f9f2193bb84/companies", + total_count: 0, + has_more: false, + }, + location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, + social_profiles: { + data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }; + server + .mockEndpoint() + .get("/contacts/find_by_external_id/cdd29344-5e0c-4ef0-ac56-f9ba2979bc27") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.showContactByExternalId({ + external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27", + include_merge_history: true, + }); + expect(response).toEqual({ + type: "contact", + id: "6762f0df1bb69f9f2193bb84", + external_id: "70", + workspace_id: "this_is_an_id307_that_should_be_at_least_", + role: "user", + email: "joe@bloggs.com", + email_domain: "example.com", + phone: "+1123456789", + formatted_phone: "+1123456789", + name: "Joe Bloggs", + owner_id: "321", + has_hard_bounced: false, + marked_email_as_spam: false, + unsubscribed_from_emails: false, + created_at: 1734537439, + updated_at: 1734537439, + signed_up_at: 1734537439, + last_seen_at: 1571672154, + last_replied_at: 1571672154, + last_contacted_at: 1571672154, + last_email_opened_at: 1571672154, + last_email_clicked_at: 1571672154, + language_override: "en", + browser: "Chrome", + browser_version: "80.0.3987.132", + browser_language: "en-US", + os: "Mac OS X", + android_app_name: "Intercom", + android_app_version: "5.0.0", + android_device: "Pixel 3", + android_os_version: "10", + android_sdk_version: "28", + android_last_seen_at: 1571672154, + ios_app_name: "Intercom", + ios_app_version: "5.0.0", + ios_device: "iPhone 11", + ios_os_version: "13.3.1", + ios_sdk_version: "13.3.1", + ios_last_seen_at: 1571672154, + custom_attributes: { + key: "value", + }, + avatar: { + type: "avatar", + image_url: "https://example.org/128Wash.jpg", + }, + tags: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0df1bb69f9f2193bb84/tags", + total_count: 0, + has_more: false, + }, + notes: { + data: [ + { + type: "note", + id: "123", + url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", + }, + ], + url: "/contacts/6762f0df1bb69f9f2193bb84/notes", + total_count: 0, + has_more: false, + }, + companies: { + data: [ + { + id: "5ba682d23d7cf92bef87bfd4", + url: "/companies/5ba682d23d7cf92bef87bfd4", + }, + ], + url: "/contacts/6762f0df1bb69f9f2193bb84/companies", + total_count: 0, + has_more: false, + }, + location: { + type: "location", + country: "Ireland", + region: "Dublin", + city: "Dublin", + }, + social_profiles: { + data: [ + { + type: "social_profile", + name: "Facebook", + url: "http://twitter.com/th1sland", + }, + ], + }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + enabled_push_messaging: true, + }); + }); + + test("ShowContactByExternalId (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/find_by_external_id/external_id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.showContactByExternalId({ + external_id: "external_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("ShowContactByExternalId (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/find_by_external_id/external_id") + .respondWith() + .statusCode(410) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.showContactByExternalId({ + external_id: "external_id", + }); + }).rejects.toThrow(Intercom.preview.GoneError); + }); + + test("ArchiveContact", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", archived: true }; + server + .mockEndpoint() + .post("/contacts/63a07ddf05a32042dffac965/archive") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.archiveContact({ + id: "63a07ddf05a32042dffac965", + }); + expect(response).toEqual({ + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + archived: true, + }); + }); + + test("UnarchiveContact", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", archived: false }; + server + .mockEndpoint() + .post("/contacts/63a07ddf05a32042dffac965/unarchive") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.unarchiveContact({ + id: "63a07ddf05a32042dffac965", + }); + expect(response).toEqual({ + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + archived: false, + }); + }); + + test("BlockContact", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", blocked: true }; + server + .mockEndpoint() + .post("/contacts/63a07ddf05a32042dffac965/block") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.blockContact({ + id: "63a07ddf05a32042dffac965", + }); + expect(response).toEqual({ + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + blocked: true, + }); + }); + + test("ListContactMergeHistory (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + next_cursor: "eyJpZCI6IjYyMzQ1NiJ9", + has_more: true, + }; + server + .mockEndpoint() + .get("/contacts/63a07ddf05a32042dffac965/merge_history") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.listContactMergeHistory({ + id: "63a07ddf05a32042dffac965", + cursor: "cursor", + per_page: 1, + order: "asc", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], + next_cursor: "eyJpZCI6IjYyMzQ1NiJ9", + has_more: true, + }); + }); + + test("ListContactMergeHistory (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/contacts/id/merge_history") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listContactMergeHistory({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("ListContactMergeHistory (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/contacts/id/merge_history") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.listContactMergeHistory({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("BulkCreateContacts (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + contacts: [ + { + external_id: "abc123", + email: "joe@bloggs.com", + name: "Joe Bloggs", + role: "user", + phone: "+353871234567", + avatar: "https://www.example.com/avatar_image.jpg", + language_override: "fr", + custom_attributes: { plan: "pro" }, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + owner_id: "321", + unsubscribed_from_emails: false, + companies: [{ company_id: "6", name: "Blue Sun" }], + tags: { add: [{ id: "123" }] }, + }, + ], + }; + const rawResponseBody = { + id: "job_v2_2", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_2", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_2", + }; + server + .mockEndpoint() + .post("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkCreateContacts({ + contacts: [ + { + external_id: "abc123", + email: "joe@bloggs.com", + name: "Joe Bloggs", + role: "user", + phone: "+353871234567", + avatar: "https://www.example.com/avatar_image.jpg", + language_override: "fr", + custom_attributes: { + plan: "pro", + }, + signed_up_at: 1571672154, + last_seen_at: 1571672154, + owner_id: "321", + unsubscribed_from_emails: false, + companies: [ + { + company_id: "6", + name: "Blue Sun", + }, + ], + tags: { + add: [ + { + id: "123", + }, + ], + }, + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_2", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_2", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_2", + }); + }); + + test("BulkCreateContacts (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + contacts: [ + { + external_id: "abc123", + email: "joe@bloggs.com", + companies: [ + { company_id: "6", name: "Blue Sun" }, + { company_id: "7", name: "Weyland-Yutani" }, + ], + }, + ], + }; + const rawResponseBody = { + id: "job_v2_2", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_2", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_2", + }; + server + .mockEndpoint() + .post("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkCreateContacts({ + contacts: [ + { + external_id: "abc123", + email: "joe@bloggs.com", + companies: [ + { + company_id: "6", + name: "Blue Sun", + }, + { + company_id: "7", + name: "Weyland-Yutani", + }, + ], + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_2", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_2", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_2", + }); + }); + + test("BulkCreateContacts (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + contacts: [{ external_id: "abc123", name: "Contact Name", tags: { add: [{ id: "123" }] } }], + }; + const rawResponseBody = { + id: "job_v2_2", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_2", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_2", + }; + server + .mockEndpoint() + .post("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkCreateContacts({ + contacts: [ + { + external_id: "abc123", + name: "Contact Name", + tags: { + add: [ + { + id: "123", + }, + ], + }, + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_2", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_2", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_2", + }); + }); + + test("BulkCreateContacts (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + contacts: [{ external_id: "abc123", email: "joe@bloggs.com", language_override: "de" }], + job: { id: "job_v2_1" }, + }; + const rawResponseBody = { + id: "job_v2_2", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_2", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_2", + }; + server + .mockEndpoint() + .post("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkCreateContacts({ + contacts: [ + { + external_id: "abc123", + email: "joe@bloggs.com", + language_override: "de", + }, + ], + job: { + id: "job_v2_1", + }, + }); + expect(response).toEqual({ + id: "job_v2_2", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_2", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_2", + }); + }); + + test("BulkCreateContacts (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{}, {}] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkCreateContacts({ + contacts: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("BulkCreateContacts (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{}, {}] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkCreateContacts({ + contacts: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("BulkCreateContacts (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{}, {}] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkCreateContacts({ + contacts: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("BulkCreateContacts (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{}, {}] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkCreateContacts({ + contacts: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("BulkUpdateContacts (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + contacts: [ + { + id: "abc123", + external_id: "ext123", + email: "joe@bloggs.com", + name: "Joe Bloggs", + phone: "+353871234567", + avatar: "https://www.example.com/avatar_image.jpg", + owner_id: "321", + unsubscribed_from_emails: false, + language_override: "fr", + custom_attributes: { plan: "pro" }, + companies: [{ company_id: "6", name: "Blue Sun" }], + tags: { add: [{ id: "123" }], remove: [{ id: "987" }] }, + }, + ], + }; + const rawResponseBody = { + id: "job_v2_1", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }; + server + .mockEndpoint() + .put("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkUpdateContacts({ + contacts: [ + { + id: "abc123", + external_id: "ext123", + email: "joe@bloggs.com", + name: "Joe Bloggs", + phone: "+353871234567", + avatar: "https://www.example.com/avatar_image.jpg", + owner_id: "321", + unsubscribed_from_emails: false, + language_override: "fr", + custom_attributes: { + plan: "pro", + }, + companies: [ + { + company_id: "6", + name: "Blue Sun", + }, + ], + tags: { + add: [ + { + id: "123", + }, + ], + remove: [ + { + id: "987", + }, + ], + }, + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }); + }); + + test("BulkUpdateContacts (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + contacts: [ + { + id: "abc123", + companies: [ + { company_id: "6", name: "Blue Sun" }, + { company_id: "7", remove: true }, + ], + }, + ], + }; + const rawResponseBody = { + id: "job_v2_1", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }; + server + .mockEndpoint() + .put("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkUpdateContacts({ + contacts: [ + { + id: "abc123", + companies: [ + { + company_id: "6", + name: "Blue Sun", + }, + { + company_id: "7", + remove: true, + }, + ], + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }); + }); + + test("BulkUpdateContacts (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + contacts: [{ id: "abc123", name: "Updated Name", tags: { add: [{ id: "123" }], remove: [{ id: "456" }] } }], + }; + const rawResponseBody = { + id: "job_v2_1", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }; + server + .mockEndpoint() + .put("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkUpdateContacts({ + contacts: [ + { + id: "abc123", + name: "Updated Name", + tags: { + add: [ + { + id: "123", + }, + ], + remove: [ + { + id: "456", + }, + ], + }, + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }); + }); + + test("BulkUpdateContacts (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "abc123", language_override: "de" }], job: { id: "job_v2_1" } }; + const rawResponseBody = { + id: "job_v2_1", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }; + server + .mockEndpoint() + .put("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkUpdateContacts({ + contacts: [ + { + id: "abc123", + language_override: "de", + }, + ], + job: { + id: "job_v2_1", + }, + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }); + }); + + test("BulkUpdateContacts (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkUpdateContacts({ + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("BulkUpdateContacts (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkUpdateContacts({ + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("BulkUpdateContacts (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkUpdateContacts({ + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("BulkUpdateContacts (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/contacts/bulk") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkUpdateContacts({ + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("BulkDeleteContacts (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "abc123" }, { id: "def456" }] }; + const rawResponseBody = { + id: "job_v2_3", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_3", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_3", + }; + server + .mockEndpoint() + .post("/contacts/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkDeleteContacts({ + contacts: [ + { + id: "abc123", + }, + { + id: "def456", + }, + ], + }); + expect(response).toEqual({ + id: "job_v2_3", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_3", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_3", + }); + }); + + test("BulkDeleteContacts (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "abc123" }], job: { id: "job_v2_1" } }; + const rawResponseBody = { + id: "job_v2_3", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_3", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_3", + }; + server + .mockEndpoint() + .post("/contacts/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.bulkDeleteContacts({ + contacts: [ + { + id: "abc123", + }, + ], + job: { + id: "job_v2_1", + }, + }); + expect(response).toEqual({ + id: "job_v2_3", + type: "contacts.bulk.job", + state: "running", + created_at: 1713360000, + updated_at: 1713360060, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_3", + item_count: 2, + state: "pending", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_3", + }); + }); + + test("BulkDeleteContacts (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/contacts/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkDeleteContacts({ + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("BulkDeleteContacts (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/contacts/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkDeleteContacts({ + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("BulkDeleteContacts (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/contacts/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkDeleteContacts({ + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("BulkDeleteContacts (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/contacts/bulk/delete") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contacts.bulkDeleteContacts({ + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("ShowBulkUpdateContactsJob (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "job_v2_1", + type: "contacts.bulk.job", + state: "completed", + created_at: 1713360000, + updated_at: 1713360120, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "completed", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }; + server + .mockEndpoint() + .get("/contacts/bulk/job_v2_1") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contacts.showBulkUpdateContactsJob({ + id: "job_v2_1", + }); + expect(response).toEqual({ + id: "job_v2_1", + type: "contacts.bulk.job", + state: "completed", + created_at: 1713360000, + updated_at: 1713360120, + completed_at: 1713360120, + tasks: [ + { + id: "task_v2_1", + item_count: 3, + state: "completed", + created_at: 1713360000, + started_at: 1713360060, + completed_at: 1713360120, + }, + ], + url: "https://api.intercom.io/contacts/bulk/job_v2_1", + }); + }); + + test("ShowBulkUpdateContactsJob (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/contacts/bulk/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.contacts.showBulkUpdateContactsJob({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); +}); diff --git a/tests/wire/preview/content.test.ts b/tests/wire/preview/content.test.ts new file mode 100644 index 00000000..4c0228e9 --- /dev/null +++ b/tests/wire/preview/content.test.ts @@ -0,0 +1,517 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ContentClient", () => { + test("bulkContentActions (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + action: "publish", + content_ids: [ + { type: "article_content", id: "12345678" }, + { type: "article_content", id: "12345679" }, + ], + }; + const rawResponseBody = { type: "content_bulk_action", status: "queued" }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.content.bulkContentActions({ + action: "publish", + content_ids: [ + { + type: "article_content", + id: "12345678", + }, + { + type: "article_content", + id: "12345679", + }, + ], + }); + expect(response).toEqual({ + type: "content_bulk_action", + status: "queued", + }); + }); + + test("bulkContentActions (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { action: "unpublish", content_ids: [{ type: "article_content", id: "12345678" }] }; + const rawResponseBody = { type: "content_bulk_action", status: "queued" }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.content.bulkContentActions({ + action: "unpublish", + content_ids: [ + { + type: "article_content", + id: "12345678", + }, + ], + }); + expect(response).toEqual({ + type: "content_bulk_action", + status: "queued", + }); + }); + + test("bulkContentActions (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + action: "delete", + content_ids: [ + { type: "article_content", id: "12345678" }, + { type: "internal_article", id: "12345679" }, + { type: "content_snippet", id: "12345680" }, + ], + }; + const rawResponseBody = { type: "content_bulk_action", status: "queued" }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.content.bulkContentActions({ + action: "delete", + content_ids: [ + { + type: "article_content", + id: "12345678", + }, + { + type: "internal_article", + id: "12345679", + }, + { + type: "content_snippet", + id: "12345680", + }, + ], + }); + expect(response).toEqual({ + type: "content_bulk_action", + status: "queued", + }); + }); + + test("bulkContentActions (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + action: "set_availability", + content_ids: [{ type: "article_content", id: "12345678" }], + availability: { ai_agent: true, copilot: false }, + }; + const rawResponseBody = { type: "content_bulk_action", status: "queued" }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.content.bulkContentActions({ + action: "set_availability", + content_ids: [ + { + type: "article_content", + id: "12345678", + }, + ], + availability: { + ai_agent: true, + copilot: false, + }, + }); + expect(response).toEqual({ + type: "content_bulk_action", + status: "queued", + }); + }); + + test("bulkContentActions (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + action: "set_audience", + content_ids: [{ type: "article_content", id: "12345678" }], + audience: { add_segment_ids: [100], remove_segment_ids: [200] }, + }; + const rawResponseBody = { type: "content_bulk_action", status: "queued" }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.content.bulkContentActions({ + action: "set_audience", + content_ids: [ + { + type: "article_content", + id: "12345678", + }, + ], + audience: { + add_segment_ids: [100], + remove_segment_ids: [200], + }, + }); + expect(response).toEqual({ + type: "content_bulk_action", + status: "queued", + }); + }); + + test("bulkContentActions (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + action: "update_tags", + content_ids: [{ type: "article", id: "12345678" }], + tags: { add_tag_ids: [100], remove_tag_ids: [200] }, + }; + const rawResponseBody = { type: "content_bulk_action", status: "queued" }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.content.bulkContentActions({ + action: "update_tags", + content_ids: [ + { + type: "article", + id: "12345678", + }, + ], + tags: { + add_tag_ids: [100], + remove_tag_ids: [200], + }, + }); + expect(response).toEqual({ + type: "content_bulk_action", + status: "queued", + }); + }); + + test("bulkContentActions (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + action: "publish", + content_ids: [ + { type: "article", id: "id" }, + { type: "article", id: "id" }, + ], + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.content.bulkContentActions({ + action: "publish", + content_ids: [ + { + type: "article", + id: "id", + }, + { + type: "article", + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("bulkContentActions (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + action: "publish", + content_ids: [ + { type: "article", id: "id" }, + { type: "article", id: "id" }, + ], + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.content.bulkContentActions({ + action: "publish", + content_ids: [ + { + type: "article", + id: "id", + }, + { + type: "article", + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("bulkContentActions (9)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + action: "publish", + content_ids: [ + { type: "article", id: "id" }, + { type: "article", id: "id" }, + ], + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/content/bulk_actions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.content.bulkContentActions({ + action: "publish", + content_ids: [ + { + type: "article", + id: "id", + }, + { + type: "article", + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("searchContent (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + total_count: 5, + pages: { + type: "pages", + page: 1, + per_page: 10, + total_pages: 1, + next: "https://api.intercom.io/content/search?query=billing&page=2", + prev: "prev", + }, + data: [ + { type: "content_snippet", id: "123", title: "Billing FAQ" }, + { type: "external_content", id: "123", title: "Billing FAQ" }, + { type: "file_source_content", id: "123", title: "Billing FAQ" }, + { type: "internal_article", id: "123", title: "Billing FAQ" }, + { + type: "article", + id: "345", + title: "Billing FAQ", + contents: [{ id: "678", title: "Billing FAQ", locale: "en" }], + }, + ], + }; + server.mockEndpoint().get("/content/search").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.content.searchContent({ + query: "billing", + page: 1, + per_page: 1, + tag_operator: "IN", + folder_entity_type: "folder", + copilot_state: "on", + fin_service_state: "on", + fin_sales_state: "on", + created_at_after: 1, + created_at_before: 1, + updated_at_after: 1, + updated_at_before: 1, + }); + expect(response).toEqual({ + type: "list", + total_count: 5, + pages: { + type: "pages", + page: 1, + per_page: 10, + total_pages: 1, + next: "https://api.intercom.io/content/search?query=billing&page=2", + prev: "prev", + }, + data: [ + { + type: "content_snippet", + id: "123", + title: "Billing FAQ", + }, + { + type: "external_content", + id: "123", + title: "Billing FAQ", + }, + { + type: "file_source_content", + id: "123", + title: "Billing FAQ", + }, + { + type: "internal_article", + id: "123", + title: "Billing FAQ", + }, + { + type: "article", + id: "345", + title: "Billing FAQ", + contents: [ + { + id: "678", + title: "Billing FAQ", + locale: "en", + }, + ], + }, + ], + }); + }); + + test("searchContent (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/content/search").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.content.searchContent(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("searchContent (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/content/search").respondWith().statusCode(422).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.content.searchContent(); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); +}); diff --git a/tests/wire/preview/contentSnippets.test.ts b/tests/wire/preview/contentSnippets.test.ts new file mode 100644 index 00000000..fe1b1c83 --- /dev/null +++ b/tests/wire/preview/contentSnippets.test.ts @@ -0,0 +1,711 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ContentSnippetsClient", () => { + test("listContentSnippets", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "content_snippet", + id: "123", + title: "How to reset your password", + locale: "en", + json_blocks: [{ type: "paragraph", text: "Navigate to Settings > Security > Reset password." }], + body_markdown: + "# How to reset your password\n\nNavigate to Settings > Security > Reset password.\n", + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_at: 1663597223, + updated_at: 1663597223, + audience_ids: [1, 2], + }, + ], + total_count: 1, + page: 1, + per_page: 50, + total_pages: 1, + }; + server.mockEndpoint().get("/content_snippets").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.contentSnippets.listContentSnippets({ + page: 1, + per_page: 20, + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "content_snippet", + id: "123", + title: "How to reset your password", + locale: "en", + json_blocks: [ + { + type: "paragraph", + text: "Navigate to Settings > Security > Reset password.", + }, + ], + body_markdown: + "# How to reset your password\n\nNavigate to Settings > Security > Reset password.\n", + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_at: 1663597223, + updated_at: 1663597223, + audience_ids: [1, 2], + }, + ], + total_count: 1, + page: 1, + per_page: 50, + total_pages: 1, + }); + }); + + test("createContentSnippet (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + title: "How to reset your password", + json_blocks: [{ type: "paragraph", text: "Navigate to Settings > Security > Reset password." }], + locale: "en", + audience_ids: [1, 2], + }; + const rawResponseBody = { + type: "content_snippet", + id: "456", + title: "How to reset your password", + locale: "en", + json_blocks: [{ type: "paragraph", text: "Navigate to Settings > Security > Reset password." }], + body_markdown: "# How to reset your password\n\nNavigate to Settings > Security > Reset password.\n", + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_at: 1663597223, + updated_at: 1663597223, + audience_ids: [1, 2], + }; + server + .mockEndpoint() + .post("/content_snippets") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contentSnippets.createContentSnippet({ + title: "How to reset your password", + json_blocks: [ + { + type: "paragraph", + text: "Navigate to Settings > Security > Reset password.", + }, + ], + locale: "en", + audience_ids: [1, 2], + }); + expect(response).toEqual({ + type: "content_snippet", + id: "456", + title: "How to reset your password", + locale: "en", + json_blocks: [ + { + type: "paragraph", + text: "Navigate to Settings > Security > Reset password.", + }, + ], + body_markdown: "# How to reset your password\n\nNavigate to Settings > Security > Reset password.\n", + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_at: 1663597223, + updated_at: 1663597223, + audience_ids: [1, 2], + }); + }); + + test("createContentSnippet (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { title: "title" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/content_snippets") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.createContentSnippet({ + title: "title", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("createContentSnippet (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { title: "title" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/content_snippets") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.createContentSnippet({ + title: "title", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("getContentSnippet (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "content_snippet", + id: "123", + title: "How to reset your password", + locale: "en", + json_blocks: [{ type: "paragraph", text: "Navigate to Settings > Security > Reset password." }], + body_markdown: "# How to reset your password\n\nNavigate to Settings > Security > Reset password.\n", + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_at: 1663597223, + updated_at: 1663597223, + audience_ids: [1, 2], + }; + server + .mockEndpoint() + .get("/content_snippets/123") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contentSnippets.getContentSnippet({ + id: "123", + }); + expect(response).toEqual({ + type: "content_snippet", + id: "123", + title: "How to reset your password", + locale: "en", + json_blocks: [ + { + type: "paragraph", + text: "Navigate to Settings > Security > Reset password.", + }, + ], + body_markdown: "# How to reset your password\n\nNavigate to Settings > Security > Reset password.\n", + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_at: 1663597223, + updated_at: 1663597223, + audience_ids: [1, 2], + }); + }); + + test("getContentSnippet (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/content_snippets/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.getContentSnippet({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateContentSnippet (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + title: "How to reset your password (updated)", + json_blocks: [ + { type: "paragraph", text: "Go to Settings > Security > Reset password and follow the steps." }, + ], + audience_ids: [1, 2], + }; + const rawResponseBody = { + type: "content_snippet", + id: "123", + title: "How to reset your password (updated)", + locale: "en", + json_blocks: [ + { type: "paragraph", text: "Go to Settings > Security > Reset password and follow the steps." }, + ], + body_markdown: + "# How to reset your password (updated)\n\nGo to Settings > Security > Reset password and follow the steps.\n", + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_at: 1663597223, + updated_at: 1663597300, + audience_ids: [1, 2], + }; + server + .mockEndpoint() + .put("/content_snippets/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contentSnippets.updateContentSnippet({ + id: "123", + title: "How to reset your password (updated)", + json_blocks: [ + { + type: "paragraph", + text: "Go to Settings > Security > Reset password and follow the steps.", + }, + ], + audience_ids: [1, 2], + }); + expect(response).toEqual({ + type: "content_snippet", + id: "123", + title: "How to reset your password (updated)", + locale: "en", + json_blocks: [ + { + type: "paragraph", + text: "Go to Settings > Security > Reset password and follow the steps.", + }, + ], + body_markdown: + "# How to reset your password (updated)\n\nGo to Settings > Security > Reset password and follow the steps.\n", + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + created_at: 1663597223, + updated_at: 1663597300, + audience_ids: [1, 2], + }); + }); + + test("updateContentSnippet (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/content_snippets/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.updateContentSnippet({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateContentSnippet (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/content_snippets/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.updateContentSnippet({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("deleteContentSnippet (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/content_snippets/123").respondWith().statusCode(200).build(); + + const response = await client.preview.contentSnippets.deleteContentSnippet({ + id: "123", + }); + expect(response).toEqual(undefined); + }); + + test("deleteContentSnippet (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/content_snippets/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.deleteContentSnippet({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteContentSnippet (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/content_snippets/id") + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.deleteContentSnippet({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("attachTagToContentSnippet (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "7522907" }; + const rawResponseBody = { + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { type: "admin", id: "1234" }, + }; + server + .mockEndpoint() + .post("/content_snippets/123/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contentSnippets.attachTagToContentSnippet({ + content_snippet_id: "123", + id: "7522907", + }); + expect(response).toEqual({ + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { + type: "admin", + id: "1234", + }, + }); + }); + + test("attachTagToContentSnippet (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/content_snippets/content_snippet_id/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.attachTagToContentSnippet({ + content_snippet_id: "content_snippet_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("attachTagToContentSnippet (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/content_snippets/content_snippet_id/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.attachTagToContentSnippet({ + content_snippet_id: "content_snippet_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("attachTagToContentSnippet (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/content_snippets/content_snippet_id/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.attachTagToContentSnippet({ + content_snippet_id: "content_snippet_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("detachTagFromContentSnippet (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { type: "contact", id: "1a2b3c" }, + }; + server + .mockEndpoint() + .delete("/content_snippets/123/tags/7522907") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.contentSnippets.detachTagFromContentSnippet({ + content_snippet_id: "123", + id: "7522907", + }); + expect(response).toEqual({ + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { + type: "contact", + id: "1a2b3c", + }, + }); + }); + + test("detachTagFromContentSnippet (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/content_snippets/content_snippet_id/tags/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.detachTagFromContentSnippet({ + content_snippet_id: "content_snippet_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("detachTagFromContentSnippet (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/content_snippets/content_snippet_id/tags/id") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.detachTagFromContentSnippet({ + content_snippet_id: "content_snippet_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("detachTagFromContentSnippet (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/content_snippets/content_snippet_id/tags/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.contentSnippets.detachTagFromContentSnippet({ + content_snippet_id: "content_snippet_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); +}); diff --git a/tests/wire/preview/conversationParticipants.test.ts b/tests/wire/preview/conversationParticipants.test.ts new file mode 100644 index 00000000..8ce87ee4 --- /dev/null +++ b/tests/wire/preview/conversationParticipants.test.ts @@ -0,0 +1,405 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ConversationParticipantsClient", () => { + test("attachContactToConversation (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19b1bb69f9f2193bbd4" } }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f19b1bb69f9f2193bbd4" }] }; + server + .mockEndpoint() + .post("/conversations/123/customers") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParticipants.attachContactToConversation({ + id: "123", + admin_id: "12345", + customer: { + intercom_user_id: "6762f19b1bb69f9f2193bbd4", + }, + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f19b1bb69f9f2193bbd4", + }, + ], + }); + }); + + test("attachContactToConversation (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19e1bb69f9f2193bbd5" } }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f19b1bb69f9f2193bbd4" }] }; + server + .mockEndpoint() + .post("/conversations/123/customers") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParticipants.attachContactToConversation({ + id: "123", + admin_id: "12345", + customer: { + intercom_user_id: "6762f19e1bb69f9f2193bbd5", + }, + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f19b1bb69f9f2193bbd4", + }, + ], + }); + }); + + test("attachContactToConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/id/customers") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParticipants.attachContactToConversation({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("attachContactToConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/id/customers") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParticipants.attachContactToConversation({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("attachContactToConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/conversations/id/customers") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParticipants.attachContactToConversation({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("detachContactFromConversation (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "5017690" }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f1b41bb69f9f2193bbe0" }] }; + server + .mockEndpoint() + .delete("/conversations/123/customers/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "123", + contact_id: "123", + admin_id: "5017690", + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f1b41bb69f9f2193bbe0", + }, + ], + }); + }); + + test("detachContactFromConversation (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "5017690" }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f1b41bb69f9f2193bbe0" }] }; + server + .mockEndpoint() + .delete("/conversations/123/customers/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "123", + contact_id: "123", + admin_id: "5017690", + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f1b41bb69f9f2193bbe0", + }, + ], + }); + }); + + test("detachContactFromConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "5017690" }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f1b41bb69f9f2193bbe0" }] }; + server + .mockEndpoint() + .delete("/conversations/123/customers/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "123", + contact_id: "123", + admin_id: "5017690", + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f1b41bb69f9f2193bbe0", + }, + ], + }); + }); + + test("detachContactFromConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "5017690" }; + const rawResponseBody = { customers: [{ type: "user", id: "6762f1b41bb69f9f2193bbe0" }] }; + server + .mockEndpoint() + .delete("/conversations/123/customers/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "123", + contact_id: "123", + admin_id: "5017690", + }); + expect(response).toEqual({ + customers: [ + { + type: "user", + id: "6762f1b41bb69f9f2193bbe0", + }, + ], + }); + }); + + test("detachContactFromConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "admin_id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/conversations/conversation_id/customers/contact_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "conversation_id", + contact_id: "contact_id", + admin_id: "admin_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("detachContactFromConversation (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "admin_id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/conversations/conversation_id/customers/contact_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "conversation_id", + contact_id: "contact_id", + admin_id: "admin_id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("detachContactFromConversation (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "admin_id" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/conversations/conversation_id/customers/contact_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "conversation_id", + contact_id: "contact_id", + admin_id: "admin_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("detachContactFromConversation (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_id: "admin_id" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/conversations/conversation_id/customers/contact_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParticipants.detachContactFromConversation({ + conversation_id: "conversation_id", + contact_id: "contact_id", + admin_id: "admin_id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); +}); diff --git a/tests/wire/preview/conversationParts.test.ts b/tests/wire/preview/conversationParts.test.ts new file mode 100644 index 00000000..32254509 --- /dev/null +++ b/tests/wire/preview/conversationParts.test.ts @@ -0,0 +1,1793 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ConversationPartsClient", () => { + test("updateConversationPart (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + send_state: "sent", + info_message: "Message delivered successfully", + experimental: true, + secret: "hmac_secret_value", + }; + const rawResponseBody = { + type: "conversation_part", + id: "456", + part_type: "comment", + body: "

Hello there!

", + created_at: 1734537559, + updated_at: 1734537561, + notified_at: 1734537559, + assigned_to: { type: "contact", id: "1a2b3c" }, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267694", + name: "Ciaran Lee", + email: "admin@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + email_message_metadata: { + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + message_id: "", + }, + metadata: { + quick_reply_options: [{ text: "text", uuid: "uuid", translations: { en: "Hello", fr: "Bonjour" } }], + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, + state: "open", + tags: [{ type: "tag", id: "123456", name: "Test tag" }], + event_details: { + workflow: { name: "Workflow 1" }, + attribute: { name: "flight_category" }, + value: { name: "vip_status" }, + }, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello there!

", fr: "

Bonjour!

" }, + }; + server + .mockEndpoint() + .put("/conversations/123/conversation_parts/456") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParts.updateConversationPart({ + conversation_id: "123", + id: "456", + send_state: "sent", + info_message: "Message delivered successfully", + experimental: true, + secret: "hmac_secret_value", + }); + expect(response).toEqual({ + type: "conversation_part", + id: "456", + part_type: "comment", + body: "

Hello there!

", + created_at: 1734537559, + updated_at: 1734537561, + notified_at: 1734537559, + assigned_to: { + type: "contact", + id: "1a2b3c", + }, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267694", + name: "Ciaran Lee", + email: "admin@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + email_message_metadata: { + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + message_id: "", + }, + metadata: { + quick_reply_options: [ + { + text: "text", + uuid: "uuid", + translations: { + en: "Hello", + fr: "Bonjour", + }, + }, + ], + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, + state: "open", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + event_details: { + workflow: { + name: "Workflow 1", + }, + attribute: { + name: "flight_category", + }, + value: { + name: "vip_status", + }, + }, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello there!

", + fr: "

Bonjour!

", + }, + }); + }); + + test("updateConversationPart (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { seen: true, admin_id: "991267694", experimental: true, secret: "hmac_secret_value" }; + const rawResponseBody = { + type: "conversation_part", + id: "456", + part_type: "comment", + body: "

Hello there!

", + created_at: 1734537559, + updated_at: 1734537561, + notified_at: 1734537559, + assigned_to: { type: "contact", id: "1a2b3c" }, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267694", + name: "Ciaran Lee", + email: "admin@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + email_message_metadata: { + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + message_id: "", + }, + metadata: { + quick_reply_options: [{ text: "text", uuid: "uuid", translations: { en: "Hello", fr: "Bonjour" } }], + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, + state: "open", + tags: [{ type: "tag", id: "123456", name: "Test tag" }], + event_details: { + workflow: { name: "Workflow 1" }, + attribute: { name: "flight_category" }, + value: { name: "vip_status" }, + }, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello there!

", fr: "

Bonjour!

" }, + }; + server + .mockEndpoint() + .put("/conversations/123/conversation_parts/456") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParts.updateConversationPart({ + conversation_id: "123", + id: "456", + seen: true, + admin_id: "991267694", + experimental: true, + secret: "hmac_secret_value", + }); + expect(response).toEqual({ + type: "conversation_part", + id: "456", + part_type: "comment", + body: "

Hello there!

", + created_at: 1734537559, + updated_at: 1734537561, + notified_at: 1734537559, + assigned_to: { + type: "contact", + id: "1a2b3c", + }, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267694", + name: "Ciaran Lee", + email: "admin@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + email_message_metadata: { + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + message_id: "", + }, + metadata: { + quick_reply_options: [ + { + text: "text", + uuid: "uuid", + translations: { + en: "Hello", + fr: "Bonjour", + }, + }, + ], + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, + state: "open", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + event_details: { + workflow: { + name: "Workflow 1", + }, + attribute: { + name: "flight_category", + }, + value: { + name: "vip_status", + }, + }, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello there!

", + fr: "

Bonjour!

", + }, + }); + }); + + test("updateConversationPart (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { experimental: true, secret: "secret" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/conversations/conversation_id/conversation_parts/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParts.updateConversationPart({ + conversation_id: "conversation_id", + id: "id", + experimental: true, + secret: "secret", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateConversationPart (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { experimental: true, secret: "secret" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/conversations/conversation_id/conversation_parts/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParts.updateConversationPart({ + conversation_id: "conversation_id", + id: "id", + experimental: true, + secret: "secret", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("updateConversationPart (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { experimental: true, secret: "secret" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/conversations/conversation_id/conversation_parts/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParts.updateConversationPart({ + conversation_id: "conversation_id", + id: "id", + experimental: true, + secret: "secret", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("redactConversation (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + type: "conversation_part", + conversation_id: "19894788788", + conversation_part_id: "19381789428", + }; + const rawResponseBody = { + type: "conversation", + id: "608", + title: "Conversation Title", + created_at: 1734537721, + updated_at: 1734537724, + waiting_since: 1734537722, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { type: "plan", id: "269315", name: "Pro" }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, + }, + ], + }, + notes: { + type: "note.list", + notes: [ + { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, + ], + }, + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, + teammate: { type: "contact", id: "1a2b3c" }, + }, + source: { + type: "conversation", + id: "403918391", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], + subject: "", + body: "

this is the message body

", + author: { type: "admin", id: "991267757", name: "Ciaran247 Lee", email: "admin247@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f1f81bb69f9f2193bc09", external_id: "70" }], + }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { key: "value" }, + first_contact_reply: { + created_at: 1734537722, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], + assigned_team_first_response_time_in_office_hours: [ + { team_id: 100, team_name: "Team One", response_time: 2310 }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ + { + type: "conversation_part", + id: "149", + part_type: "open", + body: "

This message was deleted

", + created_at: 1734537722, + updated_at: 1734537724, + notified_at: 1734537722, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "user", + id: "6762f1f81bb69f9f2193bc09", + name: "Joe Bloggs", + email: "joe@bloggs.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: true, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + ], + total_count: 1, + }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], + }; + server + .mockEndpoint() + .post("/conversations/redact") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParts.redactConversation({ + type: "conversation_part", + conversation_id: "19894788788", + conversation_part_id: "19381789428", + }); + expect(response).toEqual({ + type: "conversation", + id: "608", + title: "Conversation Title", + created_at: 1734537721, + updated_at: 1734537724, + waiting_since: 1734537722, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, + }, + ], + }, + notes: { + type: "note.list", + notes: [ + { + type: "note", + id: "17495962", + created_at: 1674589321, + body: "

Text for the note.

", + }, + ], + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + }, + teammate: { + type: "contact", + id: "1a2b3c", + }, + }, + source: { + type: "conversation", + id: "403918391", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], + subject: "", + body: "

this is the message body

", + author: { + type: "admin", + id: "991267757", + name: "Ciaran247 Lee", + email: "admin247@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f1f81bb69f9f2193bc09", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + teammates: [ + { + type: "contact", + id: "1a2b3c", + }, + ], + }, + custom_attributes: { + key: "value", + }, + first_contact_reply: { + created_at: 1734537722, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + sla_status: "hit", + }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, + ], + assigned_team_first_response_time_in_office_hours: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ + { + type: "conversation_part", + id: "149", + part_type: "open", + body: "

This message was deleted

", + created_at: 1734537722, + updated_at: 1734537724, + notified_at: 1734537722, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "user", + id: "6762f1f81bb69f9f2193bc09", + name: "Joe Bloggs", + email: "joe@bloggs.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: true, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + ], + total_count: 1, + }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: false, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], + }); + }); + + test("redactConversation (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + type: "conversation_part", + conversation_id: "really_123_doesnt_exist", + conversation_part_id: "really_123_doesnt_exist", + }; + const rawResponseBody = { + type: "conversation", + id: "608", + title: "Conversation Title", + created_at: 1734537721, + updated_at: 1734537724, + waiting_since: 1734537722, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { type: "plan", id: "269315", name: "Pro" }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, + }, + ], + }, + notes: { + type: "note.list", + notes: [ + { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, + ], + }, + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, + teammate: { type: "contact", id: "1a2b3c" }, + }, + source: { + type: "conversation", + id: "403918391", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], + subject: "", + body: "

this is the message body

", + author: { type: "admin", id: "991267757", name: "Ciaran247 Lee", email: "admin247@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f1f81bb69f9f2193bc09", external_id: "70" }], + }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { key: "value" }, + first_contact_reply: { + created_at: 1734537722, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], + assigned_team_first_response_time_in_office_hours: [ + { team_id: 100, team_name: "Team One", response_time: 2310 }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ + { + type: "conversation_part", + id: "149", + part_type: "open", + body: "

This message was deleted

", + created_at: 1734537722, + updated_at: 1734537724, + notified_at: 1734537722, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "user", + id: "6762f1f81bb69f9f2193bc09", + name: "Joe Bloggs", + email: "joe@bloggs.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: true, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + ], + total_count: 1, + }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], + }; + server + .mockEndpoint() + .post("/conversations/redact") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationParts.redactConversation({ + type: "conversation_part", + conversation_id: "really_123_doesnt_exist", + conversation_part_id: "really_123_doesnt_exist", + }); + expect(response).toEqual({ + type: "conversation", + id: "608", + title: "Conversation Title", + created_at: 1734537721, + updated_at: 1734537724, + waiting_since: 1734537722, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, + }, + ], + }, + notes: { + type: "note.list", + notes: [ + { + type: "note", + id: "17495962", + created_at: 1674589321, + body: "

Text for the note.

", + }, + ], + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + }, + teammate: { + type: "contact", + id: "1a2b3c", + }, + }, + source: { + type: "conversation", + id: "403918391", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], + subject: "", + body: "

this is the message body

", + author: { + type: "admin", + id: "991267757", + name: "Ciaran247 Lee", + email: "admin247@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f1f81bb69f9f2193bc09", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + teammates: [ + { + type: "contact", + id: "1a2b3c", + }, + ], + }, + custom_attributes: { + key: "value", + }, + first_contact_reply: { + created_at: 1734537722, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + sla_status: "hit", + }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, + ], + assigned_team_first_response_time_in_office_hours: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ + { + type: "conversation_part", + id: "149", + part_type: "open", + body: "

This message was deleted

", + created_at: 1734537722, + updated_at: 1734537724, + notified_at: 1734537722, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "user", + id: "6762f1f81bb69f9f2193bc09", + name: "Joe Bloggs", + email: "joe@bloggs.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: true, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + ], + total_count: 1, + }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: false, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], + }); + }); + + test("redactConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + type: "conversation_part", + conversation_id: "conversation_id", + conversation_part_id: "conversation_part_id", + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/redact") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParts.redactConversation({ + type: "conversation_part", + conversation_id: "conversation_id", + conversation_part_id: "conversation_part_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("redactConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + type: "conversation_part", + conversation_id: "conversation_id", + conversation_part_id: "conversation_part_id", + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/conversations/redact") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationParts.redactConversation({ + type: "conversation_part", + conversation_id: "conversation_id", + conversation_part_id: "conversation_part_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); +}); diff --git a/tests/wire/unstable/conversations.test.ts b/tests/wire/preview/conversations.test.ts similarity index 62% rename from tests/wire/unstable/conversations.test.ts rename to tests/wire/preview/conversations.test.ts index 88fb1544..17f35697 100644 --- a/tests/wire/unstable/conversations.test.ts +++ b/tests/wire/preview/conversations.test.ts @@ -28,10 +28,9 @@ describe("ConversationsClient", () => { open: false, state: "closed", read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { id: "531ee472cce572a6ec000006", name: "Blue Sun", @@ -64,14 +63,7 @@ describe("ConversationsClient", () => { delivered_as: "admin_initiated", subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267628", - name: "Ciaran166 Lee", - email: "admin166@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267628", name: "Ciaran166 Lee", email: "admin166@email.com" }, attachments: [ { type: "upload", @@ -83,6 +75,7 @@ describe("ConversationsClient", () => { height: 100, }, ], + url: "https://intercom.help/company/article/123", redacted: false, }, contacts: { @@ -120,7 +113,6 @@ describe("ConversationsClient", () => { handling_time: 2310, adjusted_handling_time: 1800, }, - conversation_parts: { total_count: 1 }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, ai_agent_participated: false, ai_agent: { @@ -130,6 +122,47 @@ describe("ConversationsClient", () => { created_at: 1663597260, updated_at: 1663597260, }, + sales_agent_participated: false, + sales_agent: { + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + }, + ], }, ], total_count: 1, @@ -143,9 +176,11 @@ describe("ConversationsClient", () => { }; server.mockEndpoint().get("/conversations").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.conversations.listConversations({ + const response = await client.preview.conversations.listConversations({ per_page: 1, starting_after: "starting_after", + include_monitors: true, + include_scorecards: true, }); expect(response).toEqual({ type: "conversation.list", @@ -161,10 +196,9 @@ describe("ConversationsClient", () => { open: false, state: "closed", read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { id: "531ee472cce572a6ec000006", name: "Blue Sun", @@ -214,8 +248,6 @@ describe("ConversationsClient", () => { id: "991267628", name: "Ciaran166 Lee", email: "admin166@email.com", - from_ai_agent: true, - is_ai_answer: false, }, attachments: [ { @@ -228,6 +260,7 @@ describe("ConversationsClient", () => { height: 100, }, ], + url: "https://intercom.help/company/article/123", redacted: false, }, contacts: { @@ -278,9 +311,6 @@ describe("ConversationsClient", () => { handling_time: 2310, adjusted_handling_time: 1800, }, - conversation_parts: { - total_count: 1, - }, linked_objects: { type: "list", total_count: 0, @@ -299,6 +329,62 @@ describe("ConversationsClient", () => { created_at: 1663597260, updated_at: 1663597260, }, + sales_agent_participated: false, + sales_agent: { + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + }, + ], }, ], total_count: 1, @@ -324,12 +410,385 @@ describe("ConversationsClient", () => { environment: server.baseUrl, }); - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/conversations").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + const rawResponseBody = { + type: "conversation.list", + conversations: [ + { + type: "conversation", + id: "601", + title: "Conversation Title", + created_at: 1734537700, + updated_at: 1734537760, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + }, + conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894 }, + source: { + type: "email", + id: "3", + delivered_as: "operator_initiated", + subject: "", + body: "

Hey there!

", + url: "https://intercom.help/company/article/123", + redacted: false, + }, + teammates: { type: "admin.list" }, + custom_attributes: { + paid_subscriber: { type: "order.list" }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { type: "conversation_sla_summary", sla_name: "" }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + handling_time: 2310, + adjusted_handling_time: 1800, + }, + linked_objects: { total_count: 100, has_more: false }, + ai_agent_participated: false, + ai_agent: { + source_title: "My AI Workflow", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + }, + sales_agent_participated: false, + sales_agent: { + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1734537760, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1734537760, + reviewed_teammate: { type: "admin", admin_id: "991267715" }, + reviewer: { type: "admin", admin_id: "884120017" }, + review_status: "submitted", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + result: { + value: "pass", + source: "ai", + reasoning: + "The agent acknowledged the issue and resolved it within the same response.", + reason_ids: ["101", "102"], + other_text: + "Agent acknowledged the issue but missed the follow-up question about billing.", + }, + }, + ], + }, + ], + }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 20, + total_pages: 1, + }, + }; + server.mockEndpoint().get("/conversations").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - await expect(async () => { - return await client.unstable.conversations.listConversations(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + const response = await client.preview.conversations.listConversations({ + per_page: 1, + starting_after: "starting_after", + include_monitors: true, + include_scorecards: true, + }); + expect(response).toEqual({ + type: "conversation.list", + conversations: [ + { + type: "conversation", + id: "601", + title: "Conversation Title", + created_at: 1734537700, + updated_at: 1734537760, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + }, + source: { + type: "email", + id: "3", + delivered_as: "operator_initiated", + subject: "", + body: "

Hey there!

", + url: "https://intercom.help/company/article/123", + redacted: false, + }, + teammates: { + type: "admin.list", + }, + custom_attributes: { + paid_subscriber: { + type: "order.list", + }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + handling_time: 2310, + adjusted_handling_time: 1800, + }, + linked_objects: { + total_count: 100, + has_more: false, + }, + ai_agent_participated: false, + ai_agent: { + source_title: "My AI Workflow", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + }, + sales_agent_participated: false, + sales_agent: { + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1734537760, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1734537760, + reviewed_teammate: { + type: "admin", + admin_id: "991267715", + }, + reviewer: { + type: "admin", + admin_id: "884120017", + }, + review_status: "submitted", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + result: { + value: "pass", + source: "ai", + reasoning: + "The agent acknowledged the issue and resolved it within the same response.", + reason_ids: ["101", "102"], + other_text: + "Agent acknowledged the issue but missed the follow-up question about billing.", + }, + }, + ], + }, + ], + }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 20, + total_pages: 1, + }, + }); }); test("listConversations (3)", async () => { @@ -342,14 +801,14 @@ describe("ConversationsClient", () => { }); const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/conversations").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); + server.mockEndpoint().get("/conversations").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.conversations.listConversations(); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); + return await client.preview.conversations.listConversations(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); - test("createConversation (1)", async () => { + test("listConversations (4)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -357,7 +816,28 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { from: { type: "user", id: "6762f11b1bb69f9f2193bba3" }, body: "Hello there" }; + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/conversations").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.conversations.listConversations(); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("createConversation (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + from: { type: "user", id: "6762f11b1bb69f9f2193bba3" }, + body: "Hello there", + brand_id: "123", + }; const rawResponseBody = { type: "user_message", id: "403918330", @@ -376,12 +856,13 @@ describe("ConversationsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.createConversation({ + const response = await client.preview.conversations.createConversation({ from: { type: "user", id: "6762f11b1bb69f9f2193bba3", }, body: "Hello there", + brand_id: "123", }); expect(response).toEqual({ type: "user_message", @@ -421,7 +902,7 @@ describe("ConversationsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.createConversation({ + const response = await client.preview.conversations.createConversation({ from: { type: "user", id: "123_doesnt_exist", @@ -459,14 +940,14 @@ describe("ConversationsClient", () => { .build(); await expect(async () => { - return await client.unstable.conversations.createConversation({ + return await client.preview.conversations.createConversation({ from: { type: "lead", id: "blackcurrant............", }, body: "body", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createConversation (4)", async () => { @@ -489,14 +970,14 @@ describe("ConversationsClient", () => { .build(); await expect(async () => { - return await client.unstable.conversations.createConversation({ + return await client.preview.conversations.createConversation({ from: { type: "lead", id: "blackcurrant............", }, body: "body", }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); + }).rejects.toThrow(Intercom.preview.ForbiddenError); }); test("createConversation (5)", async () => { @@ -519,14 +1000,14 @@ describe("ConversationsClient", () => { .build(); await expect(async () => { - return await client.unstable.conversations.createConversation({ + return await client.preview.conversations.createConversation({ from: { type: "lead", id: "blackcurrant............", }, body: "body", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("retrieveConversation (1)", async () => { @@ -549,10 +1030,9 @@ describe("ConversationsClient", () => { open: false, state: "closed", read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -575,7 +1055,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -619,16 +1099,11 @@ describe("ConversationsClient", () => { type: "conversation", id: "403918334", delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267645", - name: "Ciaran176 Lee", - email: "admin176@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267645", name: "Ciaran176 Lee", email: "admin176@email.com" }, attachments: [ { type: "upload", @@ -640,8 +1115,14 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", @@ -675,9 +1156,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -695,7 +1174,8 @@ describe("ConversationsClient", () => { created_at: 1663597223, updated_at: 1663597260, notified_at: 1663597260, - assigned_to: { type: "contact", id: "1a2b3c" }, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", id: "274", @@ -720,6 +1200,7 @@ describe("ConversationsClient", () => { state: "open", tags: [{ type: "tag", id: "123456", name: "Test tag" }], app_package_code: "test-integration", + translations: { original: "en", en: "

Okay!

", fr: "

D'accord!

" }, }, { type: "conversation_part", @@ -729,6 +1210,8 @@ describe("ConversationsClient", () => { created_at: 1740141842, updated_at: 1740141842, notified_at: 1740141842, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", id: "274", @@ -754,6 +1237,7 @@ describe("ConversationsClient", () => { tags: [{ type: "tag", id: "123456", name: "Test tag" }], event_details: { action: { name: "Jira Create Issue" } }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "conversation_part", @@ -763,6 +1247,8 @@ describe("ConversationsClient", () => { created_at: 1740141851, updated_at: 1740141851, notified_at: 1740141851, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", id: "278", @@ -788,6 +1274,7 @@ describe("ConversationsClient", () => { tags: [{ type: "tag", id: "123456", name: "Test tag" }], event_details: { attribute: { name: "jira_issue_key" }, value: { name: "PROJ-007" } }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "conversation_part", @@ -797,6 +1284,8 @@ describe("ConversationsClient", () => { created_at: 1740141857, updated_at: 1740141857, notified_at: 1740141857, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", id: "274", @@ -822,11 +1311,93 @@ describe("ConversationsClient", () => { tags: [{ type: "tag", id: "123456", name: "Test tag" }], event_details: { action: { name: "Jira Create Issue", result: "success" } }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + { + type: "conversation_part", + id: "3", + part_type: "call_summary", + body: "

The customer asked about a failed payroll run and was advised to re-submit it.

", + created_at: 1740141860, + updated_at: 1740141902, + notified_at: 1740141860, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "278", + name: "Fin", + email: "operator+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + state: "closed", + tags: [{ type: "tag", id: "123456", name: "Test tag" }], + event_details: { call_id: "3822007689" }, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + { + type: "conversation_part", + id: "3", + part_type: "ai_agent_event", + body: "

Okay!

", + created_at: 1740141870, + updated_at: 1740141870, + notified_at: 1740141870, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "278", + name: "Fin", + email: "operator+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + state: "closed", + tags: [{ type: "tag", id: "123456", name: "Test tag" }], + event_details: { + event: { + type: "otp_email_verification_failed", + value: "OTP email verification failed", + data: { otp_email_verification_failed: { reason: "no_email" } }, + }, + }, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], - total_count: 4, + total_count: 6, }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -849,13 +1420,62 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server.mockEndpoint().get("/conversations/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.conversations.retrieveConversation({ + const response = await client.preview.conversations.retrieveConversation({ id: 1, display_as: "plaintext", include_translations: true, + include_email_history: true, + include_monitors: true, + include_scorecards: true, }); expect(response).toEqual({ type: "conversation", @@ -868,10 +1488,9 @@ describe("ConversationsClient", () => { open: false, state: "closed", read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -900,6 +1519,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -959,6 +1585,18 @@ describe("ConversationsClient", () => { type: "conversation", id: "403918334", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { @@ -966,8 +1604,6 @@ describe("ConversationsClient", () => { id: "991267645", name: "Ciaran176 Lee", email: "admin176@email.com", - from_ai_agent: true, - is_ai_answer: false, }, attachments: [ { @@ -980,8 +1616,20 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", @@ -1035,7 +1683,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -1063,10 +1711,8 @@ describe("ConversationsClient", () => { created_at: 1663597223, updated_at: 1663597260, notified_at: 1663597260, - assigned_to: { - type: "contact", - id: "1a2b3c", - }, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", id: "274", @@ -1097,6 +1743,11 @@ describe("ConversationsClient", () => { }, ], app_package_code: "test-integration", + translations: { + original: "en", + en: "

Okay!

", + fr: "

D'accord!

", + }, }, { type: "conversation_part", @@ -1106,6 +1757,8 @@ describe("ConversationsClient", () => { created_at: 1740141842, updated_at: 1740141842, notified_at: 1740141842, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", id: "274", @@ -1141,6 +1794,11 @@ describe("ConversationsClient", () => { }, }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "conversation_part", @@ -1150,6 +1808,8 @@ describe("ConversationsClient", () => { created_at: 1740141851, updated_at: 1740141851, notified_at: 1740141851, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", id: "278", @@ -1188,6 +1848,11 @@ describe("ConversationsClient", () => { }, }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "conversation_part", @@ -1197,6 +1862,8 @@ describe("ConversationsClient", () => { created_at: 1740141857, updated_at: 1740141857, notified_at: 1740141857, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", id: "274", @@ -1233,9 +1900,120 @@ describe("ConversationsClient", () => { }, }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + { + type: "conversation_part", + id: "3", + part_type: "call_summary", + body: "

The customer asked about a failed payroll run and was advised to re-submit it.

", + created_at: 1740141860, + updated_at: 1740141902, + notified_at: 1740141860, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "278", + name: "Fin", + email: "operator+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + state: "closed", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + event_details: { + call_id: "3822007689", + }, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + { + type: "conversation_part", + id: "3", + part_type: "ai_agent_event", + body: "

Okay!

", + created_at: 1740141870, + updated_at: 1740141870, + notified_at: 1740141870, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "278", + name: "Fin", + email: "operator+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + state: "closed", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + event_details: { + event: { + type: "otp_email_verification_failed", + value: "OTP email verification failed", + data: { + otp_email_verification_failed: { + reason: "no_email", + }, + }, + }, + }, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], - total_count: 4, + total_count: 6, }, linked_objects: { type: "list", @@ -1247,6 +2025,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -1269,6 +2056,75 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); @@ -1281,82 +2137,20 @@ describe("ConversationsClient", () => { environment: server.baseUrl, }); - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/conversations/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.conversations.retrieveConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/conversations/1").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.conversations.retrieveConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("retrieveConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/conversations/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.conversations.retrieveConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("updateConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - read: true, - title: "new conversation title", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; const rawResponseBody = { type: "conversation", - id: "507", + id: "504", title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, + created_at: 1774370019, + updated_at: 1774370019, + waiting_since: 1774370020, snoozed_until: 1663597260, open: false, state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -1379,7 +2173,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -1399,7 +2193,18 @@ describe("ConversationsClient", () => { ], }, }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + applied_by: { type: "contact", id: "1a2b3c" }, + }, + ], + }, conversation_rating: { rating: 5, remark: "", @@ -1409,19 +2214,14 @@ describe("ConversationsClient", () => { teammate: { type: "contact", id: "1a2b3c" }, }, source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + type: "email", + id: "403918334", + delivered_as: "customer_initiated", + recipients: [{ type: "to", email: "testing-workspace@email.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], + subject: "

Re: Bug query

", + body: "

This is the message body

", + author: { type: "lead", id: "991267645", name: "Ciaran176 Lee", email: "admin176@email.com" }, attachments: [ { type: "upload", @@ -1433,15 +2233,24 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "abc-123@mail.example.com", + subject: "Re: Bug query", + email_address_headers: [ + { type: "from", email_address: "user@example.com", name: "User Name" }, + { type: "to", email_address: "anotheruser@example.com", name: "Another Name" }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f1301bb69f9f2193bbab", external_id: "70" }], + contacts: [{ type: "contact", id: "6762f1261bb69f9f2193bba7", external_id: "70" }], }, teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { issue_type: "Billing", priority: "High" }, + custom_attributes: { key: "value" }, first_contact_reply: { created_at: 1663597223, type: "conversation", @@ -1468,9 +2277,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -1482,17 +2289,92 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "129", + id: "3", + part_type: "comment", + body: "

Okay!

", + created_at: 1663597223, + updated_at: 1663597260, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "274", + name: "Operator", + email: "operator+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + state: "open", + tags: [{ type: "tag", id: "123456", name: "Test tag" }], + app_package_code: "test-integration", + translations: { original: "en", en: "

Okay!

", fr: "

D'accord!

" }, + }, + { + type: "conversation_part", + id: "3", + part_type: "custom_action_started", + body: "

Okay!

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

Hello

", fr: "

Bonjour

" }, + }, + { + type: "conversation_part", + id: "3", part_type: "conversation_attribute_updated_by_admin", body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, + created_at: 1740141851, + updated_at: 1740141851, + notified_at: 1740141851, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", - id: "991267654", + id: "278", name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", + email: "operator+abcd1234@intercom.io", from_ai_agent: true, is_ai_answer: false, }, @@ -1509,22 +2391,64 @@ describe("ConversationsClient", () => { ], external_id: "abcd1234", redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, + state: "open", + tags: [{ type: "tag", id: "123456", name: "Test tag" }], + event_details: { attribute: { name: "jira_issue_key" }, value: { name: "PROJ-007" } }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", + id: "3", + part_type: "custom_action_finished", body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, + created_at: 1740141857, + updated_at: 1740141857, + notified_at: 1740141857, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "274", + name: "Jamie Oliver", + email: "jamie+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + state: "closed", + tags: [{ type: "tag", id: "123456", name: "Test tag" }], + event_details: { action: { name: "Jira Create Issue", result: "success" } }, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + { + type: "conversation_part", + id: "3", + part_type: "ai_agent_event", + body: "

Okay!

", + created_at: 1740141870, + updated_at: 1740141870, + notified_at: 1740141870, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", - id: "991267654", + id: "278", name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", + email: "operator+abcd1234@intercom.io", from_ai_agent: true, is_ai_answer: false, }, @@ -1541,13 +2465,23 @@ describe("ConversationsClient", () => { ], external_id: "abcd1234", redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, + state: "closed", + tags: [{ type: "tag", id: "123456", name: "Test tag" }], + event_details: { + event: { + type: "otp_email_verification_failed", + value: "OTP email verification failed", + data: { otp_email_verification_failed: { reason: "no_email" } }, + }, + }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], - total_count: 2, + total_count: 5, }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -1570,41 +2504,77 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/conversations/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.conversations.updateConversation({ + const response = await client.preview.conversations.retrieveConversation({ id: 1, display_as: "plaintext", - read: true, - title: "new conversation title", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, + include_translations: true, + include_email_history: true, + include_monitors: true, + include_scorecards: true, }); expect(response).toEqual({ type: "conversation", - id: "507", + id: "504", title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, + created_at: 1774370019, + updated_at: 1774370019, + waiting_since: 1774370020, snoozed_until: 1663597260, open: false, state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -1633,6 +2603,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -1666,6 +2643,10 @@ describe("ConversationsClient", () => { id: "123456", name: "Test tag", applied_at: 1663597223, + applied_by: { + type: "contact", + id: "1a2b3c", + }, }, ], }, @@ -1685,39 +2666,66 @@ describe("ConversationsClient", () => { }, }, source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ + type: "email", + id: "403918334", + delivered_as: "customer_initiated", + recipients: [ { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", + type: "to", + email: "testing-workspace@email.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], + subject: "

Re: Bug query

", + body: "

This is the message body

", + author: { + type: "lead", + id: "991267645", + name: "Ciaran176 Lee", + email: "admin176@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", content_type: "image/png", filesize: 100, width: 100, height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "abc-123@mail.example.com", + subject: "Re: Bug query", + email_address_headers: [ + { + type: "from", + email_address: "user@example.com", + name: "User Name", + }, + { + type: "to", + email_address: "anotheruser@example.com", + name: "Another Name", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { type: "contact", - id: "6762f1301bb69f9f2193bbab", + id: "6762f1261bb69f9f2193bba7", external_id: "70", }, ], @@ -1732,8 +2740,7 @@ describe("ConversationsClient", () => { ], }, custom_attributes: { - issue_type: "Billing", - priority: "High", + key: "value", }, first_contact_reply: { created_at: 1663597223, @@ -1765,7 +2772,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -1787,17 +2794,116 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "129", + id: "3", + part_type: "comment", + body: "

Okay!

", + created_at: 1663597223, + updated_at: 1663597260, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "274", + name: "Operator", + email: "operator+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + state: "open", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Okay!

", + fr: "

D'accord!

", + }, + }, + { + type: "conversation_part", + id: "3", + part_type: "custom_action_started", + body: "

Okay!

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

Hello

", + fr: "

Bonjour

", + }, + }, + { + type: "conversation_part", + id: "3", part_type: "conversation_attribute_updated_by_admin", body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, + created_at: 1740141851, + updated_at: 1740141851, + notified_at: 1740141851, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", - id: "991267654", + id: "278", name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", + email: "operator+abcd1234@intercom.io", from_ai_agent: true, is_ai_answer: false, }, @@ -1814,24 +2920,96 @@ describe("ConversationsClient", () => { ], external_id: "abcd1234", redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + state: "open", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + event_details: { + attribute: { + name: "jira_issue_key", + }, + value: { + name: "PROJ-007", + }, }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", + id: "3", + part_type: "custom_action_finished", body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, + created_at: 1740141857, + updated_at: 1740141857, + notified_at: 1740141857, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "274", + name: "Jamie Oliver", + email: "jamie+abcd1234@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + state: "closed", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + event_details: { + action: { + name: "Jira Create Issue", + result: "success", + }, + }, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + { + type: "conversation_part", + id: "3", + part_type: "ai_agent_event", + body: "

Okay!

", + created_at: 1740141870, + updated_at: 1740141870, + notified_at: 1740141870, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", - id: "991267654", + id: "278", name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", + email: "operator+abcd1234@intercom.io", from_ai_agent: true, is_ai_answer: false, }, @@ -1848,13 +3026,34 @@ describe("ConversationsClient", () => { ], external_id: "abcd1234", redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + state: "closed", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + event_details: { + event: { + type: "otp_email_verification_failed", + value: "OTP email verification failed", + data: { + otp_email_verification_failed: { + reason: "no_email", + }, + }, + }, }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], - total_count: 2, + total_count: 5, }, linked_objects: { type: "list", @@ -1866,6 +3065,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -1888,10 +3096,79 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); - test("updateConversation (2)", async () => { + test("retrieveConversation (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -1899,22 +3176,21 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { custom_attributes: { order: {} } }; + const rawResponseBody = { type: "conversation", - id: "508", + id: "601", title: "Conversation Title", - created_at: 1734537525, - updated_at: 1734537525, + created_at: 1734537700, + updated_at: 1734537760, waiting_since: 1663597260, snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -1937,7 +3213,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -1967,19 +3243,14 @@ describe("ConversationsClient", () => { teammate: { type: "contact", id: "1a2b3c" }, }, source: { - type: "conversation", - id: "403918339", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267659", - name: "Ciaran185 Lee", - email: "admin185@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + type: "email", + id: "3", + delivered_as: "operator_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], + subject: "", + body: "

Hey there!

", + author: { type: "admin", id: "274", name: "Jane Doe", email: "jane.doe@example.com" }, attachments: [ { type: "upload", @@ -1991,30 +3262,26 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1341bb69f9f2193bbac", external_id: "70" }], - }, + contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1671028894, - updated_at: 1671028894, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }, - ], - }, + paid_subscriber: { type: "order.list", instances: [] }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", }, first_contact_reply: { created_at: 1663597223, @@ -2042,9 +3309,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -2062,14 +3327,18 @@ describe("ConversationsClient", () => { created_at: 1663597223, updated_at: 1663597260, notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], - total_count: 0, + total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -2092,38 +3361,89 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1734537760, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1734537760, + reviewed_teammate: { type: "admin", admin_id: "991267715" }, + reviewer: { type: "admin", admin_id: "884120017" }, + review_status: "submitted", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + result: { + value: "pass", + source: "ai", + reasoning: "The agent acknowledged the issue and resolved it within the same response.", + reason_ids: ["101", "102"], + other_text: + "Agent acknowledged the issue but missed the follow-up question about billing.", + }, + }, + ], + }, + ], }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/conversations/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.conversations.updateConversation({ + const response = await client.preview.conversations.retrieveConversation({ id: 1, display_as: "plaintext", - custom_attributes: { - order: {}, - }, + include_translations: true, + include_email_history: true, + include_monitors: true, + include_scorecards: true, }); expect(response).toEqual({ type: "conversation", - id: "508", + id: "601", title: "Conversation Title", - created_at: 1734537525, - updated_at: 1734537525, + created_at: 1734537700, + updated_at: 1734537760, waiting_since: 1663597260, snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -2152,6 +3472,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -2204,18 +3531,28 @@ describe("ConversationsClient", () => { }, }, source: { - type: "conversation", - id: "403918339", - delivered_as: "admin_initiated", + type: "email", + id: "3", + delivered_as: "operator_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", - body: "

this is the message body

", + body: "

Hey there!

", author: { type: "admin", - id: "991267659", - name: "Ciaran185 Lee", - email: "admin185@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "274", + name: "Jane Doe", + email: "jane.doe@example.com", }, attachments: [ { @@ -2228,15 +3565,26 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { - type: "contact", - id: "6762f1341bb69f9f2193bbac", + id: "5ba682d23d7cf92bef87bfd4", external_id: "70", }, ], @@ -2251,24 +3599,17 @@ describe("ConversationsClient", () => { ], }, custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1671028894, - updated_at: 1671028894, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }, - ], + paid_subscriber: { + type: "order.list", + instances: [], }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", }, first_contact_reply: { created_at: 1663597223, @@ -2300,7 +3641,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -2328,16 +3669,23 @@ describe("ConversationsClient", () => { created_at: 1663597223, updated_at: 1663597260, notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], - total_count: 0, + total_count: 1, }, linked_objects: { type: "list", - total_count: 0, + total_count: 100, has_more: false, data: [ { @@ -2345,6 +3693,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -2367,10 +3724,165 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1734537760, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1734537760, + reviewed_teammate: { + type: "admin", + admin_id: "991267715", + }, + reviewer: { + type: "admin", + admin_id: "884120017", + }, + review_status: "submitted", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + result: { + value: "pass", + source: "ai", + reasoning: "The agent acknowledged the issue and resolved it within the same response.", + reason_ids: ["101", "102"], + other_text: + "Agent acknowledged the issue but missed the follow-up question about billing.", + }, + }, + ], + }, + ], }); }); - test("updateConversation (3)", async () => { + test("retrieveConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/conversations/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.conversations.retrieveConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/conversations/1").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.conversations.retrieveConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("retrieveConversation (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/conversations/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.conversations.retrieveConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("retrieveConversation (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/conversations/1").respondWith().statusCode(422).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.conversations.retrieveConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("updateConversation (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -2381,7 +3893,9 @@ describe("ConversationsClient", () => { const rawRequestBody = { read: true, title: "new conversation title", - custom_attributes: { issue_type: "Billing", priority: "High" }, + priority: "high", + admin_id: "394051", + custom_attributes: { issue_type: "Billing" }, }; const rawResponseBody = { type: "conversation", @@ -2394,10 +3908,9 @@ describe("ConversationsClient", () => { open: false, state: "closed", read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "high", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -2420,7 +3933,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -2453,16 +3966,11 @@ describe("ConversationsClient", () => { type: "conversation", id: "403918338", delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267653", name: "Ciaran180 Lee", email: "admin180@email.com" }, attachments: [ { type: "upload", @@ -2474,15 +3982,21 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [{ type: "contact", id: "6762f1301bb69f9f2193bbab", external_id: "70" }], }, teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { issue_type: "Billing", priority: "High" }, + custom_attributes: { issue_type: "Billing" }, first_contact_reply: { created_at: 1663597223, type: "conversation", @@ -2509,9 +4023,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -2529,6 +4041,8 @@ describe("ConversationsClient", () => { created_at: 1734537523, updated_at: 1734537523, notified_at: 1734537523, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", id: "991267654", @@ -2552,6 +4066,7 @@ describe("ConversationsClient", () => { redacted: false, metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "conversation_part", @@ -2561,6 +4076,8 @@ describe("ConversationsClient", () => { created_at: 1734537523, updated_at: 1734537523, notified_at: 1734537523, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", id: "991267654", @@ -2584,11 +4101,13 @@ describe("ConversationsClient", () => { redacted: false, metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 2, }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -2611,24 +4130,71 @@ describe("ConversationsClient", () => { ], }, }, - }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], + }; + server + .mockEndpoint() + .put("/conversations/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); - const response = await client.unstable.conversations.updateConversation({ + const response = await client.preview.conversations.updateConversation({ id: 1, display_as: "plaintext", read: true, title: "new conversation title", + priority: "high", + admin_id: "394051", custom_attributes: { issue_type: "Billing", - priority: "High", }, }); expect(response).toEqual({ @@ -2642,10 +4208,9 @@ describe("ConversationsClient", () => { open: false, state: "closed", read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "high", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -2674,6 +4239,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -2729,6 +4301,18 @@ describe("ConversationsClient", () => { type: "conversation", id: "403918338", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { @@ -2736,8 +4320,6 @@ describe("ConversationsClient", () => { id: "991267653", name: "Ciaran180 Lee", email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, }, attachments: [ { @@ -2750,8 +4332,20 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", @@ -2774,7 +4368,6 @@ describe("ConversationsClient", () => { }, custom_attributes: { issue_type: "Billing", - priority: "High", }, first_contact_reply: { created_at: 1663597223, @@ -2806,7 +4399,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -2834,6 +4427,8 @@ describe("ConversationsClient", () => { created_at: 1734537523, updated_at: 1734537523, notified_at: 1734537523, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", id: "991267654", @@ -2859,6 +4454,11 @@ describe("ConversationsClient", () => { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "conversation_part", @@ -2868,6 +4468,8 @@ describe("ConversationsClient", () => { created_at: 1734537523, updated_at: 1734537523, notified_at: 1734537523, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "bot", id: "991267654", @@ -2893,6 +4495,11 @@ describe("ConversationsClient", () => { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 2, @@ -2907,6 +4514,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -2929,166 +4545,79 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); - test("updateConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.updateConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.updateConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("updateConversation (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.updateConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "512", object: "conversation", deleted: true }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.deleteConversation({ - id: 1, - }); - expect(response).toEqual({ - id: "512", - object: "conversation", - deleted: true, - }); - }); - - test("deleteConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.deleteConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.deleteConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("searchConversations", async () => { + test("updateConversation (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -3096,364 +4625,288 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { - query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, - pagination: { per_page: 5 }, - }; + const rawRequestBody = { custom_attributes: { order: {} } }; const rawResponseBody = { - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "515", - title: "Conversation Title", - created_at: 1734537546, - updated_at: 1734537546, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - tags: { - type: "tag.list", - tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], - }, - conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894 }, - source: { - type: "conversation", - id: "403918346", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267691", - name: "Ciaran210 Lee", - email: "admin210@email.com", - from_ai_agent: true, - is_ai_answer: false, + type: "conversation", + id: "508", + title: "Conversation Title", + created_at: 1734537525, + updated_at: 1734537525, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { type: "plan", id: "269315", name: "Pro" }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f14a1bb69f9f2193bbb3", external_id: "70" }], + ], + }, + notes: { + type: "note.list", + notes: [ + { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, + ], + }, + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, + teammate: { type: "contact", id: "1a2b3c" }, + }, + source: { + type: "conversation", + id: "403918339", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], + subject: "", + body: "

this is the message body

", + author: { type: "admin", id: "991267659", name: "Ciaran185 Lee", email: "admin185@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, }, - teammates: { type: "admin.list" }, - custom_attributes: { key: "value" }, - first_contact_reply: { + ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f1341bb69f9f2193bbac", external_id: "70" }], + }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { + order: { + type: "Order.list", + instances: [ + { + id: "21", + external_id: "123", + external_created_at: 1392036272, + external_updated_at: 1392036272, + created_at: 1671028894, + updated_at: 1671028894, + type: "Order", + custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, + }, + ], + }, + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], + assigned_team_first_response_time_in_office_hours: [ + { team_id: 100, team_name: "Team One", response_time: 2310 }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ + { + type: "conversation_part", + id: "3", + part_type: "comment", + body: "

Okay!

", created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { total_count: 1 }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, updated_at: 1663597260, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + external_id: "abcd1234", + redacted: false, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, + ], + total_count: 0, + }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 5, - total_pages: 1, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/conversations/search") + .put("/conversations/1") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.searchConversations({ - query: { - operator: "AND", - value: [ - { - field: "created_at", - operator: ">", - value: "1306054154", - }, - ], - }, - pagination: { - per_page: 5, + const response = await client.preview.conversations.updateConversation({ + id: 1, + display_as: "plaintext", + custom_attributes: { + order: {}, }, }); expect(response).toEqual({ - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "515", - title: "Conversation Title", - created_at: 1734537546, - updated_at: 1734537546, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - }, - source: { - type: "conversation", - id: "403918346", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

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

Text for the note.

" }, + { + type: "note", + id: "17495962", + created_at: 1674589321, + body: "

Text for the note.

", + }, ], }, }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, + contact: { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + }, + teammate: { + type: "contact", + id: "1a2b3c", + }, }, source: { type: "conversation", - id: "403918349", + id: "403918339", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "991267659", + name: "Ciaran185 Lee", + email: "admin185@email.com", }, attachments: [ { @@ -3524,21 +5018,70 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, - }, - contacts: { + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], + contacts: [ + { + type: "contact", + id: "6762f1341bb69f9f2193bbac", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + teammates: [ + { + type: "contact", + id: "1a2b3c", + }, + ], + }, + custom_attributes: { + order: { + type: "Order.list", + instances: [ + { + id: "21", + external_id: "123", + external_created_at: 1392036272, + external_updated_at: 1392036272, + created_at: 1671028894, + updated_at: 1671028894, + type: "Order", + custom_attributes: { + order_number: "ORDER-12345", + total_amount: "custom_attributes", + }, + }, + ], + }, }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, first_contact_reply: { - created_at: 1734537561, + created_at: 1663597223, type: "conversation", url: "https://developers.intercom.com/", }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + sla_status: "hit", + }, statistics: { type: "conversation_statistics", time_to_assignment: 2310, @@ -3559,11 +5102,19 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, + assigned_team_first_response_time: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, ], assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, ], handling_time: 2310, adjusted_handling_time: 1800, @@ -3573,40 +5124,45 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], + id: "3", + part_type: "comment", + body: "

Okay!

", + created_at: 1663597223, + updated_at: 1663597260, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, external_id: "abcd1234", redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + ], + total_count: 0, + }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", }, ], - total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -3629,50 +5185,113 @@ describe("ConversationsClient", () => { ], }, }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.replyConversation({ - id: '123 or "last"', - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); - expect(response).toEqual({ + }); + + test("updateConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + read: true, + title: "new conversation title", + priority: "high", + admin_id: "394051", + custom_attributes: { issue_type: "Billing" }, + }; + const rawResponseBody = { type: "conversation", - id: "524", + id: "507", title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, + created_at: 1734537521, + updated_at: 1734537523, + waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: false, + state: "closed", + read: true, + priority: "high", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", name: "Blue Sun", app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, + plan: { type: "plan", id: "269315", name: "Pro" }, company_id: "6", remote_created_at: 1663597223, created_at: 1663597223, @@ -3689,9 +5308,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { - type: "tag.list", - }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -3707,55 +5324,28 @@ describe("ConversationsClient", () => { notes: { type: "note.list", notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, + { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, ], }, }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, + contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, + teammate: { type: "contact", id: "1a2b3c" }, }, source: { type: "conversation", - id: "403918349", + id: "403918338", delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267653", name: "Ciaran180 Lee", email: "admin180@email.com" }, attachments: [ { type: "upload", @@ -3767,41 +5357,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1571bb69f9f2193bbbb", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", + contacts: [{ type: "contact", id: "6762f1301bb69f9f2193bbab", external_id: "70" }], }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { issue_type: "Billing" }, first_contact_reply: { - created_at: 1734537561, + created_at: 1663597223, type: "conversation", url: "https://developers.intercom.com/", }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, + sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, statistics: { type: "conversation_statistics", time_to_assignment: 2310, @@ -3822,19 +5398,9 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, + { team_id: 100, team_name: "Team One", response_time: 2310 }, ], handling_time: 2310, adjusted_handling_time: 1800, @@ -3844,17 +5410,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, + id: "129", + part_type: "conversation_attribute_updated_by_admin", + body: "

Okay!

", + created_at: 1734537523, + updated_at: 1734537523, + notified_at: 1734537523, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", + type: "bot", + id: "991267654", + name: "Fin", + email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", from_ai_agent: true, is_ai_answer: false, }, @@ -3871,24 +5439,50 @@ describe("ConversationsClient", () => { ], external_id: "abcd1234", redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ { - id: "7583", + type: "conversation_part", + id: "130", + part_type: "conversation_attribute_updated_by_admin", + body: "

Okay!

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

Hello

", fr: "

Bonjour

" }, }, ], + total_count: 2, }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -3911,44 +5505,97 @@ describe("ConversationsClient", () => { ], }, }, - }); - }); + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], + }; + server + .mockEndpoint() + .put("/conversations/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); - test("replyConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, + const response = await client.preview.conversations.updateConversation({ + id: 1, + display_as: "plaintext", + read: true, + title: "new conversation title", + priority: "high", + admin_id: "394051", + custom_attributes: { + issue_type: "Billing", + }, }); - const rawRequestBody = { - message_type: "note", - type: "admin", - body: "

An Unordered HTML List

  • Coffee
  • Tea
  • Milk

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk
", - admin_id: "3156780", - }; - const rawResponseBody = { + expect(response).toEqual({ type: "conversation", - id: "525", + id: "507", title: "Conversation Title", - created_at: 1734537563, - updated_at: 1734537565, + created_at: 1734537521, + updated_at: 1734537523, waiting_since: 1663597260, snoozed_until: 1663597260, open: false, state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + read: true, + priority: "high", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", name: "Blue Sun", app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, company_id: "6", remote_created_at: 1663597223, created_at: 1663597223, @@ -3965,7 +5612,16 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + }, segments: { type: "segment.list", segments: [ @@ -3981,32 +5637,64 @@ describe("ConversationsClient", () => { notes: { type: "note.list", notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, + { + type: "note", + id: "17495962", + created_at: 1674589321, + body: "

Text for the note.

", + }, ], }, }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, + contact: { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + }, + teammate: { + type: "contact", + id: "1a2b3c", + }, }, source: { type: "conversation", - id: "403918350", + id: "403918338", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "991267653", + name: "Ciaran180 Lee", + email: "admin180@email.com", }, attachments: [ { @@ -4019,21 +5707,53 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f15b1bb69f9f2193bbbc", external_id: "70" }], + contacts: [ + { + type: "contact", + id: "6762f1301bb69f9f2193bbab", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + teammates: [ + { + type: "contact", + id: "1a2b3c", + }, + ], + }, + custom_attributes: { + issue_type: "Billing", }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, first_contact_reply: { created_at: 1663597223, type: "conversation", url: "https://developers.intercom.com/", }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + sla_status: "hit", + }, statistics: { type: "conversation_statistics", time_to_assignment: 2310, @@ -4054,11 +5774,19 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, + assigned_team_first_response_time: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, ], assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, ], handling_time: 2310, adjusted_handling_time: 1800, @@ -4068,20 +5796,22 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "133", - part_type: "note", - body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537565, - updated_at: 1734537565, - notified_at: 1734537565, + id: "129", + part_type: "conversation_attribute_updated_by_admin", + body: "

Okay!

", + created_at: 1734537523, + updated_at: 1734537523, + notified_at: 1734537523, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + type: "bot", + id: "991267654", + name: "Fin", + email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", + from_ai_agent: true, + is_ai_answer: false, + }, attachments: [ { type: "upload", @@ -4095,13 +5825,79 @@ describe("ConversationsClient", () => { ], external_id: "abcd1234", redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + { + type: "conversation_part", + id: "130", + part_type: "conversation_attribute_updated_by_admin", + body: "

Okay!

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

Hello

", + fr: "

Bonjour

", + }, + }, + ], + total_count: 2, + }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", }, ], - total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -4124,235 +5920,297 @@ describe("ConversationsClient", () => { ], }, }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.replyConversation({ - id: '123 or "last"', - body: { - message_type: "note", - type: "admin", - body: "

An Unordered HTML List

  • Coffee
  • Tea
  • Milk

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk
", - admin_id: "3156780", + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, }, - }); - expect(response).toEqual({ - type: "conversation", - id: "525", - title: "Conversation Title", - created_at: 1734537563, - updated_at: 1734537565, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", }, - tags: { - type: "tag.list", + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, }, - segments: { - type: "segment.list", - segments: [ + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", }, ], - }, - notes: { - type: "note.list", - notes: [ + evaluators: [ { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

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

this is the message body

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

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537565, - updated_at: 1734537565, - notified_at: 1734537565, - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, + ], + }); + }); + + test("updateConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/conversations/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.updateConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/conversations/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.updateConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("updateConversation (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/conversations/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.updateConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteConversation (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "512", object: "conversation", deleted: true }; + server + .mockEndpoint() + .delete("/conversations/1") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversations.deleteConversation({ + id: 1, + retain_metrics: true, + }); + expect(response).toEqual({ + id: "512", + object: "conversation", + deleted: true, + }); + }); + + test("deleteConversation (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/conversations/1") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.deleteConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/conversations/1") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.deleteConversation({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("searchConversations (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, + pagination: { per_page: 5 }, + }; + const rawResponseBody = { + type: "conversation.list", + conversations: [ + { + type: "conversation", + id: "515", + title: "Conversation Title", + created_at: 1734537546, + updated_at: 1734537546, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", }, + }, + tags: { + type: "tag.list", + tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], + }, + conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894 }, + source: { + type: "conversation", + id: "403918346", + delivered_as: "admin_initiated", + subject: "", + body: "

this is the message body

", + author: { type: "admin", id: "991267691", name: "Ciaran210 Lee", email: "admin210@email.com" }, attachments: [ { type: "upload", @@ -4364,52 +6222,353 @@ describe("ConversationsClient", () => { height: 100, }, ], - external_id: "abcd1234", + url: "https://intercom.help/company/article/123", redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f14a1bb69f9f2193bbb3", external_id: "70" }], }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ + teammates: { type: "admin.list" }, + custom_attributes: { key: "value" }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { type: "conversation_sla_summary", sla_name: "" }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + handling_time: 2310, + adjusted_handling_time: 1800, + }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_agent_participated: false, + ai_agent: { + source_title: "My AI Workflow", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + }, + sales_agent_participated: false, + sales_agent: { + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + }, + ], + }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 5, + total_pages: 1, + }, + }; + server + .mockEndpoint() + .post("/conversations/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversations.searchConversations({ + include_monitors: true, + include_scorecards: true, + body: { + query: { + operator: "AND", + value: [ + { + field: "created_at", + operator: ">", + value: "1306054154", + }, + ], + }, + pagination: { + per_page: 5, + }, + }, + }); + expect(response).toEqual({ + type: "conversation.list", + conversations: [ + { + type: "conversation", + id: "515", + title: "Conversation Title", + created_at: 1734537546, + updated_at: 1734537546, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + }, + source: { + type: "conversation", + id: "403918346", + delivered_as: "admin_initiated", + subject: "", + body: "

this is the message body

", + author: { + type: "admin", + id: "991267691", + name: "Ciaran210 Lee", + email: "admin210@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + url: "https://intercom.help/company/article/123", + redacted: false, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f14a1bb69f9f2193bbb3", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + }, + custom_attributes: { + key: "value", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + handling_time: 2310, + adjusted_handling_time: 1800, + }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ai_agent_participated: false, + ai_agent: { + source_title: "My AI Workflow", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + }, + sales_agent_participated: false, + sales_agent: { + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, }, ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + }, + ], + }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", }, + per_page: 5, + total_pages: 1, }, }); }); - test("replyConversation (3)", async () => { + test("searchConversations (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -4418,2102 +6577,411 @@ describe("ConversationsClient", () => { environment: server.baseUrl, }); const rawRequestBody = { - message_type: "quick_reply", - type: "admin", - admin_id: "3156780", - reply_options: [ - { text: "Yes", uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" }, - { text: "No", uuid: "f4a98af1-be56-4948-a57e-e1a83f8484c6" }, - ], - }; - const rawResponseBody = { - type: "conversation", - id: "526", - title: "Conversation Title", - created_at: 1734537567, - updated_at: 1734537568, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

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

this is the message body

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

Okay!

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

Text for the note.

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

this is the message body

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

Okay!

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

Text for the note.

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

this is the message body

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

Thanks again :)

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

Text for the note.

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

this is the message body

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

Thanks again :)

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

Text for the note.

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

this is the message body

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

Thanks again :)

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

Text for the note.

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

this is the message body

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

Thanks again :)

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

Text for the note.

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

this is the message body

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

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", + type: "conversation.list", + conversations: [ + { + type: "conversation", + id: "601", + title: "Conversation Title", + created_at: 1734537700, + updated_at: 1734537760, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + }, + conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894 }, + source: { + type: "email", + id: "3", + delivered_as: "operator_initiated", + subject: "", + body: "

Hey there!

", + url: "https://intercom.help/company/article/123", redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ + teammates: { type: "admin.list" }, + custom_attributes: { + paid_subscriber: { type: "order.list" }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { type: "conversation_sla_summary", sla_name: "" }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + handling_time: 2310, + adjusted_handling_time: 1800, + }, + linked_objects: { total_count: 100, has_more: false }, + ai_agent_participated: false, + ai_agent: { + source_title: "My AI Workflow", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + }, + sales_agent_participated: false, + sales_agent: { + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1734537760, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1734537760, + reviewed_teammate: { type: "admin", admin_id: "991267715" }, + reviewer: { type: "admin", admin_id: "884120017" }, + review_status: "submitted", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + result: { + value: "pass", + source: "ai", + reasoning: + "The agent acknowledged the issue and resolved it within the same response.", + reason_ids: ["101", "102"], + other_text: + "Agent acknowledged the issue but missed the follow-up question about billing.", + }, + }, + ], }, ], }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 5, + total_pages: 1, }, }; server .mockEndpoint() - .post("/conversations/123/parts") + .post("/conversations/search") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.manageConversation({ - id: "123", + const response = await client.preview.conversations.searchConversations({ + include_monitors: true, + include_scorecards: true, body: { - message_type: "close", - type: "admin", - admin_id: "12345", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ + query: { + operator: "AND", + value: [ { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, + field: "created_at", + operator: ">", + value: "1306054154", }, ], }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], + pagination: { + per_page: 5, }, }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, + }); + expect(response).toEqual({ + type: "conversation.list", + conversations: [ + { + type: "conversation", + id: "601", + title: "Conversation Title", + created_at: 1734537700, + updated_at: 1734537760, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + company: { + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f16e1bb69f9f2193bbc2", - external_id: "70", + source: { + type: "email", + id: "3", + delivered_as: "operator_initiated", + subject: "", + body: "

Hey there!

", + url: "https://intercom.help/company/article/123", + redacted: false, + }, + teammates: { + type: "admin.list", + }, + custom_attributes: { + paid_subscriber: { + type: "order.list", + }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + handling_time: 2310, + adjusted_handling_time: 1800, }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, + linked_objects: { + total_count: 100, + has_more: false, }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + ai_agent_participated: false, + ai_agent: { + source_title: "My AI Workflow", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + }, + sales_agent_participated: false, + sales_agent: { + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", }, - app_package_code: "test-integration", }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", + channel: { + initial: "messenger", + current: "messenger", }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ + external_references: [ { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1734537760, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1734537760, + reviewed_teammate: { + type: "admin", + admin_id: "991267715", + }, + reviewer: { + type: "admin", + admin_id: "884120017", + }, + review_status: "submitted", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + result: { + value: "pass", + source: "ai", + reasoning: + "The agent acknowledged the issue and resolved it within the same response.", + reason_ids: ["101", "102"], + other_text: + "Agent acknowledged the issue but missed the follow-up question about billing.", + }, + }, + ], }, ], }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 5, + total_pages: 1, }, }); }); - test("manageConversation (2)", async () => { + test("replyConversation (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -6521,22 +6989,26 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { message_type: "snoozed", admin_id: "5017691", snoozed_until: 1673609604 }; + const rawRequestBody = { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f1571bb69f9f2193bbbb", + }; const rawResponseBody = { type: "conversation", - id: "532", + id: "524", title: "Conversation Title", - created_at: 1734537586, - updated_at: 1734537587, - waiting_since: 1663597260, - snoozed_until: 1734541187, + created_at: 1734537559, + updated_at: 1734537561, + waiting_since: 1734537561, + snoozed_until: 1663597260, open: true, - state: "snoozed", + state: "open", read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -6559,7 +7031,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -6590,18 +7062,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918357", + id: "403918349", delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267694", name: "Ciaran212 Lee", email: "admin212@email.com" }, attachments: [ { type: "upload", @@ -6613,17 +7080,23 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f1711bb69f9f2193bbc3", external_id: "70" }], + contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], }, teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, custom_attributes: { key: "value" }, first_contact_reply: { - created_at: 1663597223, + created_at: 1734537561, type: "conversation", url: "https://developers.intercom.com/", }, @@ -6648,9 +7121,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -6662,17 +7133,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "137", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537587, - updated_at: 1734537587, - notified_at: 1734537587, + id: "132", + part_type: "open", + body: "

Thanks again :)

", + created_at: 1734537561, + updated_at: 1734537561, + notified_at: 1734537561, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", + type: "user", + id: "6762f1571bb69f9f2193bbbb", + name: "Joe Bloggs", + email: "joe@bloggs.com", from_ai_agent: true, is_ai_answer: false, }, @@ -6691,11 +7164,13 @@ describe("ConversationsClient", () => { redacted: false, metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -6718,39 +7193,85 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/conversations/123/parts") + .post("/conversations/123%20or%20%22last%22/reply") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.manageConversation({ - id: "123", - body: { - message_type: "snoozed", - admin_id: "5017691", - snoozed_until: 1673609604, + const response = await client.preview.conversations.replyConversation({ + id: '123 or "last"', + body: { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f1571bb69f9f2193bbbb", }, }); expect(response).toEqual({ type: "conversation", - id: "532", + id: "524", title: "Conversation Title", - created_at: 1734537586, - updated_at: 1734537587, - waiting_since: 1663597260, - snoozed_until: 1734541187, + created_at: 1734537559, + updated_at: 1734537561, + waiting_since: 1734537561, + snoozed_until: 1663597260, open: true, - state: "snoozed", + state: "open", read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -6779,6 +7300,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -6832,17 +7360,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918357", + id: "403918349", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "991267694", + name: "Ciaran212 Lee", + email: "admin212@email.com", }, attachments: [ { @@ -6855,15 +7393,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { type: "contact", - id: "6762f1711bb69f9f2193bbc3", + id: "6762f1571bb69f9f2193bbbb", external_id: "70", }, ], @@ -6881,7 +7431,7 @@ describe("ConversationsClient", () => { key: "value", }, first_contact_reply: { - created_at: 1663597223, + created_at: 1734537561, type: "conversation", url: "https://developers.intercom.com/", }, @@ -6910,7 +7460,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -6932,17 +7482,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "137", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537587, - updated_at: 1734537587, - notified_at: 1734537587, + id: "132", + part_type: "open", + body: "

Thanks again :)

", + created_at: 1734537561, + updated_at: 1734537561, + notified_at: 1734537561, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", + type: "user", + id: "6762f1571bb69f9f2193bbbb", + name: "Joe Bloggs", + email: "joe@bloggs.com", from_ai_agent: true, is_ai_answer: false, }, @@ -6963,6 +7515,11 @@ describe("ConversationsClient", () => { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, @@ -6977,6 +7534,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -6999,10 +7565,79 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); - test("manageConversation (3)", async () => { + test("replyConversation (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -7010,22 +7645,26 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { message_type: "open", admin_id: "5017690" }; + const rawRequestBody = { + message_type: "note", + type: "admin", + body: "

An Unordered HTML List

  • Coffee
  • Tea
  • Milk

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk
", + admin_id: "3156780", + }; const rawResponseBody = { type: "conversation", - id: "537", - title: "", - created_at: 1734537587, - updated_at: 1734537601, + id: "525", + title: "Conversation Title", + created_at: 1734537563, + updated_at: 1734537565, waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -7048,7 +7687,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -7079,18 +7718,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918358", + id: "403918350", delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267696", name: "Ciaran213 Lee", email: "admin213@email.com" }, attachments: [ { type: "upload", @@ -7102,12 +7736,18 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f1781bb69f9f2193bbc8", external_id: "74" }], + contacts: [{ type: "contact", id: "6762f15b1bb69f9f2193bbbc", external_id: "70" }], }, teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, custom_attributes: { key: "value" }, @@ -7137,9 +7777,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -7151,17 +7789,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "139", - part_type: "open", - body: "

Okay!

", - created_at: 1734537601, - updated_at: 1734537601, - notified_at: 1734537601, + id: "133", + part_type: "note", + body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", + created_at: 1734537565, + updated_at: 1734537565, + notified_at: 1734537565, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", + id: "991267696", + name: "Ciaran213 Lee", + email: "admin213@email.com", from_ai_agent: true, is_ai_answer: false, }, @@ -7180,11 +7820,13 @@ describe("ConversationsClient", () => { redacted: false, metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -7207,38 +7849,85 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/conversations/123/parts") + .post("/conversations/123%20or%20%22last%22/reply") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.manageConversation({ - id: "123", + const response = await client.preview.conversations.replyConversation({ + id: '123 or "last"', body: { - message_type: "open", - admin_id: "5017690", + message_type: "note", + type: "admin", + body: "

An Unordered HTML List

  • Coffee
  • Tea
  • Milk

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk
", + admin_id: "3156780", }, }); expect(response).toEqual({ type: "conversation", - id: "537", - title: "", - created_at: 1734537587, - updated_at: 1734537601, + id: "525", + title: "Conversation Title", + created_at: 1734537563, + updated_at: 1734537565, waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -7267,6 +7956,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -7320,17 +8016,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918358", + id: "403918350", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "991267696", + name: "Ciaran213 Lee", + email: "admin213@email.com", }, attachments: [ { @@ -7343,16 +8049,28 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { type: "contact", - id: "6762f1781bb69f9f2193bbc8", - external_id: "74", + id: "6762f15b1bb69f9f2193bbbc", + external_id: "70", }, ], }, @@ -7398,7 +8116,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -7420,17 +8138,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "139", - part_type: "open", - body: "

Okay!

", - created_at: 1734537601, - updated_at: 1734537601, - notified_at: 1734537601, + id: "133", + part_type: "note", + body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", + created_at: 1734537565, + updated_at: 1734537565, + notified_at: 1734537565, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", + id: "991267696", + name: "Ciaran213 Lee", + email: "admin213@email.com", from_ai_agent: true, is_ai_answer: false, }, @@ -7451,6 +8171,11 @@ describe("ConversationsClient", () => { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, @@ -7465,6 +8190,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -7487,10 +8221,79 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); - test("manageConversation (4)", async () => { + test("replyConversation (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -7498,22 +8301,29 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { message_type: "assignment", type: "admin", admin_id: "12345", assignee_id: "4324241" }; + const rawRequestBody = { + message_type: "quick_reply", + type: "admin", + admin_id: "3156780", + reply_options: [ + { text: "Yes", uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" }, + { text: "No", uuid: "f4a98af1-be56-4948-a57e-e1a83f8484c6" }, + ], + }; const rawResponseBody = { type: "conversation", - id: "542", + id: "526", title: "Conversation Title", - created_at: 1734537603, - updated_at: 1734537605, + created_at: 1734537567, + updated_at: 1734537568, waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", + open: false, + state: "closed", read: false, - priority: "not_priority", + priority: "none", admin_assignee_id: 991267715, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -7536,7 +8346,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -7567,18 +8377,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918361", + id: "403918351", delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267698", name: "Ciaran214 Lee", email: "admin214@email.com" }, attachments: [ { type: "upload", @@ -7590,12 +8395,18 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f1831bb69f9f2193bbcc", external_id: "70" }], + contacts: [{ type: "contact", id: "6762f15e1bb69f9f2193bbbd", external_id: "70" }], }, teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, custom_attributes: { key: "value" }, @@ -7625,9 +8436,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -7639,18 +8448,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "140", - part_type: "assign_and_reopen", + id: "134", + part_type: "quick_reply", body: "

Okay!

", - created_at: 1734537605, - updated_at: 1734537605, - notified_at: 1734537605, - assigned_to: { type: "admin", id: "991267715" }, + created_at: 1734537568, + updated_at: 1734537568, + notified_at: 1734537568, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", + id: "991267698", + name: "Ciaran214 Lee", + email: "admin214@email.com", from_ai_agent: true, is_ai_answer: false, }, @@ -7669,11 +8479,13 @@ describe("ConversationsClient", () => { redacted: false, metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -7696,40 +8508,94 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/conversations/123/parts") + .post("/conversations/123%20or%20%22last%22/reply") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.manageConversation({ - id: "123", + const response = await client.preview.conversations.replyConversation({ + id: '123 or "last"', body: { - message_type: "assignment", + message_type: "quick_reply", type: "admin", - admin_id: "12345", - assignee_id: "4324241", + admin_id: "3156780", + reply_options: [ + { + text: "Yes", + uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb", + }, + { + text: "No", + uuid: "f4a98af1-be56-4948-a57e-e1a83f8484c6", + }, + ], }, }); expect(response).toEqual({ type: "conversation", - id: "542", + id: "526", title: "Conversation Title", - created_at: 1734537603, - updated_at: 1734537605, + created_at: 1734537567, + updated_at: 1734537568, waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", + open: false, + state: "closed", read: false, - priority: "not_priority", + priority: "none", admin_assignee_id: 991267715, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -7758,6 +8624,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -7811,17 +8684,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918361", + id: "403918351", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "991267698", + name: "Ciaran214 Lee", + email: "admin214@email.com", }, attachments: [ { @@ -7834,15 +8717,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { type: "contact", - id: "6762f1831bb69f9f2193bbcc", + id: "6762f15e1bb69f9f2193bbbd", external_id: "70", }, ], @@ -7889,7 +8784,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -7911,21 +8806,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "140", - part_type: "assign_and_reopen", + id: "134", + part_type: "quick_reply", body: "

Okay!

", - created_at: 1734537605, - updated_at: 1734537605, - notified_at: 1734537605, - assigned_to: { - type: "admin", - id: "991267715", - }, + created_at: 1734537568, + updated_at: 1734537568, + notified_at: 1734537568, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", + id: "991267698", + name: "Ciaran214 Lee", + email: "admin214@email.com", from_ai_agent: true, is_ai_answer: false, }, @@ -7946,6 +8839,11 @@ describe("ConversationsClient", () => { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, @@ -7960,6 +8858,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -7982,10 +8889,79 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); - test("manageConversation (5)", async () => { + test("replyConversation (4)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -7993,22 +8969,27 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "12345" }; + const rawRequestBody = { + message_type: "comment", + type: "user", + body: "body", + reply_options: [{ text: "Yes", uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" }], + intercom_user_id: "6762f1621bb69f9f2193bbbe", + }; const rawResponseBody = { type: "conversation", - id: "531", + id: "524", title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, + created_at: 1734537559, + updated_at: 1734537561, + waiting_since: 1734537561, snoozed_until: 1663597260, - open: false, - state: "closed", + open: true, + state: "open", read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -8031,7 +9012,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -8062,18 +9043,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918356", + id: "403918349", delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267694", name: "Ciaran212 Lee", email: "admin212@email.com" }, attachments: [ { type: "upload", @@ -8085,17 +9061,23 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f16e1bb69f9f2193bbc2", external_id: "70" }], + contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], }, teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, custom_attributes: { key: "value" }, first_contact_reply: { - created_at: 1663597223, + created_at: 1734537561, type: "conversation", url: "https://developers.intercom.com/", }, @@ -8120,9 +9102,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -8134,17 +9114,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, + id: "132", + part_type: "open", + body: "

Thanks again :)

", + created_at: 1734537561, + updated_at: 1734537561, + notified_at: 1734537561, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", + type: "user", + id: "6762f1571bb69f9f2193bbbb", + name: "Joe Bloggs", + email: "joe@bloggs.com", from_ai_agent: true, is_ai_answer: false, }, @@ -8163,11 +9145,13 @@ describe("ConversationsClient", () => { redacted: false, metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -8190,39 +9174,91 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/conversations/123/parts") + .post("/conversations/123%20or%20%22last%22/reply") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.manageConversation({ - id: "123", + const response = await client.preview.conversations.replyConversation({ + id: '123 or "last"', body: { - message_type: "close", - type: "admin", - admin_id: "12345", + message_type: "comment", + type: "user", + body: "body", + reply_options: [ + { + text: "Yes", + uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb", + }, + ], + intercom_user_id: "6762f1621bb69f9f2193bbbe", }, }); expect(response).toEqual({ type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, + id: "524", + title: "Conversation Title", + created_at: 1734537559, + updated_at: 1734537561, + waiting_since: 1734537561, snoozed_until: 1663597260, - open: false, - state: "closed", + open: true, + state: "open", read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -8251,6 +9287,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -8304,17 +9347,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918356", + id: "403918349", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "991267694", + name: "Ciaran212 Lee", + email: "admin212@email.com", }, attachments: [ { @@ -8327,15 +9380,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { type: "contact", - id: "6762f16e1bb69f9f2193bbc2", + id: "6762f1571bb69f9f2193bbbb", external_id: "70", }, ], @@ -8353,7 +9418,7 @@ describe("ConversationsClient", () => { key: "value", }, first_contact_reply: { - created_at: 1663597223, + created_at: 1734537561, type: "conversation", url: "https://developers.intercom.com/", }, @@ -8382,7 +9447,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -8404,17 +9469,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, + id: "132", + part_type: "open", + body: "

Thanks again :)

", + created_at: 1734537561, + updated_at: 1734537561, + notified_at: 1734537561, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", + type: "user", + id: "6762f1571bb69f9f2193bbbb", + name: "Joe Bloggs", + email: "joe@bloggs.com", from_ai_agent: true, is_ai_answer: false, }, @@ -8435,6 +9502,11 @@ describe("ConversationsClient", () => { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, @@ -8449,6 +9521,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -8471,103 +9552,79 @@ describe("ConversationsClient", () => { ], }, }, - }); - }); - - test("manageConversation (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.manageConversation({ - id: "id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("manageConversation (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.manageConversation({ - id: "id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", }, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("manageConversation (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.manageConversation({ - id: "id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], + }); }); - test("attachContactToConversation (1)", async () => { + test("replyConversation (5)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -8575,22 +9632,26 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19b1bb69f9f2193bbd4" } }; + const rawRequestBody = { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f1661bb69f9f2193bbbf", + }; const rawResponseBody = { type: "conversation", - id: "1295", + id: "527", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, + created_at: 1734537571, + updated_at: 1734537572, + waiting_since: 1734537572, snoozed_until: 1663597260, open: true, state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -8613,7 +9674,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -8644,18 +9705,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918352", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, + body: "

this is the message body

", + author: { type: "admin", id: "991267700", name: "Ciaran215 Lee", email: "admin215@email.com" }, attachments: [ { type: "upload", @@ -8667,20 +9723,23 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f1621bb69f9f2193bbbe", external_id: "70" }], }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { key: "value" }, first_contact_reply: { - created_at: 1663597223, + created_at: 1734537572, type: "conversation", url: "https://developers.intercom.com/", }, @@ -8705,9 +9764,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -8719,21 +9776,45 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + id: "135", + part_type: "open", + body: "

Thanks again :)

", + created_at: 1734537572, + updated_at: 1734537572, + notified_at: 1734537572, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "user", + id: "6762f1621bb69f9f2193bbbe", + name: "Joe Bloggs", + email: "joe@bloggs.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -8755,38 +9836,85 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/conversations/123/customers") + .post("/conversations/123%20or%20%22last%22/reply") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.attachContactToConversation({ - id: "123", - admin_id: "12345", - customer: { - intercom_user_id: "6762f19b1bb69f9f2193bbd4", + const response = await client.preview.conversations.replyConversation({ + id: '123 or "last"', + body: { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f1661bb69f9f2193bbbf", }, }); expect(response).toEqual({ type: "conversation", - id: "1295", + id: "527", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, + created_at: 1734537571, + updated_at: 1734537572, + waiting_since: 1734537572, snoozed_until: 1663597260, open: true, state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -8815,6 +9943,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -8868,17 +10003,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918352", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", - body: "

Hey there!

", + body: "

this is the message body

", author: { type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, + id: "991267700", + name: "Ciaran215 Lee", + email: "admin215@email.com", }, attachments: [ { @@ -8891,14 +10036,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { - id: "5ba682d23d7cf92bef87bfd4", + type: "contact", + id: "6762f1621bb69f9f2193bbbe", external_id: "70", }, ], @@ -8913,17 +10071,10 @@ describe("ConversationsClient", () => { ], }, custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + key: "value", }, first_contact_reply: { - created_at: 1663597223, + created_at: 1734537572, type: "conversation", url: "https://developers.intercom.com/", }, @@ -8952,7 +10103,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -8974,22 +10125,51 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + id: "135", + part_type: "open", + body: "

Thanks again :)

", + created_at: 1734537572, + updated_at: 1734537572, + notified_at: 1734537572, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "user", + id: "6762f1621bb69f9f2193bbbe", + name: "Joe Bloggs", + email: "joe@bloggs.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, }, linked_objects: { type: "list", - total_count: 100, + total_count: 0, has_more: false, data: [ { @@ -8997,7 +10177,16 @@ describe("ConversationsClient", () => { }, ], }, - ai_agent_participated: true, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -9019,10 +10208,190 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], + }); + }); + + test("replyConversation (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, }); + const rawRequestBody = { + intercom_user_id: "intercom_user_id", + message_type: "comment", + type: "user", + body: "body", + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/id/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.replyConversation({ + id: "id", + body: { + intercom_user_id: "intercom_user_id", + message_type: "comment", + type: "user", + body: "body", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("replyConversation (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + intercom_user_id: "intercom_user_id", + message_type: "comment", + type: "user", + body: "body", + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/id/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.replyConversation({ + id: "id", + body: { + intercom_user_id: "intercom_user_id", + message_type: "comment", + type: "user", + body: "body", + }, + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("replyConversation (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + intercom_user_id: "intercom_user_id", + message_type: "comment", + type: "user", + body: "body", + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/conversations/id/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.replyConversation({ + id: "id", + body: { + intercom_user_id: "intercom_user_id", + message_type: "comment", + type: "user", + body: "body", + }, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); - test("attachContactToConversation (2)", async () => { + test("manageConversation (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -9030,22 +10399,21 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19e1bb69f9f2193bbd5" } }; + const rawRequestBody = { message_type: "close", type: "admin", admin_id: "12345" }; const rawResponseBody = { type: "conversation", - id: "1295", + id: "531", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + created_at: 1734537582, + updated_at: 1734537584, waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -9068,7 +10436,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -9099,18 +10467,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918356", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, + body: "

this is the message body

", + author: { type: "admin", id: "991267708", name: "Ciaran219 Lee", email: "admin219@email.com" }, attachments: [ { type: "upload", @@ -9122,18 +10485,21 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f16e1bb69f9f2193bbc2", external_id: "70" }], }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { key: "value" }, first_contact_reply: { created_at: 1663597223, type: "conversation", @@ -9160,9 +10526,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -9174,21 +10538,45 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + id: "136", + part_type: "close", + body: "

Goodbye :)

", + created_at: 1734537584, + updated_at: 1734537584, + notified_at: 1734537584, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267708", + name: "Ciaran219 Lee", + email: "admin219@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -9210,38 +10598,84 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/conversations/123/customers") + .post("/conversations/123/parts") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.attachContactToConversation({ + const response = await client.preview.conversations.manageConversation({ id: "123", - admin_id: "12345", - customer: { - intercom_user_id: "6762f19e1bb69f9f2193bbd5", + body: { + message_type: "close", + type: "admin", + admin_id: "12345", }, }); expect(response).toEqual({ type: "conversation", - id: "1295", + id: "531", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + created_at: 1734537582, + updated_at: 1734537584, waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -9270,6 +10704,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -9323,17 +10764,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918356", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", - body: "

Hey there!

", + body: "

this is the message body

", author: { type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, + id: "991267708", + name: "Ciaran219 Lee", + email: "admin219@email.com", }, attachments: [ { @@ -9346,14 +10797,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { - id: "5ba682d23d7cf92bef87bfd4", + type: "contact", + id: "6762f16e1bb69f9f2193bbc2", external_id: "70", }, ], @@ -9368,14 +10832,7 @@ describe("ConversationsClient", () => { ], }, custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + key: "value", }, first_contact_reply: { created_at: 1663597223, @@ -9407,7 +10864,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -9429,22 +10886,51 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + id: "136", + part_type: "close", + body: "

Goodbye :)

", + created_at: 1734537584, + updated_at: 1734537584, + notified_at: 1734537584, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267708", + name: "Ciaran219 Lee", + email: "admin219@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, }, linked_objects: { type: "list", - total_count: 100, + total_count: 0, has_more: false, data: [ { @@ -9452,7 +10938,16 @@ describe("ConversationsClient", () => { }, ], }, - ai_agent_participated: true, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -9474,88 +10969,79 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); - test("attachContactToConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.attachContactToConversation({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("attachContactToConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.attachContactToConversation({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("attachContactToConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.attachContactToConversation({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachContactFromConversation (1)", async () => { + test("manageConversation (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -9563,22 +11049,21 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { admin_id: "5017690" }; + const rawRequestBody = { message_type: "snoozed", admin_id: "5017691", snoozed_until: 1673609604 }; const rawResponseBody = { type: "conversation", - id: "1295", + id: "532", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + created_at: 1734537586, + updated_at: 1734537587, waiting_since: 1663597260, - snoozed_until: 1663597260, + snoozed_until: 1734541187, open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + state: "snoozed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -9601,7 +11086,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -9632,18 +11117,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918357", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, + body: "

this is the message body

", + author: { type: "admin", id: "991267710", name: "Ciaran220 Lee", email: "admin220@email.com" }, attachments: [ { type: "upload", @@ -9655,18 +11135,21 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f1711bb69f9f2193bbc3", external_id: "70" }], }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { key: "value" }, first_contact_reply: { created_at: 1663597223, type: "conversation", @@ -9693,9 +11176,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -9707,21 +11188,45 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", + id: "137", + part_type: "snoozed", body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + created_at: 1734537587, + updated_at: 1734537587, + notified_at: 1734537587, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267710", + name: "Ciaran220 Lee", + email: "admin220@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -9743,36 +11248,84 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .delete("/conversations/123/customers/123") + .post("/conversations/123/parts") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", + const response = await client.preview.conversations.manageConversation({ + id: "123", + body: { + message_type: "snoozed", + admin_id: "5017691", + snoozed_until: 1673609604, + }, }); expect(response).toEqual({ type: "conversation", - id: "1295", + id: "532", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + created_at: 1734537586, + updated_at: 1734537587, waiting_since: 1663597260, - snoozed_until: 1663597260, + snoozed_until: 1734541187, open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + state: "snoozed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -9801,6 +11354,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -9854,17 +11414,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918357", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", - body: "

Hey there!

", + body: "

this is the message body

", author: { type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, + id: "991267710", + name: "Ciaran220 Lee", + email: "admin220@email.com", }, attachments: [ { @@ -9877,14 +11447,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { - id: "5ba682d23d7cf92bef87bfd4", + type: "contact", + id: "6762f1711bb69f9f2193bbc3", external_id: "70", }, ], @@ -9899,14 +11482,7 @@ describe("ConversationsClient", () => { ], }, custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + key: "value", }, first_contact_reply: { created_at: 1663597223, @@ -9938,7 +11514,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -9960,22 +11536,51 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", + id: "137", + part_type: "snoozed", body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + created_at: 1734537587, + updated_at: 1734537587, + notified_at: 1734537587, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267710", + name: "Ciaran220 Lee", + email: "admin220@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, }, linked_objects: { type: "list", - total_count: 100, + total_count: 0, has_more: false, data: [ { @@ -9983,7 +11588,16 @@ describe("ConversationsClient", () => { }, ], }, - ai_agent_participated: true, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -10005,10 +11619,79 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); - test("detachContactFromConversation (2)", async () => { + test("manageConversation (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -10016,22 +11699,21 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { admin_id: "5017690" }; + const rawRequestBody = { message_type: "open", admin_id: "5017690" }; const rawResponseBody = { type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + id: "537", + title: "", + created_at: 1734537587, + updated_at: 1734537601, waiting_since: 1663597260, snoozed_until: 1663597260, open: true, state: "open", read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -10054,7 +11736,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -10085,18 +11767,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918358", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, + body: "

this is the message body

", + author: { type: "admin", id: "991267712", name: "Ciaran221 Lee", email: "admin221@email.com" }, attachments: [ { type: "upload", @@ -10108,18 +11785,21 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f1781bb69f9f2193bbc8", external_id: "74" }], }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { key: "value" }, first_contact_reply: { created_at: 1663597223, type: "conversation", @@ -10146,9 +11826,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -10160,21 +11838,45 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", + id: "139", + part_type: "open", body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + created_at: 1734537601, + updated_at: 1734537601, + notified_at: 1734537601, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267712", + name: "Ciaran221 Lee", + email: "admin221@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -10196,36 +11898,83 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .delete("/conversations/123/customers/123") + .post("/conversations/123/parts") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", + const response = await client.preview.conversations.manageConversation({ + id: "123", + body: { + message_type: "open", + admin_id: "5017690", + }, }); expect(response).toEqual({ type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + id: "537", + title: "", + created_at: 1734537587, + updated_at: 1734537601, waiting_since: 1663597260, snoozed_until: 1663597260, open: true, state: "open", read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -10254,6 +12003,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -10307,17 +12063,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918358", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", - body: "

Hey there!

", + body: "

this is the message body

", author: { type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, + id: "991267712", + name: "Ciaran221 Lee", + email: "admin221@email.com", }, attachments: [ { @@ -10330,15 +12096,28 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", + type: "contact", + id: "6762f1781bb69f9f2193bbc8", + external_id: "74", }, ], }, @@ -10352,14 +12131,7 @@ describe("ConversationsClient", () => { ], }, custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + key: "value", }, first_contact_reply: { created_at: 1663597223, @@ -10391,7 +12163,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -10413,22 +12185,51 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", + id: "139", + part_type: "open", body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + created_at: 1734537601, + updated_at: 1734537601, + notified_at: 1734537601, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267712", + name: "Ciaran221 Lee", + email: "admin221@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, }, linked_objects: { type: "list", - total_count: 100, + total_count: 0, has_more: false, data: [ { @@ -10436,7 +12237,16 @@ describe("ConversationsClient", () => { }, ], }, - ai_agent_participated: true, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -10458,237 +12268,107 @@ describe("ConversationsClient", () => { ], }, }, - }); - }); - - test("detachContactFromConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", }, }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, + channel: { + initial: "messenger", + current: "messenger", }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

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

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", }, ], }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); + ], + }); + }); - const response = await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", + test("manageConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, }); - expect(response).toEqual({ + const rawRequestBody = { message_type: "assignment", type: "admin", admin_id: "12345", assignee_id: "4324241" }; + const rawResponseBody = { type: "conversation", - id: "1295", + id: "542", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + created_at: 1734537603, + updated_at: 1734537605, waiting_since: 1663597260, snoozed_until: 1663597260, open: true, state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", name: "Blue Sun", app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, + plan: { type: "plan", id: "269315", name: "Pro" }, company_id: "6", remote_created_at: 1663597223, created_at: 1663597223, @@ -10705,9 +12385,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { - type: "tag.list", - }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -10723,55 +12401,28 @@ describe("ConversationsClient", () => { notes: { type: "note.list", notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, + { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, ], }, }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, + contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, + teammate: { type: "contact", id: "1a2b3c" }, }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918361", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, + body: "

this is the message body

", + author: { type: "admin", id: "991267715", name: "Ciaran223 Lee", email: "admin223@email.com" }, attachments: [ { type: "upload", @@ -10783,47 +12434,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + contacts: [{ type: "contact", id: "6762f1831bb69f9f2193bbcc", external_id: "70" }], }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { key: "value" }, first_contact_reply: { created_at: 1663597223, type: "conversation", url: "https://developers.intercom.com/", }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, + sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, statistics: { type: "conversation_statistics", time_to_assignment: 2310, @@ -10844,19 +12475,9 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, + { team_id: 100, team_name: "Team One", response_time: 2310 }, ], handling_time: 2310, adjusted_handling_time: 1800, @@ -10866,30 +12487,46 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", + id: "140", + part_type: "assign_and_reopen", body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + created_at: 1734537605, + updated_at: 1734537605, + notified_at: 1734537605, + assigned_to: { type: "admin", id: "991267715" }, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267715", + name: "Ciaran223 Lee", + email: "admin223@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -10911,39 +12548,95 @@ describe("ConversationsClient", () => { ], }, }, - }); - }); + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], + }; + server + .mockEndpoint() + .post("/conversations/123/parts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); - test("detachContactFromConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, + const response = await client.preview.conversations.manageConversation({ + id: "123", + body: { + message_type: "assignment", + type: "admin", + admin_id: "12345", + assignee_id: "4324241", + }, }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { + expect(response).toEqual({ type: "conversation", - id: "1295", + id: "542", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + created_at: 1734537603, + updated_at: 1734537605, waiting_since: 1663597260, snoozed_until: 1663597260, open: true, state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", name: "Blue Sun", app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, company_id: "6", remote_created_at: 1663597223, created_at: 1663597223, @@ -10960,7 +12653,16 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + }, segments: { type: "segment.list", segments: [ @@ -10976,32 +12678,64 @@ describe("ConversationsClient", () => { notes: { type: "note.list", notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, + { + type: "note", + id: "17495962", + created_at: 1674589321, + body: "

Text for the note.

", + }, ], }, }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, + contact: { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + }, + teammate: { + type: "contact", + id: "1a2b3c", + }, }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918361", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", - body: "

Hey there!

", + body: "

this is the message body

", author: { type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, + id: "991267715", + name: "Ciaran223 Lee", + email: "admin223@email.com", }, attachments: [ { @@ -11014,24 +12748,53 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f1831bb69f9f2193bbcc", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + teammates: [ + { + type: "contact", + id: "1a2b3c", + }, + ], }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, + key: "value", }, first_contact_reply: { created_at: 1663597223, type: "conversation", url: "https://developers.intercom.com/", }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + sla_status: "hit", + }, statistics: { type: "conversation_statistics", time_to_assignment: 2310, @@ -11052,11 +12815,19 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, + assigned_team_first_response_time: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, ], assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, ], handling_time: 2310, adjusted_handling_time: 1800, @@ -11066,21 +12837,72 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", + id: "140", + part_type: "assign_and_reopen", body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + created_at: 1734537605, + updated_at: 1734537605, + notified_at: 1734537605, + assigned_to: { + type: "admin", + id: "991267715", + }, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267715", + name: "Ciaran223 Lee", + email: "admin223@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -11102,46 +12924,107 @@ describe("ConversationsClient", () => { ], }, }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], + }); + }); - const response = await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", + test("manageConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, }); - expect(response).toEqual({ + const rawRequestBody = { message_type: "close", type: "admin", admin_id: "12345" }; + const rawResponseBody = { type: "conversation", - id: "1295", + id: "531", title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, + created_at: 1734537582, + updated_at: 1734537584, waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", name: "Blue Sun", app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, + plan: { type: "plan", id: "269315", name: "Pro" }, company_id: "6", remote_created_at: 1663597223, created_at: 1663597223, @@ -11158,9 +13041,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { - type: "tag.list", - }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -11176,55 +13057,28 @@ describe("ConversationsClient", () => { notes: { type: "note.list", notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, + { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, ], }, }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, + contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, + teammate: { type: "contact", id: "1a2b3c" }, }, source: { type: "conversation", - id: "3", - delivered_as: "operator_initiated", + id: "403918356", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, + body: "

this is the message body

", + author: { type: "admin", id: "991267708", name: "Ciaran219 Lee", email: "admin219@email.com" }, attachments: [ { type: "upload", @@ -11236,47 +13090,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, }, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f16e1bb69f9f2193bbc2", external_id: "70" }], + }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { key: "value" }, first_contact_reply: { created_at: 1663597223, type: "conversation", url: "https://developers.intercom.com/", }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, + sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, statistics: { type: "conversation_statistics", time_to_assignment: 2310, @@ -11297,19 +13131,9 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, + { team_id: 100, team_name: "Team One", response_time: 2310 }, ], handling_time: 2310, adjusted_handling_time: 1800, @@ -11319,30 +13143,45 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, + id: "136", + part_type: "close", + body: "

Goodbye :)

", + created_at: 1734537584, + updated_at: 1734537584, + notified_at: 1734537584, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991267708", + name: "Ciaran219 Lee", + email: "admin219@email.com", + from_ai_agent: true, + is_ai_answer: false, + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], external_id: "abcd1234", redacted: false, + metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", source_title: "My AI Workflow", @@ -11359,274 +13198,99 @@ describe("ConversationsClient", () => { { url: "/fin-ai-agent/content?content=content_snippet&id=3234924", title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactFromConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("detachContactFromConversation (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("detachContactFromConversation (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachContactFromConversation (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("listHandlingEvents (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - handling_events: [ - { - teammate: { type: "admin", id: 123, name: "Jane Example", email: "jane@example.com" }, - type: "paused", - timestamp: "2026-01-09T09:00:00Z", - reason: "Paused", - }, - { - teammate: { type: "admin", id: 123, name: "Jane Example", email: "jane@example.com" }, - type: "resumed", - timestamp: "2026-01-09T09:10:00Z", - reason: "Paused", - }, - ], - }; - server - .mockEndpoint() - .get("/conversations/123/handling_events") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.listHandlingEvents({ - id: "123", - }); - expect(response).toEqual({ - handling_events: [ - { - teammate: { - type: "admin", - id: 123, - name: "Jane Example", - email: "jane@example.com", - }, - type: "paused", - timestamp: "2026-01-09T09:00:00Z", - reason: "Paused", - }, - { - teammate: { - type: "admin", - id: 123, - name: "Jane Example", - email: "jane@example.com", - }, - type: "resumed", - timestamp: "2026-01-09T09:10:00Z", - reason: "Paused", - }, - ], - }); - }); - - test("listHandlingEvents (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/conversations/id/handling_events") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.listHandlingEvents({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listHandlingEvents (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], + }; server .mockEndpoint() - .get("/conversations/id/handling_events") + .post("/conversations/123/parts") + .jsonBody(rawRequestBody) .respondWith() - .statusCode(404) + .statusCode(200) .jsonBody(rawResponseBody) .build(); - await expect(async () => { - return await client.unstable.conversations.listHandlingEvents({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("redactConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, + const response = await client.preview.conversations.manageConversation({ + id: "123", + body: { + message_type: "close", + type: "admin", + admin_id: "12345", + }, }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "19894788788", - conversation_part_id: "19381789428", - }; - const rawResponseBody = { + expect(response).toEqual({ type: "conversation", - id: "608", + id: "531", title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, + created_at: 1734537582, + updated_at: 1734537584, + waiting_since: 1663597260, snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + open: false, + state: "closed", + read: false, + priority: "none", + admin_assignee_id: 991267715, + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", name: "Blue Sun", app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, company_id: "6", remote_created_at: 1663597223, created_at: 1663597223, @@ -11643,7 +13307,16 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + }, segments: { type: "segment.list", segments: [ @@ -11659,32 +13332,64 @@ describe("ConversationsClient", () => { notes: { type: "note.list", notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, + { + type: "note", + id: "17495962", + created_at: 1674589321, + body: "

Text for the note.

", + }, ], }, }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, + contact: { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + }, + teammate: { + type: "contact", + id: "1a2b3c", + }, }, source: { type: "conversation", - id: "403918391", + id: "403918356", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "991267708", + name: "Ciaran219 Lee", + email: "admin219@email.com", }, attachments: [ { @@ -11697,21 +13402,53 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f1f81bb69f9f2193bc09", external_id: "70" }], + contacts: [ + { + type: "contact", + id: "6762f16e1bb69f9f2193bbc2", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + teammates: [ + { + type: "contact", + id: "1a2b3c", + }, + ], + }, + custom_attributes: { + key: "value", }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, first_contact_reply: { - created_at: 1734537722, + created_at: 1663597223, type: "conversation", url: "https://developers.intercom.com/", }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + sla_status: "hit", + }, statistics: { type: "conversation_statistics", time_to_assignment: 2310, @@ -11732,11 +13469,19 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, + assigned_team_first_response_time: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, ], assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, ], handling_time: 2310, adjusted_handling_time: 1800, @@ -11746,17 +13491,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, + id: "136", + part_type: "close", + body: "

Goodbye :)

", + created_at: 1734537584, + updated_at: 1734537584, + notified_at: 1734537584, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", + type: "admin", + id: "991267708", + name: "Ciaran219 Lee", + email: "admin219@email.com", from_ai_agent: true, is_ai_answer: false, }, @@ -11772,14 +13519,39 @@ describe("ConversationsClient", () => { }, ], external_id: "abcd1234", - redacted: true, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, + redacted: false, + metadata: { + quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -11801,289 +13573,800 @@ describe("ConversationsClient", () => { }, ], }, - }, - }; + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], + }); + }); + + test("manageConversation (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/id/parts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.manageConversation({ + id: "id", + body: { + message_type: "close", + type: "admin", + admin_id: "admin_id", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("manageConversation (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/id/parts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.manageConversation({ + id: "id", + body: { + message_type: "close", + type: "admin", + admin_id: "admin_id", + }, + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("manageConversation (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; + const rawResponseBody = { key: "value" }; server .mockEndpoint() - .post("/conversations/redact") + .post("/conversations/id/parts") .jsonBody(rawRequestBody) .respondWith() - .statusCode(200) + .statusCode(404) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "19894788788", - conversation_part_id: "19381789428", + await expect(async () => { + return await client.preview.conversations.manageConversation({ + id: "id", + body: { + message_type: "close", + type: "admin", + admin_id: "admin_id", + }, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listHandlingEvents (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, }); - expect(response).toEqual({ - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", + + const rawResponseBody = { + handling_events: [ + { + teammate: { type: "admin", id: 123, name: "Jane Example", email: "jane@example.com" }, + type: "paused", + timestamp: "2026-01-09T09:00:00Z", + reason: "Paused", }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", + { + teammate: { type: "admin", id: 123, name: "Jane Example", email: "jane@example.com" }, + type: "resumed", + timestamp: "2026-01-09T09:10:00Z", + reason: "Paused", }, - tags: { - type: "tag.list", + ], + }; + server + .mockEndpoint() + .get("/conversations/123/handling_events") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversations.listHandlingEvents({ + id: "123", + }); + expect(response).toEqual({ + handling_events: [ + { + teammate: { + type: "admin", + id: 123, + name: "Jane Example", + email: "jane@example.com", + }, + type: "paused", + timestamp: "2026-01-09T09:00:00Z", + reason: "Paused", }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], + { + teammate: { + type: "admin", + id: 123, + name: "Jane Example", + email: "jane@example.com", + }, + type: "resumed", + timestamp: "2026-01-09T09:10:00Z", + reason: "Paused", }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], + ], + }); + }); + + test("listHandlingEvents (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/conversations/id/handling_events") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.listHandlingEvents({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listHandlingEvents (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/conversations/id/handling_events") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.listHandlingEvents({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listHitlEvents (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_consultation_started", + conversation_part_id: "4471002", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225600, + data: { + channel: "email", + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, + }, }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_draft_proposed", + conversation_part_id: "4471008", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225600, + data: { + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", }, - teammate: { - type: "contact", - id: "1a2b3c", + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_teammate_input_received", + conversation_part_id: "4471002", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225701, + data: { + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, + }, }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_draft_revised", + conversation_part_id: "4471002", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225760, + data: { + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, + }, }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_consultation_finished", + conversation_part_id: "4471029", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225780, + data: { + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + outcome: "approved", + approved_draft_type: "revised", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1f81bb69f9f2193bc09", - external_id: "70", + }, + ], + }; + server + .mockEndpoint() + .get("/conversations/123/hitl_events") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversations.listHitlEvents({ + id: "123", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_consultation_started", + conversation_part_id: "4471002", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225600, + data: { + channel: "email", + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", + }, + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_draft_proposed", + conversation_part_id: "4471008", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225600, + data: { + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, + }, + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_teammate_input_received", + conversation_part_id: "4471002", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225701, + data: { + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, + }, + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_draft_revised", + conversation_part_id: "4471002", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225760, + data: { + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, + }, + { + hitl_cycle_id: "3f2a91c4-8e77-4d61-9a2b-0c5d7e1f4a80", + event_type: "fin_consultation_finished", + conversation_part_id: "4471029", + rule_id: "88", + rule_name: "Refunds over $100", + created_at: 1767225780, + data: { + rule_threshold_percent: 60, + confidence_percent: 42, + sharp_ask: "How long do refunds take?", + ask_rationale: "No article covers refund timelines.", + issue_summary: "Customer chasing a refund.", + customer_question: "Where is my refund?", + draft: "Refunds are processed within 30 days.", + round_index: 1, + teammate_input: "Tell them 5 business days.", + reviewer_admin_id: "4001", + regeneration_outcome: "answer", + revised_draft: "Refunds take 5 business days.", + outcome: "approved", + approved_draft_type: "revised", + final_draft: "Refunds take 5 business days.", + sent_text: "Refunds take 5 business days.", + duration_seconds: 180, + rounds_count: 1, + payload_truncated: false, + }, + }, + ], + }); + }); + + test("listHitlEvents (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/conversations/id/hitl_events") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.listHitlEvents({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listHitlEvents (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/conversations/id/hitl_events") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.listHitlEvents({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listSideConversations (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "side_conversation.list", + side_conversations: [ + { + side_conversation_id: "456", + conversation_parts: [ + { + type: "conversation_part", + id: "789", + part_type: "comment", + body: "

Internal note about this issue

", + created_at: 1663597223, + updated_at: 1663597223, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "123", + name: "Jane Example", + email: "jane@example.com", + from_ai_agent: true, + is_ai_answer: false, }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", + external_id: "abcd1234", + redacted: false, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", + ], total_count: 1, - content_sources: [ + }, + ], + total_count: 1, + pages: { type: "pages", page: 1, per_page: 25, total_pages: 1 }, + }; + server + .mockEndpoint() + .get("/conversations/123/side_conversations") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversations.listSideConversations({ + id: "123", + page: 1, + per_page: 1, + }); + expect(response).toEqual({ + type: "side_conversation.list", + side_conversations: [ + { + side_conversation_id: "456", + conversation_parts: [ { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", + type: "conversation_part", + id: "789", + part_type: "comment", + body: "

Internal note about this issue

", + created_at: 1663597223, + updated_at: 1663597223, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "123", + name: "Jane Example", + email: "jane@example.com", + from_ai_agent: true, + is_ai_answer: false, + }, + external_id: "abcd1234", + redacted: false, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], + total_count: 1, }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + per_page: 25, + total_pages: 1, }, }); }); - test("redactConversation (2)", async () => { + test("listSideConversations (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/conversations/id/side_conversations") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.listSideConversations({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listSideConversations (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/conversations/id/side_conversations") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.listSideConversations({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("mergeConversation (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -12091,26 +14374,21 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "really_123_doesnt_exist", - conversation_part_id: "really_123_doesnt_exist", - }; + const rawRequestBody = { merge_into_conversation_id: 456 }; const rawResponseBody = { type: "conversation", - id: "608", + id: "456", title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, + created_at: 1734537559, + updated_at: 1734537561, + waiting_since: 1734537561, snoozed_until: 1663597260, open: true, state: "open", - read: true, - priority: "not_priority", + read: false, + priority: "none", admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -12133,7 +14411,7 @@ describe("ConversationsClient", () => { monthly_spend: "custom_attributes", team_mates: "custom_attributes", }, - tags: { type: "tag.list" }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, segments: { type: "segment.list", segments: [ @@ -12164,18 +14442,13 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918391", + id: "403918349", delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], subject: "", body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, + author: { type: "admin", id: "991267694", name: "Ciaran212 Lee", email: "admin212@email.com" }, attachments: [ { type: "upload", @@ -12187,17 +14460,23 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", - contacts: [{ type: "contact", id: "6762f1f81bb69f9f2193bc09", external_id: "70" }], + contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], }, teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, custom_attributes: { key: "value" }, first_contact_reply: { - created_at: 1734537722, + created_at: 1734537561, type: "conversation", url: "https://developers.intercom.com/", }, @@ -12222,9 +14501,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], assigned_team_first_response_time_in_office_hours: [ { team_id: 100, team_name: "Team One", response_time: 2310 }, ], @@ -12236,17 +14513,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, + id: "133", + part_type: "merged_primary_conversation", + body: "

Okay!

", + created_at: 1734537561, + updated_at: 1734537561, + notified_at: 1734537561, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", + type: "bot", + id: "991267694", + name: "Operator", + email: "operator@intercom.io", from_ai_agent: true, is_ai_answer: false, }, @@ -12262,14 +14541,16 @@ describe("ConversationsClient", () => { }, ], external_id: "abcd1234", - redacted: true, + redacted: false, metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -12292,36 +14573,80 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/conversations/redact") + .post("/conversations/123/merge") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "really_123_doesnt_exist", - conversation_part_id: "really_123_doesnt_exist", + const response = await client.preview.conversations.mergeConversation({ + id: "123", + merge_into_conversation_id: 456, }); expect(response).toEqual({ type: "conversation", - id: "608", + id: "456", title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, + created_at: 1734537559, + updated_at: 1734537561, + waiting_since: 1734537561, snoozed_until: 1663597260, open: true, state: "open", - read: true, - priority: "not_priority", + read: false, + priority: "none", admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + team_assignee_id: 5017691, company: { type: "company", id: "531ee472cce572a6ec000006", @@ -12350,6 +14675,13 @@ describe("ConversationsClient", () => { }, tags: { type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], }, segments: { type: "segment.list", @@ -12403,17 +14735,27 @@ describe("ConversationsClient", () => { }, source: { type: "conversation", - id: "403918391", + id: "403918349", delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], subject: "", body: "

this is the message body

", author: { type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, + id: "991267694", + name: "Ciaran212 Lee", + email: "admin212@email.com", }, attachments: [ { @@ -12426,15 +14768,27 @@ describe("ConversationsClient", () => { height: 100, }, ], - url: "url", + url: "https://intercom.help/company/article/123", redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, contacts: { type: "contact.list", contacts: [ { type: "contact", - id: "6762f1f81bb69f9f2193bc09", + id: "6762f1571bb69f9f2193bbbb", external_id: "70", }, ], @@ -12452,7 +14806,7 @@ describe("ConversationsClient", () => { key: "value", }, first_contact_reply: { - created_at: 1734537722, + created_at: 1734537561, type: "conversation", url: "https://developers.intercom.com/", }, @@ -12481,7 +14835,7 @@ describe("ConversationsClient", () => { count_reopens: 1, count_assignments: 1, count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ + assigned_team_first_response_time: [ { team_id: 100, team_name: "Team One", @@ -12503,17 +14857,19 @@ describe("ConversationsClient", () => { conversation_parts: [ { type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, + id: "133", + part_type: "merged_primary_conversation", + body: "

Okay!

", + created_at: 1734537561, + updated_at: 1734537561, + notified_at: 1734537561, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", + type: "bot", + id: "991267694", + name: "Operator", + email: "operator@intercom.io", from_ai_agent: true, is_ai_answer: false, }, @@ -12529,11 +14885,16 @@ describe("ConversationsClient", () => { }, ], external_id: "abcd1234", - redacted: true, + redacted: false, metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", }, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, @@ -12548,6 +14909,15 @@ describe("ConversationsClient", () => { }, ], }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, ai_agent_participated: false, ai_agent: { source_type: "essentials_plan_setup", @@ -12570,10 +14940,79 @@ describe("ConversationsClient", () => { ], }, }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], }); }); - test("redactConversation (3)", async () => { + test("mergeConversation (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -12581,15 +15020,38 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }; + const rawRequestBody = { merge_into_conversation_id: 1 }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/conversations/id/merge") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.mergeConversation({ + id: "id", + merge_into_conversation_id: 1, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("mergeConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { merge_into_conversation_id: 1 }; const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; server .mockEndpoint() - .post("/conversations/redact") + .post("/conversations/id/merge") .jsonBody(rawRequestBody) .respondWith() .statusCode(401) @@ -12597,15 +15059,14 @@ describe("ConversationsClient", () => { .build(); await expect(async () => { - return await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", + return await client.preview.conversations.mergeConversation({ + id: "id", + merge_into_conversation_id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); - test("redactConversation (4)", async () => { + test("mergeConversation (4)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -12613,28 +15074,50 @@ describe("ConversationsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }; + const rawRequestBody = { merge_into_conversation_id: 1 }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/id/merge") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.mergeConversation({ + id: "id", + merge_into_conversation_id: 1, + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("mergeConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { merge_into_conversation_id: 1 }; const rawResponseBody = { key: "value" }; server .mockEndpoint() - .post("/conversations/redact") + .post("/conversations/id/merge") .jsonBody(rawRequestBody) .respondWith() - .statusCode(404) + .statusCode(422) .jsonBody(rawResponseBody) .build(); await expect(async () => { - return await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", + return await client.preview.conversations.mergeConversation({ + id: "id", + merge_into_conversation_id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); }); test("convertConversationToTicket (1)", async () => { @@ -12677,8 +15160,8 @@ describe("ConversationsClient", () => { type: "contact.list", contacts: [{ type: "contact", id: "6762f2041bb69f9f2193bc0c", external_id: "70" }], }, - admin_assignee_id: "0", - team_assignee_id: "0", + admin_assignee_id: 0, + team_assignee_id: 0, created_at: 1734537732, updated_at: 1734537737, open: true, @@ -12694,6 +15177,8 @@ describe("ConversationsClient", () => { body: "

Comment for message

", created_at: 1734537732, updated_at: 1734537732, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "user", id: "6762f2041bb69f9f2193bc0c", @@ -12714,6 +15199,7 @@ describe("ConversationsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -12724,6 +15210,8 @@ describe("ConversationsClient", () => { ticket_state: "submitted", created_at: 1734537737, updated_at: 1734537737, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991267767", @@ -12744,11 +15232,13 @@ describe("ConversationsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 2, }, is_shared: true, + previous_ticket_state_id: "7490", }; server .mockEndpoint() @@ -12759,7 +15249,7 @@ describe("ConversationsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.convertConversationToTicket({ + const response = await client.preview.conversations.convertConversationToTicket({ id: 1, ticket_type_id: "53", }); @@ -12808,8 +15298,8 @@ describe("ConversationsClient", () => { }, ], }, - admin_assignee_id: "0", - team_assignee_id: "0", + admin_assignee_id: 0, + team_assignee_id: 0, created_at: 1734537732, updated_at: 1734537737, open: true, @@ -12834,6 +15324,8 @@ describe("ConversationsClient", () => { body: "

Comment for message

", created_at: 1734537732, updated_at: 1734537732, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "user", id: "6762f2041bb69f9f2193bc0c", @@ -12854,6 +15346,11 @@ describe("ConversationsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -12864,6 +15361,8 @@ describe("ConversationsClient", () => { ticket_state: "submitted", created_at: 1734537737, updated_at: 1734537737, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991267767", @@ -12884,11 +15383,17 @@ describe("ConversationsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 2, }, is_shared: true, + previous_ticket_state_id: "7490", }); }); @@ -12932,8 +15437,8 @@ describe("ConversationsClient", () => { type: "contact.list", contacts: [{ type: "contact", id: "6762f2041bb69f9f2193bc0c", external_id: "70" }], }, - admin_assignee_id: "0", - team_assignee_id: "0", + admin_assignee_id: 0, + team_assignee_id: 0, created_at: 1734537732, updated_at: 1734537737, open: true, @@ -12949,6 +15454,8 @@ describe("ConversationsClient", () => { body: "

Comment for message

", created_at: 1734537732, updated_at: 1734537732, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "user", id: "6762f2041bb69f9f2193bc0c", @@ -12969,6 +15476,7 @@ describe("ConversationsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -12979,6 +15487,8 @@ describe("ConversationsClient", () => { ticket_state: "submitted", created_at: 1734537737, updated_at: 1734537737, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991267767", @@ -12999,11 +15509,13 @@ describe("ConversationsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 2, }, is_shared: true, + previous_ticket_state_id: "7490", }; server .mockEndpoint() @@ -13014,7 +15526,7 @@ describe("ConversationsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.conversations.convertConversationToTicket({ + const response = await client.preview.conversations.convertConversationToTicket({ id: 1, ticket_type_id: "54", }); @@ -13063,8 +15575,8 @@ describe("ConversationsClient", () => { }, ], }, - admin_assignee_id: "0", - team_assignee_id: "0", + admin_assignee_id: 0, + team_assignee_id: 0, created_at: 1734537732, updated_at: 1734537737, open: true, @@ -13089,6 +15601,8 @@ describe("ConversationsClient", () => { body: "

Comment for message

", created_at: 1734537732, updated_at: 1734537732, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "user", id: "6762f2041bb69f9f2193bc0c", @@ -13109,6 +15623,11 @@ describe("ConversationsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -13119,6 +15638,8 @@ describe("ConversationsClient", () => { ticket_state: "submitted", created_at: 1734537737, updated_at: 1734537737, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991267767", @@ -13139,11 +15660,17 @@ describe("ConversationsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 2, }, is_shared: true, + previous_ticket_state_id: "7490", }); }); @@ -13167,10 +15694,120 @@ describe("ConversationsClient", () => { .build(); await expect(async () => { - return await client.unstable.conversations.convertConversationToTicket({ + return await client.preview.conversations.convertConversationToTicket({ id: 1, ticket_type_id: "ticket_type_id", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("listDeletedConversationIds (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "conversations.list", + conversations: [ + { type: "conversation", id: "512", metrics_retained: false, deleted_at: 1734537460 }, + { type: "conversation", id: "513", metrics_retained: true, deleted_at: 1734537400 }, + ], + total_count: 4, + pages: { + type: "pages", + page: 1, + next: "https://api.intercom.io/conversations/deleted?per_page=2&order=desc&page=2", + per_page: 2, + total_pages: 2, + }, + }; + server + .mockEndpoint() + .get("/conversations/deleted") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversations.listDeletedConversationIds({ + page: 1, + per_page: 1, + order: "desc", + }); + expect(response).toEqual({ + type: "conversations.list", + conversations: [ + { + type: "conversation", + id: "512", + metrics_retained: false, + deleted_at: 1734537460, + }, + { + type: "conversation", + id: "513", + metrics_retained: true, + deleted_at: 1734537400, + }, + ], + total_count: 4, + pages: { + type: "pages", + page: 1, + next: "https://api.intercom.io/conversations/deleted?per_page=2&order=desc&page=2", + per_page: 2, + total_pages: 2, + }, + }); + }); + + test("listDeletedConversationIds (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/conversations/deleted") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.listDeletedConversationIds(); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("listDeletedConversationIds (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/conversations/deleted") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversations.listDeletedConversationIds(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/preview/conversationsAttributes.test.ts b/tests/wire/preview/conversationsAttributes.test.ts new file mode 100644 index 00000000..50897bb1 --- /dev/null +++ b/tests/wire/preview/conversationsAttributes.test.ts @@ -0,0 +1,990 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ConversationsAttributesClient", () => { + test("listConversationAttributes (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }, + { + data_type: "list", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + options: [{ id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", label: "High", archived: false }], + }, + { + data_type: "relationship", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + reference: { object_type_id: "Test_Object" }, + }, + ], + }; + server + .mockEndpoint() + .get("/conversations/attributes") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationsAttributes.listConversationAttributes({ + include_archived: true, + }); + expect(response).toEqual({ + type: "list", + data: [ + { + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }, + { + data_type: "list", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + options: [ + { + id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + label: "High", + archived: false, + }, + ], + }, + { + data_type: "relationship", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + reference: { + object_type_id: "Test_Object", + }, + }, + ], + }); + }); + + test("listConversationAttributes (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/conversations/attributes") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.listConversationAttributes(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createConversationAttribute (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { data_type: "string", name: "api_test_attr" }; + const rawResponseBody = { + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }; + server + .mockEndpoint() + .post("/conversations/attributes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationsAttributes.createConversationAttribute({ + data_type: "string", + name: "api_test_attr", + }); + expect(response).toEqual({ + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }); + }); + + test("createConversationAttribute (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { data_type: "string", name: "name" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/attributes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.createConversationAttribute({ + data_type: "string", + name: "name", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createConversationAttribute (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { data_type: "string", name: "name" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/conversations/attributes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.createConversationAttribute({ + data_type: "string", + name: "name", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("getConversationAttribute (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }; + server + .mockEndpoint() + .get("/conversations/attributes/1") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationsAttributes.getConversationAttribute({ + id: 1, + }); + expect(response).toEqual({ + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }); + }); + + test("getConversationAttribute (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/conversations/attributes/1") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.getConversationAttribute({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("getConversationAttribute (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/conversations/attributes/1") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.getConversationAttribute({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateConversationAttribute (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "api_test_renamed", description: "Updated via API" }; + const rawResponseBody = { + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }; + server + .mockEndpoint() + .put("/conversations/attributes/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationsAttributes.updateConversationAttribute({ + id: 1, + name: "api_test_renamed", + description: "Updated via API", + }); + expect(response).toEqual({ + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }); + }); + + test("updateConversationAttribute (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/conversations/attributes/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.updateConversationAttribute({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateConversationAttribute (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/conversations/attributes/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.updateConversationAttribute({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteConversationAttribute (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }; + server + .mockEndpoint() + .delete("/conversations/attributes/1") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationsAttributes.deleteConversationAttribute({ + id: 1, + }); + expect(response).toEqual({ + data_type: "string", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + multiline: false, + }); + }); + + test("deleteConversationAttribute (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/conversations/attributes/1") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.deleteConversationAttribute({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteConversationAttribute (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/conversations/attributes/1") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.deleteConversationAttribute({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("createConversationAttributeOption (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { label: "High" }; + const rawResponseBody = { + data_type: "list", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + options: [{ id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", label: "High", archived: false }], + }; + server + .mockEndpoint() + .post("/conversations/attributes/1/options") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationsAttributes.createConversationAttributeOption({ + id: 1, + body: { + label: "High", + }, + }); + expect(response).toEqual({ + data_type: "list", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + options: [ + { + id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + label: "High", + archived: false, + }, + ], + }); + }); + + test("createConversationAttributeOption (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { label: "label" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/conversations/attributes/1/options") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.createConversationAttributeOption({ + id: 1, + body: { + label: "label", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createConversationAttributeOption (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { label: "label" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/conversations/attributes/1/options") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.createConversationAttributeOption({ + id: 1, + body: { + label: "label", + }, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("createConversationAttributeOption (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { label: "label" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/conversations/attributes/1/options") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.createConversationAttributeOption({ + id: 1, + body: { + label: "label", + }, + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("updateConversationAttributeOption (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { label: "Renamed" }; + const rawResponseBody = { + data_type: "list", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + options: [{ id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", label: "High", archived: false }], + }; + server + .mockEndpoint() + .put("/conversations/attributes/1/options/a1b2c3d4-e5f6-7890-abcd-ef1234567890") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationsAttributes.updateConversationAttributeOption({ + id: 1, + option_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + label: "Renamed", + }); + expect(response).toEqual({ + data_type: "list", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + options: [ + { + id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + label: "High", + archived: false, + }, + ], + }); + }); + + test("updateConversationAttributeOption (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { label: "label" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/conversations/attributes/1/options/option_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.updateConversationAttributeOption({ + id: 1, + option_id: "option_id", + label: "label", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateConversationAttributeOption (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { label: "label" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/conversations/attributes/1/options/option_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.updateConversationAttributeOption({ + id: 1, + option_id: "option_id", + label: "label", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateConversationAttributeOption (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { label: "label" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/conversations/attributes/1/options/option_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.updateConversationAttributeOption({ + id: 1, + option_id: "option_id", + label: "label", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("deleteConversationAttributeOption (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data_type: "list", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + options: [{ id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", label: "High", archived: false }], + }; + server + .mockEndpoint() + .delete("/conversations/attributes/1/options/a1b2c3d4-e5f6-7890-abcd-ef1234567890") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.conversationsAttributes.deleteConversationAttributeOption({ + id: 1, + option_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + }); + expect(response).toEqual({ + data_type: "list", + type: "conversation_attribute", + id: 8, + name: "api_test_attr", + description: "Created via API test", + required: false, + visible_to_team_ids: ["visible_to_team_ids"], + archived: false, + created_at: 1778239701, + updated_at: 1778239701, + admin_id: "16", + options: [ + { + id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + label: "High", + archived: false, + }, + ], + }); + }); + + test("deleteConversationAttributeOption (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/conversations/attributes/1/options/option_id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.deleteConversationAttributeOption({ + id: 1, + option_id: "option_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteConversationAttributeOption (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/conversations/attributes/1/options/option_id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.deleteConversationAttributeOption({ + id: 1, + option_id: "option_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteConversationAttributeOption (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/conversations/attributes/1/options/option_id") + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.conversationsAttributes.deleteConversationAttributeOption({ + id: 1, + option_id: "option_id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); +}); diff --git a/tests/wire/unstable/customObjectInstances.test.ts b/tests/wire/preview/customObjectInstances.test.ts similarity index 74% rename from tests/wire/unstable/customObjectInstances.test.ts rename to tests/wire/preview/customObjectInstances.test.ts index 6f46b5a0..cf31ca61 100644 --- a/tests/wire/unstable/customObjectInstances.test.ts +++ b/tests/wire/preview/customObjectInstances.test.ts @@ -5,7 +5,7 @@ import { IntercomClient } from "../../../src/Client"; import { mockServerPool } from "../../mock-server/MockServerPool"; describe("CustomObjectInstancesClient", () => { - test("getCustomObjectInstancesByExternalId (1)", async () => { + test("listCustomObjectInstances (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -15,14 +15,31 @@ describe("CustomObjectInstancesClient", () => { }); const rawResponseBody = { - id: "24", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537748, - updated_at: 1734537748, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, + type: "list", + pages: { type: "pages", page: 1, next: "next", per_page: 20, total_pages: 1 }, + total_count: 2, + data: [ + { + id: "2", + external_id: "order_002", + external_created_at: 1571672154, + external_updated_at: 1571672154, + created_at: 1734537800, + updated_at: 1734537800, + type: "Order", + custom_attributes: { order_number: "ORDER-98765", total_amount: "custom_attributes" }, + }, + { + id: "1", + external_id: "order_001", + external_created_at: 1734537100, + external_updated_at: 1734537100, + created_at: 1734537100, + updated_at: 1734537100, + type: "Order", + custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, + }, + ], }; server .mockEndpoint() @@ -32,26 +49,56 @@ describe("CustomObjectInstancesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ + const response = await client.preview.customObjectInstances.listCustomObjectInstances({ custom_object_type_identifier: "Order", + references_contact_id: "references_contact_id", + references_conversation_id: "references_conversation_id", external_id: "external_id", + page: 1, + per_page: 1, }); expect(response).toEqual({ - id: "24", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537748, - updated_at: 1734537748, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", + type: "list", + pages: { + type: "pages", + page: 1, + next: "next", + per_page: 20, + total_pages: 1, }, + total_count: 2, + data: [ + { + id: "2", + external_id: "order_002", + external_created_at: 1571672154, + external_updated_at: 1571672154, + created_at: 1734537800, + updated_at: 1734537800, + type: "Order", + custom_attributes: { + order_number: "ORDER-98765", + total_amount: "custom_attributes", + }, + }, + { + id: "1", + external_id: "order_001", + external_created_at: 1734537100, + external_updated_at: 1734537100, + created_at: 1734537100, + updated_at: 1734537100, + type: "Order", + custom_attributes: { + order_number: "ORDER-12345", + total_amount: "custom_attributes", + }, + }, + ], }); }); - test("getCustomObjectInstancesByExternalId (2)", async () => { + test("listCustomObjectInstances (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -70,14 +117,13 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ + return await client.preview.customObjectInstances.listCustomObjectInstances({ custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); - test("getCustomObjectInstancesByExternalId (3)", async () => { + test("listCustomObjectInstances (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -96,11 +142,10 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ + return await client.preview.customObjectInstances.listCustomObjectInstances({ custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("createCustomObjectInstances (1)", async () => { @@ -136,7 +181,7 @@ describe("CustomObjectInstancesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.customObjectInstances.createCustomObjectInstances({ + const response = await client.preview.customObjectInstances.createCustomObjectInstances({ custom_object_type_identifier: "Order", external_id: "123", external_created_at: 1392036272, @@ -181,10 +226,10 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.createCustomObjectInstances({ + return await client.preview.customObjectInstances.createCustomObjectInstances({ custom_object_type_identifier: "custom_object_type_identifier", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createCustomObjectInstances (3)", async () => { @@ -207,10 +252,10 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.createCustomObjectInstances({ + return await client.preview.customObjectInstances.createCustomObjectInstances({ custom_object_type_identifier: "custom_object_type_identifier", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("deleteCustomObjectInstancesById (1)", async () => { @@ -231,7 +276,7 @@ describe("CustomObjectInstancesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ + const response = await client.preview.customObjectInstances.deleteCustomObjectInstancesById({ custom_object_type_identifier: "Order", external_id: "external_id", }); @@ -261,11 +306,11 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ + return await client.preview.customObjectInstances.deleteCustomObjectInstancesById({ custom_object_type_identifier: "custom_object_type_identifier", external_id: "external_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteCustomObjectInstancesById (3)", async () => { @@ -287,11 +332,11 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ + return await client.preview.customObjectInstances.deleteCustomObjectInstancesById({ custom_object_type_identifier: "custom_object_type_identifier", external_id: "external_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("getCustomObjectInstancesById (1)", async () => { @@ -321,7 +366,7 @@ describe("CustomObjectInstancesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.customObjectInstances.getCustomObjectInstancesById({ + const response = await client.preview.customObjectInstances.getCustomObjectInstancesById({ custom_object_type_identifier: "Order", id: "id", }); @@ -359,11 +404,11 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.getCustomObjectInstancesById({ + return await client.preview.customObjectInstances.getCustomObjectInstancesById({ custom_object_type_identifier: "custom_object_type_identifier", id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("getCustomObjectInstancesById (3)", async () => { @@ -385,11 +430,11 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.getCustomObjectInstancesById({ + return await client.preview.customObjectInstances.getCustomObjectInstancesById({ custom_object_type_identifier: "custom_object_type_identifier", id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("deleteCustomObjectInstancesByExternalId (1)", async () => { @@ -410,7 +455,7 @@ describe("CustomObjectInstancesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ + const response = await client.preview.customObjectInstances.deleteCustomObjectInstancesByExternalId({ custom_object_type_identifier: "Order", id: "id", }); @@ -440,11 +485,11 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ + return await client.preview.customObjectInstances.deleteCustomObjectInstancesByExternalId({ custom_object_type_identifier: "custom_object_type_identifier", id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteCustomObjectInstancesByExternalId (3)", async () => { @@ -466,10 +511,10 @@ describe("CustomObjectInstancesClient", () => { .build(); await expect(async () => { - return await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ + return await client.preview.customObjectInstances.deleteCustomObjectInstancesByExternalId({ custom_object_type_identifier: "custom_object_type_identifier", id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/unstable/dataAttributes.test.ts b/tests/wire/preview/dataAttributes.test.ts similarity index 95% rename from tests/wire/unstable/dataAttributes.test.ts rename to tests/wire/preview/dataAttributes.test.ts index 40902954..351be920 100644 --- a/tests/wire/unstable/dataAttributes.test.ts +++ b/tests/wire/preview/dataAttributes.test.ts @@ -345,7 +345,7 @@ describe("DataAttributesClient", () => { }; server.mockEndpoint().get("/data_attributes").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.dataAttributes.lisDataAttributes({ + const response = await client.preview.dataAttributes.lisDataAttributes({ model: "contact", include_archived: true, }); @@ -693,8 +693,25 @@ describe("DataAttributesClient", () => { server.mockEndpoint().get("/data_attributes").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.dataAttributes.lisDataAttributes(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.dataAttributes.lisDataAttributes(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("lisDataAttributes (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/data_attributes").respondWith().statusCode(422).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.dataAttributes.lisDataAttributes(); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); }); test("createDataAttribute (1)", async () => { @@ -734,7 +751,7 @@ describe("DataAttributesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.dataAttributes.createDataAttribute({ + const response = await client.preview.dataAttributes.createDataAttribute({ key: "value", }); expect(response).toEqual({ @@ -778,10 +795,10 @@ describe("DataAttributesClient", () => { .build(); await expect(async () => { - return await client.unstable.dataAttributes.createDataAttribute({ + return await client.preview.dataAttributes.createDataAttribute({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("createDataAttribute (3)", async () => { @@ -804,10 +821,10 @@ describe("DataAttributesClient", () => { .build(); await expect(async () => { - return await client.unstable.dataAttributes.createDataAttribute({ + return await client.preview.dataAttributes.createDataAttribute({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateDataAttribute (1)", async () => { @@ -847,7 +864,7 @@ describe("DataAttributesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.dataAttributes.updateDataAttribute({ + const response = await client.preview.dataAttributes.updateDataAttribute({ id: 1, body: { key: "value", @@ -894,13 +911,13 @@ describe("DataAttributesClient", () => { .build(); await expect(async () => { - return await client.unstable.dataAttributes.updateDataAttribute({ + return await client.preview.dataAttributes.updateDataAttribute({ id: 1, body: { key: "value", }, }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("updateDataAttribute (3)", async () => { @@ -923,13 +940,13 @@ describe("DataAttributesClient", () => { .build(); await expect(async () => { - return await client.unstable.dataAttributes.updateDataAttribute({ + return await client.preview.dataAttributes.updateDataAttribute({ id: 1, body: { key: "value", }, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateDataAttribute (4)", async () => { @@ -952,13 +969,13 @@ describe("DataAttributesClient", () => { .build(); await expect(async () => { - return await client.unstable.dataAttributes.updateDataAttribute({ + return await client.preview.dataAttributes.updateDataAttribute({ id: 1, body: { key: "value", }, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("updateDataAttribute (5)", async () => { @@ -981,12 +998,12 @@ describe("DataAttributesClient", () => { .build(); await expect(async () => { - return await client.unstable.dataAttributes.updateDataAttribute({ + return await client.preview.dataAttributes.updateDataAttribute({ id: 1, body: { key: "value", }, }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); }); }); diff --git a/tests/wire/preview/dataConnectors.test.ts b/tests/wire/preview/dataConnectors.test.ts new file mode 100644 index 00000000..747d2ef2 --- /dev/null +++ b/tests/wire/preview/dataConnectors.test.ts @@ -0,0 +1,1872 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("DataConnectorsClient", () => { + test("listDataConnectors (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "data_connector", + id: "12345", + name: "Order Status Service", + description: "Fetches order status from external fulfillment API", + state: "live", + http_method: "post", + direct_fin_usage: false, + created_by_admin_id: "128", + updated_by_admin_id: "128", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }, + ], + pages: { type: "pages", per_page: 20, next: { starting_after: "WzE3MDc1OTQ3MTUuMCwxMjM0NV0=" } }, + }; + server.mockEndpoint().get("/data_connectors").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.dataConnectors.listDataConnectors({ + per_page: 1, + starting_after: "starting_after", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "data_connector", + id: "12345", + name: "Order Status Service", + description: "Fetches order status from external fulfillment API", + state: "live", + http_method: "post", + direct_fin_usage: false, + created_by_admin_id: "128", + updated_by_admin_id: "128", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }, + ], + pages: { + type: "pages", + per_page: 20, + next: { + starting_after: "WzE3MDc1OTQ3MTUuMCwxMjM0NV0=", + }, + }, + }); + }); + + test("listDataConnectors (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/data_connectors").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.dataConnectors.listDataConnectors(); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("listDataConnectors (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/data_connectors").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.dataConnectors.listDataConnectors(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createDataConnector (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + name: "Get Order Status", + description: "Looks up order status from an external service", + http_method: "get", + url: "https://api.example.com/orders/{{order_id}}/status", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + headers: [{ name: "Content-Type", value: "application/json" }], + data_inputs: [ + { + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "", + }, + ], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true, + }; + const rawResponseBody = { + type: "data_connector", + id: "125", + name: "Get Order Status", + description: "Looks up order status from an external service", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [{ name: "Authorization", value: "****" }], + http_method: "get", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 30000, + data_inputs: [ + { + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "", + }, + ], + response_fields: [{ path: "status", type: "unknown", example_value: "ok", redacted: false }], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true, + created_by_admin_id: "128", + updated_by_admin_id: "128", + created_at: "2026-03-19T11:27:36Z", + updated_at: "2026-03-19T11:27:36Z", + execution_results_url: "/data_connectors/125/execution_results", + }; + server + .mockEndpoint() + .post("/data_connectors") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.createDataConnector({ + name: "Get Order Status", + description: "Looks up order status from an external service", + http_method: "get", + url: "https://api.example.com/orders/{{order_id}}/status", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + headers: [ + { + name: "Content-Type", + value: "application/json", + }, + ], + data_inputs: [ + { + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "", + }, + ], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true, + }); + expect(response).toEqual({ + type: "data_connector", + id: "125", + name: "Get Order Status", + description: "Looks up order status from an external service", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [ + { + name: "Authorization", + value: "****", + }, + ], + http_method: "get", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 30000, + data_inputs: [ + { + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "", + }, + ], + response_fields: [ + { + path: "status", + type: "unknown", + example_value: "ok", + redacted: false, + }, + ], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true, + created_by_admin_id: "128", + updated_by_admin_id: "128", + created_at: "2026-03-19T11:27:36Z", + updated_at: "2026-03-19T11:27:36Z", + execution_results_url: "/data_connectors/125/execution_results", + }); + }); + + test("createDataConnector (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "My Connector" }; + const rawResponseBody = { + type: "data_connector", + id: "125", + name: "Get Order Status", + description: "Looks up order status from an external service", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [{ name: "Authorization", value: "****" }], + http_method: "get", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 30000, + data_inputs: [ + { + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "", + }, + ], + response_fields: [{ path: "status", type: "unknown", example_value: "ok", redacted: false }], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true, + created_by_admin_id: "128", + updated_by_admin_id: "128", + created_at: "2026-03-19T11:27:36Z", + updated_at: "2026-03-19T11:27:36Z", + execution_results_url: "/data_connectors/125/execution_results", + }; + server + .mockEndpoint() + .post("/data_connectors") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.createDataConnector({ + name: "My Connector", + }); + expect(response).toEqual({ + type: "data_connector", + id: "125", + name: "Get Order Status", + description: "Looks up order status from an external service", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [ + { + name: "Authorization", + value: "****", + }, + ], + http_method: "get", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 30000, + data_inputs: [ + { + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "", + }, + ], + response_fields: [ + { + path: "status", + type: "unknown", + example_value: "ok", + redacted: false, + }, + ], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true, + created_by_admin_id: "128", + updated_by_admin_id: "128", + created_at: "2026-03-19T11:27:36Z", + updated_at: "2026-03-19T11:27:36Z", + execution_results_url: "/data_connectors/125/execution_results", + }); + }); + + test("createDataConnector (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "Order Lookup", mock_response: { order: { id: 12345, status: "shipped" } } }; + const rawResponseBody = { + type: "data_connector", + id: "125", + name: "Get Order Status", + description: "Looks up order status from an external service", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [{ name: "Authorization", value: "****" }], + http_method: "get", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 30000, + data_inputs: [ + { + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "", + }, + ], + response_fields: [{ path: "status", type: "unknown", example_value: "ok", redacted: false }], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true, + created_by_admin_id: "128", + updated_by_admin_id: "128", + created_at: "2026-03-19T11:27:36Z", + updated_at: "2026-03-19T11:27:36Z", + execution_results_url: "/data_connectors/125/execution_results", + }; + server + .mockEndpoint() + .post("/data_connectors") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.createDataConnector({ + name: "Order Lookup", + mock_response: { + order: { + id: 12345, + status: "shipped", + }, + }, + }); + expect(response).toEqual({ + type: "data_connector", + id: "125", + name: "Get Order Status", + description: "Looks up order status from an external service", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [ + { + name: "Authorization", + value: "****", + }, + ], + http_method: "get", + direct_fin_usage: true, + audiences: ["leads", "visitors"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 30000, + data_inputs: [ + { + name: "order_id", + type: "string", + description: "The order ID to look up", + required: true, + default_value: "", + }, + ], + response_fields: [ + { + path: "status", + type: "unknown", + example_value: "ok", + redacted: false, + }, + ], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: true, + bypass_authentication: false, + validate_missing_attributes: true, + created_by_admin_id: "128", + updated_by_admin_id: "128", + created_at: "2026-03-19T11:27:36Z", + updated_at: "2026-03-19T11:27:36Z", + execution_results_url: "/data_connectors/125/execution_results", + }); + }); + + test("createDataConnector (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/data_connectors") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.createDataConnector({ + name: "name", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createDataConnector (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/data_connectors") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.createDataConnector({ + name: "name", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("RetrieveDataConnector (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "data_connector", + id: "12345", + name: "Order Status Service", + description: "Fetches order status from external fulfillment API", + state: "live", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [{ name: "Authorization", value: "****" }], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "code_block_transformation", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [{ path: "status", type: "string", example_value: "ok", redacted: false }], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: true, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }; + server + .mockEndpoint() + .get("/data_connectors/12345") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.retrieveDataConnector({ + id: "12345", + state_version: "draft", + }); + expect(response).toEqual({ + type: "data_connector", + id: "12345", + name: "Order Status Service", + description: "Fetches order status from external fulfillment API", + state: "live", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [ + { + name: "Authorization", + value: "****", + }, + ], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "code_block_transformation", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [ + { + path: "status", + type: "string", + example_value: "ok", + redacted: false, + }, + ], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: true, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-01-20T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }); + }); + + test("RetrieveDataConnector (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/data_connectors/id") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.retrieveDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("RetrieveDataConnector (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/data_connectors/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.retrieveDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("RetrieveDataConnector (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/data_connectors/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.retrieveDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteDataConnector (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "125", object: "data_connector", deleted: true }; + server + .mockEndpoint() + .delete("/data_connectors/12345") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.deleteDataConnector({ + id: "12345", + }); + expect(response).toEqual({ + id: "125", + object: "data_connector", + deleted: true, + }); + }); + + test("deleteDataConnector (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/data_connectors/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.deleteDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteDataConnector (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/data_connectors/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.deleteDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteDataConnector (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/data_connectors/id") + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.deleteDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ConflictError); + }); + + test("updateDataConnector (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "Updated Connector Name", description: "Updated description" }; + const rawResponseBody = { + type: "data_connector", + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [{ name: "Authorization", value: "****" }], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [{ path: "status", type: "unknown", example_value: "ok", redacted: false }], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: false, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-03-24T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }; + server + .mockEndpoint() + .patch("/data_connectors/12345") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.updateDataConnector({ + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + }); + expect(response).toEqual({ + type: "data_connector", + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [ + { + name: "Authorization", + value: "****", + }, + ], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [ + { + path: "status", + type: "unknown", + example_value: "ok", + redacted: false, + }, + ], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: false, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-03-24T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }); + }); + + test("updateDataConnector (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { state: "live" }; + const rawResponseBody = { + type: "data_connector", + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [{ name: "Authorization", value: "****" }], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [{ path: "status", type: "unknown", example_value: "ok", redacted: false }], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: false, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-03-24T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }; + server + .mockEndpoint() + .patch("/data_connectors/12345") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.updateDataConnector({ + id: "12345", + state: "live", + }); + expect(response).toEqual({ + type: "data_connector", + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [ + { + name: "Authorization", + value: "****", + }, + ], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [ + { + path: "status", + type: "unknown", + example_value: "ok", + redacted: false, + }, + ], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: false, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-03-24T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }); + }); + + test("updateDataConnector (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { state: "draft" }; + const rawResponseBody = { + type: "data_connector", + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [{ name: "Authorization", value: "****" }], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [{ path: "status", type: "unknown", example_value: "ok", redacted: false }], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: false, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-03-24T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }; + server + .mockEndpoint() + .patch("/data_connectors/12345") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.updateDataConnector({ + id: "12345", + state: "draft", + }); + expect(response).toEqual({ + type: "data_connector", + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [ + { + name: "Authorization", + value: "****", + }, + ], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [ + { + path: "status", + type: "unknown", + example_value: "ok", + redacted: false, + }, + ], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: false, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-03-24T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }); + }); + + test("updateDataConnector (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { mock_response: { user: { name: "Alice", email: "alice@example.com" } } }; + const rawResponseBody = { + type: "data_connector", + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [{ name: "Authorization", value: "****" }], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [{ path: "status", type: "unknown", example_value: "ok", redacted: false }], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: false, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-03-24T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }; + server + .mockEndpoint() + .patch("/data_connectors/12345") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.updateDataConnector({ + id: "12345", + mock_response: { + user: { + name: "Alice", + email: "alice@example.com", + }, + }, + }); + expect(response).toEqual({ + type: "data_connector", + id: "12345", + name: "Updated Connector Name", + description: "Updated description", + state: "draft", + url: "https://api.example.com/orders/{{order_id}}/status", + body: '{"text": "{{message}}"}', + headers: [ + { + name: "Authorization", + value: "****", + }, + ], + http_method: "post", + direct_fin_usage: false, + audiences: ["users", "leads"], + execution_type: "server_side", + configuration_response_type: "test_response_type", + data_transformation_type: "full_access", + transform_code_block: { + code: 'def transform(response):\n return {"status": response["order_status"]}\n', + language: "python", + }, + client_function_name: "client_function_name", + client_function_timeout_ms: 1, + data_inputs: [ + { + name: "conversation_id", + type: "string", + description: "The Intercom conversation ID", + required: true, + default_value: "", + }, + ], + response_fields: [ + { + path: "status", + type: "unknown", + example_value: "ok", + redacted: false, + }, + ], + object_mappings: [ + { + response_object_path: "response_object_path", + intercom_object_type: "conversation", + attribute_mappings: [{}], + reference_mappings: [{}], + }, + ], + token_ids: ["token_ids"], + customer_authentication: false, + bypass_authentication: false, + validate_missing_attributes: false, + created_by_admin_id: "456", + updated_by_admin_id: "456", + created_at: "2025-11-15T09:30:00Z", + updated_at: "2026-03-24T14:22:15Z", + execution_results_url: "/data_connectors/12345/execution_results", + }); + }); + + test("updateDataConnector (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .patch("/data_connectors/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.updateDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateDataConnector (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .patch("/data_connectors/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.updateDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateDataConnector (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .patch("/data_connectors/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.updateDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ConflictError); + }); + + test("updateDataConnector (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .patch("/data_connectors/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.updateDataConnector({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("listDataConnectorExecutionResults (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "data_connector.execution", + id: "99001", + data_connector_id: "12345", + success: true, + http_status: 200, + http_method: "post", + error_type: "request_configuration_error", + error_message: "Connection refused", + execution_time_ms: 150, + source_type: "workflow", + source_id: "5001", + conversation_id: "8001", + created_at: "2026-02-10T18:15:32Z", + request_url: "https://api.vendor.com/webhook", + request_body: '{"message": "hello"}', + response_body: '{"status": "ok"}', + raw_response_body: '{"status": "ok"}', + }, + { + type: "data_connector.execution", + id: "99000", + data_connector_id: "12345", + success: false, + http_status: 200, + http_method: "post", + error_type: "3rd_party_error", + error_message: "Connection refused", + execution_time_ms: 245, + source_type: "inbox", + source_id: "5001", + conversation_id: "8001", + created_at: "2026-02-10T17:45:15Z", + request_url: "https://api.example.com/webhook", + request_body: '{"message": "hello"}', + response_body: '{"status": "ok"}', + raw_response_body: '{"status": "ok"}', + }, + ], + pages: { type: "pages", per_page: 10, next: { starting_after: "WzE3MDc1OTQ3MTUuMCw5OTAwMF0=" } }, + }; + server + .mockEndpoint() + .get("/data_connectors/12345/execution_results") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.listDataConnectorExecutionResults({ + data_connector_id: "12345", + per_page: 1, + starting_after: "starting_after", + success: "true", + error_type: "request_configuration_error", + start_ts: 1, + end_ts: 1, + include_bodies: "true", + }); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "data_connector.execution", + id: "99001", + data_connector_id: "12345", + success: true, + http_status: 200, + http_method: "post", + error_type: "request_configuration_error", + error_message: "Connection refused", + execution_time_ms: 150, + source_type: "workflow", + source_id: "5001", + conversation_id: "8001", + created_at: "2026-02-10T18:15:32Z", + request_url: "https://api.vendor.com/webhook", + request_body: '{"message": "hello"}', + response_body: '{"status": "ok"}', + raw_response_body: '{"status": "ok"}', + }, + { + type: "data_connector.execution", + id: "99000", + data_connector_id: "12345", + success: false, + http_status: 200, + http_method: "post", + error_type: "3rd_party_error", + error_message: "Connection refused", + execution_time_ms: 245, + source_type: "inbox", + source_id: "5001", + conversation_id: "8001", + created_at: "2026-02-10T17:45:15Z", + request_url: "https://api.example.com/webhook", + request_body: '{"message": "hello"}', + response_body: '{"status": "ok"}', + raw_response_body: '{"status": "ok"}', + }, + ], + pages: { + type: "pages", + per_page: 10, + next: { + starting_after: "WzE3MDc1OTQ3MTUuMCw5OTAwMF0=", + }, + }, + }); + }); + + test("listDataConnectorExecutionResults (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/data_connectors/data_connector_id/execution_results") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.listDataConnectorExecutionResults({ + data_connector_id: "data_connector_id", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("listDataConnectorExecutionResults (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/data_connectors/data_connector_id/execution_results") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.listDataConnectorExecutionResults({ + data_connector_id: "data_connector_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listDataConnectorExecutionResults (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/data_connectors/data_connector_id/execution_results") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.listDataConnectorExecutionResults({ + data_connector_id: "data_connector_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("showDataConnectorExecutionResult (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "data_connector.execution", + id: "99001", + data_connector_id: "12345", + success: true, + http_status: 200, + http_method: "post", + error_type: "request_configuration_error", + error_message: "Connection refused", + execution_time_ms: 150, + source_type: "workflow", + source_id: "5001", + conversation_id: "8001", + created_at: "2026-02-10T18:15:32Z", + request_url: "https://api.example.com/webhook", + request_body: '{"channel": "#alerts", "text": "Conversation updated"}', + response_body: '{"ok": true}', + raw_response_body: '{"ok": true}', + }; + server + .mockEndpoint() + .get("/data_connectors/12345/execution_results/99001") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.dataConnectors.showDataConnectorExecutionResult({ + data_connector_id: "12345", + id: "99001", + }); + expect(response).toEqual({ + type: "data_connector.execution", + id: "99001", + data_connector_id: "12345", + success: true, + http_status: 200, + http_method: "post", + error_type: "request_configuration_error", + error_message: "Connection refused", + execution_time_ms: 150, + source_type: "workflow", + source_id: "5001", + conversation_id: "8001", + created_at: "2026-02-10T18:15:32Z", + request_url: "https://api.example.com/webhook", + request_body: '{"channel": "#alerts", "text": "Conversation updated"}', + response_body: '{"ok": true}', + raw_response_body: '{"ok": true}', + }); + }); + + test("showDataConnectorExecutionResult (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/data_connectors/data_connector_id/execution_results/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.showDataConnectorExecutionResult({ + data_connector_id: "data_connector_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("showDataConnectorExecutionResult (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/data_connectors/data_connector_id/execution_results/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.dataConnectors.showDataConnectorExecutionResult({ + data_connector_id: "data_connector_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); +}); diff --git a/tests/wire/unstable/dataEvents.test.ts b/tests/wire/preview/dataEvents.test.ts similarity index 88% rename from tests/wire/unstable/dataEvents.test.ts rename to tests/wire/preview/dataEvents.test.ts index 14d6052a..4dc77407 100644 --- a/tests/wire/unstable/dataEvents.test.ts +++ b/tests/wire/preview/dataEvents.test.ts @@ -26,7 +26,7 @@ describe("DataEventsClient", () => { }; server.mockEndpoint().get("/events").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.dataEvents.lisDataEvents({ + const response = await client.preview.dataEvents.lisDataEvents({ filter: { user_id: "user_id", }, @@ -69,13 +69,13 @@ describe("DataEventsClient", () => { server.mockEndpoint().get("/events").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.dataEvents.lisDataEvents({ + return await client.preview.dataEvents.lisDataEvents({ filter: { user_id: "user_id", }, type: "type", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createDataEvent (1)", async () => { @@ -90,7 +90,7 @@ describe("DataEventsClient", () => { server.mockEndpoint().post("/events").jsonBody(rawRequestBody).respondWith().statusCode(200).build(); - const response = await client.unstable.dataEvents.createDataEvent({ + const response = await client.preview.dataEvents.createDataEvent({ key: "value", }); expect(response).toEqual(undefined); @@ -116,10 +116,10 @@ describe("DataEventsClient", () => { .build(); await expect(async () => { - return await client.unstable.dataEvents.createDataEvent({ + return await client.preview.dataEvents.createDataEvent({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("dataEventSummaries (1)", async () => { @@ -134,7 +134,7 @@ describe("DataEventsClient", () => { server.mockEndpoint().post("/events/summaries").jsonBody(rawRequestBody).respondWith().statusCode(200).build(); - const response = await client.unstable.dataEvents.dataEventSummaries(); + const response = await client.preview.dataEvents.dataEventSummaries(); expect(response).toEqual(undefined); }); @@ -158,7 +158,7 @@ describe("DataEventsClient", () => { .build(); await expect(async () => { - return await client.unstable.dataEvents.dataEventSummaries(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.dataEvents.dataEventSummaries(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/dataExport.test.ts b/tests/wire/preview/dataExport.test.ts similarity index 92% rename from tests/wire/unstable/dataExport.test.ts rename to tests/wire/preview/dataExport.test.ts index 7db13db4..d95fbeae 100644 --- a/tests/wire/unstable/dataExport.test.ts +++ b/tests/wire/preview/dataExport.test.ts @@ -28,7 +28,7 @@ describe("DataExportClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.dataExport.createDataExport({ + const response = await client.preview.dataExport.createDataExport({ created_at_after: 1734519776, created_at_before: 1734537776, }); @@ -63,7 +63,7 @@ describe("DataExportClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.dataExport.getDataExport({ + const response = await client.preview.dataExport.getDataExport({ job_identifier: "job_identifier", }); expect(response).toEqual({ @@ -97,7 +97,7 @@ describe("DataExportClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.dataExport.cancelDataExport({ + const response = await client.preview.dataExport.cancelDataExport({ job_identifier: "job_identifier", }); expect(response).toEqual({ @@ -119,7 +119,7 @@ describe("DataExportClient", () => { server.mockEndpoint().get("/download/content/data/job_identifier").respondWith().statusCode(200).build(); - const response = await client.unstable.dataExport.downloadDataExport({ + const response = await client.preview.dataExport.downloadDataExport({ job_identifier: "job_identifier", }); expect(response).toEqual(undefined); diff --git a/tests/wire/unstable/emails.test.ts b/tests/wire/preview/emails.test.ts similarity index 91% rename from tests/wire/unstable/emails.test.ts rename to tests/wire/preview/emails.test.ts index 95a02bd0..8f528df3 100644 --- a/tests/wire/unstable/emails.test.ts +++ b/tests/wire/preview/emails.test.ts @@ -45,7 +45,7 @@ describe("EmailsClient", () => { }; server.mockEndpoint().get("/emails").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.emails.listEmails(); + const response = await client.preview.emails.listEmails(); expect(response).toEqual({ type: "list", data: [ @@ -90,8 +90,8 @@ describe("EmailsClient", () => { server.mockEndpoint().get("/emails").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.emails.listEmails(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.emails.listEmails(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveEmail (1)", async () => { @@ -117,7 +117,7 @@ describe("EmailsClient", () => { }; server.mockEndpoint().get("/emails/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.emails.retrieveEmail({ + const response = await client.preview.emails.retrieveEmail({ id: "id", }); expect(response).toEqual({ @@ -147,10 +147,10 @@ describe("EmailsClient", () => { server.mockEndpoint().get("/emails/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.emails.retrieveEmail({ + return await client.preview.emails.retrieveEmail({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveEmail (3)", async () => { @@ -166,9 +166,9 @@ describe("EmailsClient", () => { server.mockEndpoint().get("/emails/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.emails.retrieveEmail({ + return await client.preview.emails.retrieveEmail({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/preview/finAgent.test.ts b/tests/wire/preview/finAgent.test.ts new file mode 100644 index 00000000..41dc6285 --- /dev/null +++ b/tests/wire/preview/finAgent.test.ts @@ -0,0 +1,2192 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("FinAgentClient", () => { + test("listFinCapabilities (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { user: { id: "123456" } }; + const rawResponseBody = { + version: "Preview", + capabilities: [ + { + type: "procedure", + id: "12345", + name: "Reset password", + description: "Walk the user through resetting their password.", + endpoint: "/fin/procedures/12345/run", + method: "POST", + }, + { + type: "reply", + id: "12345", + name: "Reset password", + description: "Reply to an in-progress Fin conversation.", + endpoint: "/fin/reply", + method: "POST", + }, + { + type: "ask", + id: "12345", + name: "Reset password", + description: "Ask Fin a single, self-contained question.", + endpoint: "/fin/ask", + method: "POST", + }, + ], + }; + server + .mockEndpoint() + .post("/fin/capabilities") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.listFinCapabilities({ + user: { + id: "123456", + }, + }); + expect(response).toEqual({ + version: "Preview", + capabilities: [ + { + type: "procedure", + id: "12345", + name: "Reset password", + description: "Walk the user through resetting their password.", + endpoint: "/fin/procedures/12345/run", + method: "POST", + }, + { + type: "reply", + id: "12345", + name: "Reset password", + description: "Reply to an in-progress Fin conversation.", + endpoint: "/fin/reply", + method: "POST", + }, + { + type: "ask", + id: "12345", + name: "Reset password", + description: "Ask Fin a single, self-contained question.", + endpoint: "/fin/ask", + method: "POST", + }, + ], + }); + }); + + test("listFinCapabilities (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { user: { id: "id" } }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/capabilities") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.listFinCapabilities({ + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("listFinCapabilities (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { user: { id: "id" } }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/capabilities") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.listFinCapabilities({ + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("askFin (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How do I reset my password?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/ask") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.askFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How do I reset my password?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("askFin (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { + author: "user", + body: "And how long does that take to apply?", + timestamp: "2025-01-24T10:02:00Z", + }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com", attributes: { plan_type: "Pro" } }, + conversation_metadata: { + history: [{ author: "user", body: "How do I reset my password?", timestamp: "2025-01-24T10:01:20Z" }], + attributes: { order_id: "98765" }, + }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/ask") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.askFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "And how long does that take to apply?", + timestamp: "2025-01-24T10:02:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + attributes: { + plan_type: "Pro", + }, + }, + conversation_metadata: { + history: [ + { + author: "user", + body: "How do I reset my password?", + timestamp: "2025-01-24T10:01:20Z", + }, + ], + attributes: { + order_id: "98765", + }, + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("askFin (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How do I reset my password?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/ask") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.askFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How do I reset my password?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("askFin (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How do I reset my password?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/ask") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.askFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How do I reset my password?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("askFin (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body" }, + user: { id: "id" }, + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/ask") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.askFin({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("askFin (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body" }, + user: { id: "id" }, + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/ask") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.askFin({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("replyToFin (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.replyToFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "Thanks, here is my order number.", timestamp: "2025-01-24T09:01:00Z" }, + user: { id: "123456", name: "Jane Smith", email: "jane.smith@example.com" }, + settings: { follow_up_questions: false, email: true }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.replyToFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "Thanks, here is my order number.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "Jane Smith", + email: "jane.smith@example.com", + }, + settings: { + follow_up_questions: false, + email: true, + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "Here's the invoice you asked for.", timestamp: "2025-01-24T09:01:00Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + attachments: [{ type: "url", url: "https://example.com/invoice.pdf" }], + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.replyToFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "Here's the invoice you asked for.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + attachments: [ + { + type: "url", + url: "https://example.com/invoice.pdf", + }, + ], + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.replyToFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.replyToFin({ + conversation_id: "ext-123", + message: { + author: "user", + body: "Here's the information you requested.", + timestamp: "2025-01-24T09:01:00Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...", + }); + }); + + test("replyToFin (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body" }, + user: { id: "id" }, + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.replyToFin({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("replyToFin (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body" }, + user: { id: "id" }, + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.replyToFin({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("runFinProcedure (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + procedure_id: "12345", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/procedures/12345/run") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.runFinProcedure({ + procedure_id: "12345", + conversation_id: "ext-123", + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + procedure_id: "12345", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("runFinProcedure (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + message: { author: "agent", body: "Starting your refund request." }, + conversation_metadata: { attributes: { order_id: "98765" } }, + settings: { email: true }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + procedure_id: "12345", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/procedures/12345/run") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.runFinProcedure({ + procedure_id: "12345", + conversation_id: "ext-123", + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + message: { + author: "agent", + body: "Starting your refund request.", + }, + conversation_metadata: { + attributes: { + order_id: "98765", + }, + }, + settings: { + email: true, + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + procedure_id: "12345", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("runFinProcedure (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + procedure_id: "12345", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/procedures/12345/run") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.runFinProcedure({ + procedure_id: "12345", + conversation_id: "ext-123", + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + procedure_id: "12345", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("runFinProcedure (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + procedure_id: "12345", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/procedures/12345/run") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.runFinProcedure({ + procedure_id: "12345", + conversation_id: "ext-123", + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + procedure_id: "12345", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("runFinProcedure (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "conversation_id", user: { id: "id" } }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/procedures/procedure_id/run") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.runFinProcedure({ + procedure_id: "procedure_id", + conversation_id: "conversation_id", + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("runFinProcedure (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "conversation_id", user: { id: "id" } }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/procedures/procedure_id/run") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.runFinProcedure({ + procedure_id: "procedure_id", + conversation_id: "conversation_id", + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("escalateFinConversation (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + context: "Customer is requesting a refund and is frustrated.", + }; + const rawResponseBody = { + conversation_id: "ext-123", + intercom_conversation_id: "987654321", + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + status: "escalated", + }; + server + .mockEndpoint() + .post("/fin/escalate") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.escalateFinConversation({ + conversation_id: "ext-123", + context: "Customer is requesting a refund and is frustrated.", + }); + expect(response).toEqual({ + conversation_id: "ext-123", + intercom_conversation_id: "987654321", + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + status: "escalated", + }); + }); + + test("escalateFinConversation (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + context: "I need help with my billing issue", + }; + const rawResponseBody = { + conversation_id: "ext-123", + intercom_conversation_id: "987654321", + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + status: "escalated", + }; + server + .mockEndpoint() + .post("/fin/escalate") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.escalateFinConversation({ + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + context: "I need help with my billing issue", + }); + expect(response).toEqual({ + conversation_id: "ext-123", + intercom_conversation_id: "987654321", + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + status: "escalated", + }); + }); + + test("escalateFinConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + context: "Customer is requesting a refund and is frustrated.", + }; + const rawResponseBody = { + conversation_id: "ext-123", + intercom_conversation_id: "987654321", + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + status: "escalated", + }; + server + .mockEndpoint() + .post("/fin/escalate") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.escalateFinConversation({ + conversation_id: "ext-123", + context: "Customer is requesting a refund and is frustrated.", + }); + expect(response).toEqual({ + conversation_id: "ext-123", + intercom_conversation_id: "987654321", + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + status: "escalated", + }); + }); + + test("escalateFinConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + context: "Customer is requesting a refund and is frustrated.", + }; + const rawResponseBody = { + conversation_id: "ext-123", + intercom_conversation_id: "987654321", + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + status: "escalated", + }; + server + .mockEndpoint() + .post("/fin/escalate") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.escalateFinConversation({ + conversation_id: "ext-123", + context: "Customer is requesting a refund and is frustrated.", + }); + expect(response).toEqual({ + conversation_id: "ext-123", + intercom_conversation_id: "987654321", + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + status: "escalated", + }); + }); + + test("escalateFinConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { key: "value" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/escalate") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.escalateFinConversation({ + key: "value", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("escalateFinConversation (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { key: "value" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/escalate") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.escalateFinConversation({ + key: "value", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("submitFinCsat (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "ext-123", rating: "amazing" }; + const rawResponseBody = { conversation_id: "ext-123", rating: "amazing", status: "rated" }; + server + .mockEndpoint() + .post("/fin/csat") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.submitFinCsat({ + conversation_id: "ext-123", + rating: "amazing", + }); + expect(response).toEqual({ + conversation_id: "ext-123", + rating: "amazing", + status: "rated", + }); + }); + + test("submitFinCsat (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + rating: "amazing", + remark: "Fin solved my problem in seconds.", + }; + const rawResponseBody = { conversation_id: "ext-123", rating: "amazing", status: "rated" }; + server + .mockEndpoint() + .post("/fin/csat") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.submitFinCsat({ + conversation_id: "ext-123", + rating: "amazing", + remark: "Fin solved my problem in seconds.", + }); + expect(response).toEqual({ + conversation_id: "ext-123", + rating: "amazing", + status: "rated", + }); + }); + + test("submitFinCsat (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "conversation_id", rating: "terrible" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/csat") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.submitFinCsat({ + conversation_id: "conversation_id", + rating: "terrible", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("submitFinCsat (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "conversation_id", rating: "terrible" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/csat") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.submitFinCsat({ + conversation_id: "conversation_id", + rating: "terrible", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("startFinConversation (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How can I see my account details?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I resolve my outstanding invoice?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { id: "123456", name: "Jane Smith", email: "jane.smith@example.com" }, + settings: { follow_up_questions: false, email: true }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I resolve my outstanding invoice?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "Jane Smith", + email: "jane.smith@example.com", + }, + settings: { + follow_up_questions: false, + email: true, + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How can I see my account details?", timestamp: "2025-01-24T10:01:20Z" }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + attributes: { plan_type: "Pro", subscription_status: "active" }, + }, + conversation_metadata: { + history: [ + { author: "user", body: "I need help", timestamp: "2025-01-24T10:00:01Z" }, + { author: "agent", body: "What do you need help with?", timestamp: "2025-01-24T10:01:00Z" }, + ], + attributes: { priority_level: "high", department: "sales" }, + }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + attributes: { + plan_type: "Pro", + subscription_status: "active", + }, + }, + conversation_metadata: { + history: [ + { + author: "user", + body: "I need help", + timestamp: "2025-01-24T10:00:01Z", + }, + { + author: "agent", + body: "What do you need help with?", + timestamp: "2025-01-24T10:01:00Z", + }, + ], + attributes: { + priority_level: "high", + department: "sales", + }, + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "Here is a screenshot of the issue", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + attachments: [ + { type: "url", url: "https://example.com/document.pdf" }, + { + type: "file", + name: "screenshot.png", + content_type: "image/png", + data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...", + }, + ], + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "Here is a screenshot of the issue", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + attachments: [ + { + type: "url", + url: "https://example.com/document.pdf", + }, + { + type: "file", + name: "screenshot.png", + content_type: "image/png", + data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...", + }, + ], + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How can I see my account details?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "ext-123", + message: { author: "user", body: "How can I see my account details?", timestamp: "2025-01-24T10:01:20Z" }, + user: { id: "123456", name: "John Doe", email: "john.doe@example.com" }, + }; + const rawResponseBody = { + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { attributes: { invalid_attr: "User attribute 'invalid_attr' does not exist" } }, + conversation: { attributes: { bad_attr: "Conversation attribute 'bad_attr' does not exist" } }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.finAgent.startFinConversation({ + conversation_id: "ext-123", + message: { + author: "user", + body: "How can I see my account details?", + timestamp: "2025-01-24T10:01:20Z", + }, + user: { + id: "123456", + name: "John Doe", + email: "john.doe@example.com", + }, + }); + expect(response).toEqual({ + conversation_id: "ext-123", + user_id: "user-456", + status: "thinking", + created_at_ms: "2025-01-24T10:00:00Z", + errors: { + user: { + attributes: { + invalid_attr: "User attribute 'invalid_attr' does not exist", + }, + }, + conversation: { + attributes: { + bad_attr: "Conversation attribute 'bad_attr' does not exist", + }, + }, + }, + sse_subscription_url: + "https://primary-realtime.intercom-messenger.com/event-stream?channels=fin_agent_api:app123:ext-123&accessToken=eyJhbG...&rewind=2m", + }); + }); + + test("startFinConversation (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body" }, + user: { id: "id" }, + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.startFinConversation({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("startFinConversation (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + conversation_id: "conversation_id", + message: { author: "user", body: "body" }, + user: { id: "id" }, + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/fin/start") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.finAgent.startFinConversation({ + conversation_id: "conversation_id", + message: { + author: "user", + body: "body", + }, + user: { + id: "id", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); +}); diff --git a/tests/wire/preview/folders.test.ts b/tests/wire/preview/folders.test.ts new file mode 100644 index 00000000..99399f1d --- /dev/null +++ b/tests/wire/preview/folders.test.ts @@ -0,0 +1,477 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("FoldersClient", () => { + test("listFolders (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + id: 6, + name: "Product Documentation", + description: "Internal product docs", + emoji: "📚", + parent_folder_id: 1, + content_count: 5, + created_at: 1672928359, + updated_at: 1672928610, + }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 50, + total_pages: 1, + }, + }; + server.mockEndpoint().get("/folders").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.folders.listFolders({ + page: 1, + per_page: 50, + parent_folder_id: 1, + }); + expect(response).toEqual({ + type: "list", + data: [ + { + id: 6, + name: "Product Documentation", + description: "Internal product docs", + emoji: "\uD83D\uDCDA", + parent_folder_id: 1, + content_count: 5, + created_at: 1672928359, + updated_at: 1672928610, + }, + ], + total_count: 1, + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 50, + total_pages: 1, + }, + }); + }); + + test("listFolders (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/folders").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.folders.listFolders(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createFolder (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + folder: { name: "Product Documentation", description: "Internal product docs", emoji: "📚" }, + }; + const rawResponseBody = { + id: 6, + name: "Product Documentation", + description: "Internal product docs", + emoji: "📚", + parent_folder_id: 1, + content_count: 0, + created_at: 1672928359, + updated_at: 1672928359, + }; + server + .mockEndpoint() + .post("/folders") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.folders.createFolder({ + folder: { + name: "Product Documentation", + description: "Internal product docs", + emoji: "\uD83D\uDCDA", + }, + }); + expect(response).toEqual({ + id: 6, + name: "Product Documentation", + description: "Internal product docs", + emoji: "\uD83D\uDCDA", + parent_folder_id: 1, + content_count: 0, + created_at: 1672928359, + updated_at: 1672928359, + }); + }); + + test("createFolder (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { folder: { name: "name" } }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/folders") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.folders.createFolder({ + folder: { + name: "name", + }, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("createFolder (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { folder: { name: "name" } }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/folders") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.folders.createFolder({ + folder: { + name: "name", + }, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveFolder (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: 6, + name: "Product Documentation", + description: "Internal product docs", + emoji: "📚", + parent_folder_id: 1, + content_count: 5, + created_at: 1672928359, + updated_at: 1672928610, + }; + server.mockEndpoint().get("/folders/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.folders.retrieveFolder({ + id: 1, + }); + expect(response).toEqual({ + id: 6, + name: "Product Documentation", + description: "Internal product docs", + emoji: "\uD83D\uDCDA", + parent_folder_id: 1, + content_count: 5, + created_at: 1672928359, + updated_at: 1672928610, + }); + }); + + test("retrieveFolder (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/folders/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.folders.retrieveFolder({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveFolder (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/folders/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.folders.retrieveFolder({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateFolder (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { folder: { name: "Updated Product Documentation", emoji: "📖" } }; + const rawResponseBody = { + id: 6, + name: "Updated Product Documentation", + description: "Internal product docs", + emoji: "📖", + parent_folder_id: 1, + content_count: 5, + created_at: 1672928359, + updated_at: 1672928900, + }; + server + .mockEndpoint() + .put("/folders/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.folders.updateFolder({ + id: 1, + folder: { + name: "Updated Product Documentation", + emoji: "\uD83D\uDCD6", + }, + }); + expect(response).toEqual({ + id: 6, + name: "Updated Product Documentation", + description: "Internal product docs", + emoji: "\uD83D\uDCD6", + parent_folder_id: 1, + content_count: 5, + created_at: 1672928359, + updated_at: 1672928900, + }); + }); + + test("updateFolder (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { folder: {} }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/folders/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.folders.updateFolder({ + id: 1, + folder: {}, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("updateFolder (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { folder: {} }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/folders/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.folders.updateFolder({ + id: 1, + folder: {}, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateFolder (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { folder: {} }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/folders/1") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.folders.updateFolder({ + id: 1, + folder: {}, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteFolder (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: 6, object: "folder", deleted: true }; + server.mockEndpoint().delete("/folders/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.folders.deleteFolder({ + id: 1, + }); + expect(response).toEqual({ + id: 6, + object: "folder", + deleted: true, + }); + }); + + test("deleteFolder (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/folders/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.folders.deleteFolder({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteFolder (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().delete("/folders/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.folders.deleteFolder({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteFolder (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().delete("/folders/1").respondWith().statusCode(422).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.folders.deleteFolder({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); +}); diff --git a/tests/wire/unstable/helpCenter.test.ts b/tests/wire/preview/helpCenter.test.ts similarity index 79% rename from tests/wire/unstable/helpCenter.test.ts rename to tests/wire/preview/helpCenter.test.ts index 7e4acacd..074a2c77 100644 --- a/tests/wire/unstable/helpCenter.test.ts +++ b/tests/wire/preview/helpCenter.test.ts @@ -5,6 +5,538 @@ import { IntercomClient } from "../../../src/Client"; import { mockServerPool } from "../../mock-server/MockServerPool"; describe("HelpCenterClient", () => { + test("listHelpCenterRedirects (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + pages: { + type: "pages", + page: 1, + next: { per_page: 2, starting_after: "your-cursor-from-response" }, + per_page: 50, + total_pages: 1, + }, + total_count: 1, + data: [ + { + id: "26", + type: "help_center_redirect", + from_url: "http://help-center.test/lovelyhelpcenter/legacy-page", + locale: "en", + help_center_id: "7", + target_type: "article", + target_id: "11", + created_at: 1781619405, + updated_at: 1781619405, + }, + ], + }; + server + .mockEndpoint() + .get("/help_center/help_centers/123/redirects") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.helpCenter.listHelpCenterRedirects({ + help_center_id: "123", + page: 1, + per_page: 1, + }); + expect(response).toEqual({ + type: "list", + pages: { + type: "pages", + page: 1, + next: { + per_page: 2, + starting_after: "your-cursor-from-response", + }, + per_page: 50, + total_pages: 1, + }, + total_count: 1, + data: [ + { + id: "26", + type: "help_center_redirect", + from_url: "http://help-center.test/lovelyhelpcenter/legacy-page", + locale: "en", + help_center_id: "7", + target_type: "article", + target_id: "11", + created_at: 1781619405, + updated_at: 1781619405, + }, + ], + }); + }); + + test("listHelpCenterRedirects (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/help_center/help_centers/help_center_id/redirects") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.listHelpCenterRedirects({ + help_center_id: "help_center_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listHelpCenterRedirects (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/help_center/help_centers/help_center_id/redirects") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.listHelpCenterRedirects({ + help_center_id: "help_center_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("createHelpCenterRedirect (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + from_url: "http://help-center.test/lovelyhelpcenter/old-page", + locale: "en", + target_type: "article", + target_id: "11", + }; + const rawResponseBody = { + id: "26", + type: "help_center_redirect", + from_url: "http://help-center.test/lovelyhelpcenter/old-page", + locale: "en", + help_center_id: "7", + target_type: "article", + target_id: "11", + created_at: 1781619405, + updated_at: 1781619405, + }; + server + .mockEndpoint() + .post("/help_center/help_centers/123/redirects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.helpCenter.createHelpCenterRedirect({ + help_center_id: "123", + from_url: "http://help-center.test/lovelyhelpcenter/old-page", + locale: "en", + target_type: "article", + target_id: "11", + }); + expect(response).toEqual({ + id: "26", + type: "help_center_redirect", + from_url: "http://help-center.test/lovelyhelpcenter/old-page", + locale: "en", + help_center_id: "7", + target_type: "article", + target_id: "11", + created_at: 1781619405, + updated_at: 1781619405, + }); + }); + + test("createHelpCenterRedirect (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/help_center/help_centers/help_center_id/redirects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.createHelpCenterRedirect({ + help_center_id: "help_center_id", + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("createHelpCenterRedirect (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/help_center/help_centers/help_center_id/redirects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.createHelpCenterRedirect({ + help_center_id: "help_center_id", + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createHelpCenterRedirect (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/help_center/help_centers/help_center_id/redirects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.createHelpCenterRedirect({ + help_center_id: "help_center_id", + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("createHelpCenterRedirect (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/help_center/help_centers/help_center_id/redirects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.createHelpCenterRedirect({ + help_center_id: "help_center_id", + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }); + }).rejects.toThrow(Intercom.preview.ConflictError); + }); + + test("createHelpCenterRedirect (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/help_center/help_centers/help_center_id/redirects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.createHelpCenterRedirect({ + help_center_id: "help_center_id", + from_url: "from_url", + locale: "locale", + target_type: "article", + target_id: "target_id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("retrieveHelpCenterRedirect (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "26", + type: "help_center_redirect", + from_url: "http://help-center.test/lovelyhelpcenter/old-page", + locale: "en", + help_center_id: "7", + target_type: "article", + target_id: "11", + created_at: 1781619405, + updated_at: 1781619405, + }; + server + .mockEndpoint() + .get("/help_center/help_centers/123/redirects/26") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.helpCenter.retrieveHelpCenterRedirect({ + help_center_id: "123", + id: "26", + }); + expect(response).toEqual({ + id: "26", + type: "help_center_redirect", + from_url: "http://help-center.test/lovelyhelpcenter/old-page", + locale: "en", + help_center_id: "7", + target_type: "article", + target_id: "11", + created_at: 1781619405, + updated_at: 1781619405, + }); + }); + + test("retrieveHelpCenterRedirect (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/help_center/help_centers/help_center_id/redirects/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.retrieveHelpCenterRedirect({ + help_center_id: "help_center_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveHelpCenterRedirect (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/help_center/help_centers/help_center_id/redirects/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.retrieveHelpCenterRedirect({ + help_center_id: "help_center_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteHelpCenterRedirect (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "26", object: "help_center_redirect", deleted: true }; + server + .mockEndpoint() + .delete("/help_center/help_centers/123/redirects/26") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.helpCenter.deleteHelpCenterRedirect({ + help_center_id: "123", + id: "26", + }); + expect(response).toEqual({ + id: "26", + object: "help_center_redirect", + deleted: true, + }); + }); + + test("deleteHelpCenterRedirect (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/help_center/help_centers/help_center_id/redirects/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.deleteHelpCenterRedirect({ + help_center_id: "help_center_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteHelpCenterRedirect (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/help_center/help_centers/help_center_id/redirects/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.helpCenter.deleteHelpCenterRedirect({ + help_center_id: "help_center_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + test("listAllCollections (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ @@ -63,7 +595,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.listAllCollections(); + const response = await client.preview.helpCenter.listAllCollections(); expect(response).toEqual({ type: "list", pages: { @@ -129,8 +661,8 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.listAllCollections(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.helpCenter.listAllCollections(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createCollection (1)", async () => { @@ -205,7 +737,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.createCollection({ + const response = await client.preview.helpCenter.createCollection({ name: "Thanks for everything", }); expect(response).toEqual({ @@ -484,7 +1016,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.createCollection({ + const response = await client.preview.helpCenter.createCollection({ name: "collection 51", description: "Missing required parameter", }); @@ -712,10 +1244,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.createCollection({ + return await client.preview.helpCenter.createCollection({ name: "name", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("createCollection (4)", async () => { @@ -738,10 +1270,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.createCollection({ + return await client.preview.helpCenter.createCollection({ name: "name", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveCollection (1)", async () => { @@ -815,7 +1347,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.retrieveCollection({ + const response = await client.preview.helpCenter.retrieveCollection({ id: 1, }); expect(response).toEqual({ @@ -1041,10 +1573,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.retrieveCollection({ + return await client.preview.helpCenter.retrieveCollection({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveCollection (3)", async () => { @@ -1066,10 +1598,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.retrieveCollection({ + return await client.preview.helpCenter.retrieveCollection({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("updateCollection (1)", async () => { @@ -1144,7 +1676,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.updateCollection({ + const response = await client.preview.helpCenter.updateCollection({ id: 1, name: "Update collection name", }); @@ -1424,7 +1956,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.updateCollection({ + const response = await client.preview.helpCenter.updateCollection({ id: 1, name: "Update collection name", }); @@ -1652,10 +2184,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.updateCollection({ + return await client.preview.helpCenter.updateCollection({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateCollection (4)", async () => { @@ -1678,10 +2210,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.updateCollection({ + return await client.preview.helpCenter.updateCollection({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("deleteCollection (1)", async () => { @@ -1702,7 +2234,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.deleteCollection({ + const response = await client.preview.helpCenter.deleteCollection({ id: 1, }); expect(response).toEqual({ @@ -1731,10 +2263,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.deleteCollection({ + return await client.preview.helpCenter.deleteCollection({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteCollection (3)", async () => { @@ -1756,10 +2288,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.deleteCollection({ + return await client.preview.helpCenter.deleteCollection({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("retrieveHelpCenter (1)", async () => { @@ -1781,6 +2313,8 @@ describe("HelpCenterClient", () => { display_name: "Intercom Help Center", url: "https://help.mycompany.com", custom_domain: "help.mycompany.com", + default: false, + locales: ["en"], }; server .mockEndpoint() @@ -1790,7 +2324,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.retrieveHelpCenter({ + const response = await client.preview.helpCenter.retrieveHelpCenter({ id: 1, }); expect(response).toEqual({ @@ -1803,6 +2337,8 @@ describe("HelpCenterClient", () => { display_name: "Intercom Help Center", url: "https://help.mycompany.com", custom_domain: "help.mycompany.com", + default: false, + locales: ["en"], }); }); @@ -1825,10 +2361,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.retrieveHelpCenter({ + return await client.preview.helpCenter.retrieveHelpCenter({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveHelpCenter (3)", async () => { @@ -1850,10 +2386,10 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.retrieveHelpCenter({ + return await client.preview.helpCenter.retrieveHelpCenter({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("listHelpCenters (1)", async () => { @@ -1878,6 +2414,8 @@ describe("HelpCenterClient", () => { display_name: "Intercom Help Center", url: "https://help.mycompany.com", custom_domain: "help.mycompany.com", + default: false, + locales: ["en", "fr"], }, ], }; @@ -1889,7 +2427,7 @@ describe("HelpCenterClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.helpCenter.listHelpCenters(); + const response = await client.preview.helpCenter.listHelpCenters(); expect(response).toEqual({ type: "list", data: [ @@ -1903,6 +2441,8 @@ describe("HelpCenterClient", () => { display_name: "Intercom Help Center", url: "https://help.mycompany.com", custom_domain: "help.mycompany.com", + default: false, + locales: ["en", "fr"], }, ], }); @@ -1927,7 +2467,7 @@ describe("HelpCenterClient", () => { .build(); await expect(async () => { - return await client.unstable.helpCenter.listHelpCenters(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.helpCenter.listHelpCenters(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/preview/identityVerificationSecrets.test.ts b/tests/wire/preview/identityVerificationSecrets.test.ts new file mode 100644 index 00000000..5b94ac46 --- /dev/null +++ b/tests/wire/preview/identityVerificationSecrets.test.ts @@ -0,0 +1,292 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("IdentityVerificationSecretsClient", () => { + test("listIdentityVerificationSecrets (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "list", + data: [ + { + type: "identity_verification_secret", + id: "102", + name: "Production Web", + supports_android: false, + supports_ios: false, + supports_web: true, + created_at: 1734537243, + }, + ], + }; + server + .mockEndpoint() + .get("/secure_mode_secrets") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.identityVerificationSecrets.listIdentityVerificationSecrets(); + expect(response).toEqual({ + type: "list", + data: [ + { + type: "identity_verification_secret", + id: "102", + name: "Production Web", + supports_android: false, + supports_ios: false, + supports_web: true, + created_at: 1734537243, + }, + ], + }); + }); + + test("listIdentityVerificationSecrets (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/secure_mode_secrets") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.identityVerificationSecrets.listIdentityVerificationSecrets(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createIdentityVerificationSecret (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "Production Web", supports_web: true }; + const rawResponseBody = { + type: "identity_verification_secret", + id: "103", + name: "Production Web", + supports_android: false, + supports_ios: false, + supports_web: true, + created_at: 1734537500, + secret: "9Zw0xNs3vKk0fPz9rwKqNbzH3mPVQmQxL9vhSm9Tk4A", + }; + server + .mockEndpoint() + .post("/secure_mode_secrets") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.identityVerificationSecrets.createIdentityVerificationSecret({ + name: "Production Web", + supports_web: true, + }); + expect(response).toEqual({ + type: "identity_verification_secret", + id: "103", + name: "Production Web", + supports_android: false, + supports_ios: false, + supports_web: true, + created_at: 1734537500, + secret: "9Zw0xNs3vKk0fPz9rwKqNbzH3mPVQmQxL9vhSm9Tk4A", + }); + }); + + test("createIdentityVerificationSecret (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + name: "Production all-platform", + supports_android: true, + supports_ios: true, + supports_web: true, + }; + const rawResponseBody = { + type: "identity_verification_secret", + id: "103", + name: "Production Web", + supports_android: false, + supports_ios: false, + supports_web: true, + created_at: 1734537500, + secret: "9Zw0xNs3vKk0fPz9rwKqNbzH3mPVQmQxL9vhSm9Tk4A", + }; + server + .mockEndpoint() + .post("/secure_mode_secrets") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.identityVerificationSecrets.createIdentityVerificationSecret({ + name: "Production all-platform", + supports_android: true, + supports_ios: true, + supports_web: true, + }); + expect(response).toEqual({ + type: "identity_verification_secret", + id: "103", + name: "Production Web", + supports_android: false, + supports_ios: false, + supports_web: true, + created_at: 1734537500, + secret: "9Zw0xNs3vKk0fPz9rwKqNbzH3mPVQmQxL9vhSm9Tk4A", + }); + }); + + test("createIdentityVerificationSecret (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/secure_mode_secrets") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.identityVerificationSecrets.createIdentityVerificationSecret({ + name: "name", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createIdentityVerificationSecret (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/secure_mode_secrets") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.identityVerificationSecrets.createIdentityVerificationSecret({ + name: "name", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("deleteIdentityVerificationSecret (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/secure_mode_secrets/102").respondWith().statusCode(200).build(); + + const response = await client.preview.identityVerificationSecrets.deleteIdentityVerificationSecret({ + id: "102", + }); + expect(response).toEqual(undefined); + }); + + test("deleteIdentityVerificationSecret (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/secure_mode_secrets/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.identityVerificationSecrets.deleteIdentityVerificationSecret({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteIdentityVerificationSecret (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/secure_mode_secrets/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.identityVerificationSecrets.deleteIdentityVerificationSecret({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); +}); diff --git a/tests/wire/unstable/internalArticles.test.ts b/tests/wire/preview/internalArticles.test.ts similarity index 52% rename from tests/wire/unstable/internalArticles.test.ts rename to tests/wire/preview/internalArticles.test.ts index b8d9b058..7e162a34 100644 --- a/tests/wire/unstable/internalArticles.test.ts +++ b/tests/wire/preview/internalArticles.test.ts @@ -30,17 +30,23 @@ describe("InternalArticlesClient", () => { id: "39", title: "Thanks for everything", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, }, ], }; server.mockEndpoint().get("/internal_articles").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.internalArticles.listInternalArticles(); + const response = await client.preview.internalArticles.listInternalArticles(); expect(response).toEqual({ type: "list", pages: { @@ -60,11 +66,17 @@ describe("InternalArticlesClient", () => { id: "39", title: "Thanks for everything", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, }, ], }); @@ -83,8 +95,8 @@ describe("InternalArticlesClient", () => { server.mockEndpoint().get("/internal_articles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.internalArticles.listInternalArticles(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.internalArticles.listInternalArticles(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createInternalArticle (1)", async () => { @@ -100,17 +112,25 @@ describe("InternalArticlesClient", () => { body: "Body of the Article", author_id: 991266252, owner_id: 991266252, + audience_ids: [1, 2], }; const rawResponseBody = { type: "internal_article", id: "42", title: "Thanks for everything", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, }; server .mockEndpoint() @@ -121,22 +141,40 @@ describe("InternalArticlesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.internalArticles.createInternalArticle({ + const response = await client.preview.internalArticles.createInternalArticle({ title: "Thanks for everything", body: "Body of the Article", author_id: 991266252, owner_id: 991266252, + audience_ids: [1, 2], }); expect(response).toEqual({ type: "internal_article", id: "42", title: "Thanks for everything", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, }); }); @@ -159,11 +197,18 @@ describe("InternalArticlesClient", () => { id: "42", title: "Thanks for everything", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, }; server .mockEndpoint() @@ -174,7 +219,7 @@ describe("InternalArticlesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.internalArticles.createInternalArticle({ + const response = await client.preview.internalArticles.createInternalArticle({ title: "Thanks for everything", body: "Body of the Internal Article", author_id: 1295, @@ -185,11 +230,28 @@ describe("InternalArticlesClient", () => { id: "42", title: "Thanks for everything", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, }); }); @@ -212,8 +274,8 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.createInternalArticle(undefined); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + return await client.preview.internalArticles.createInternalArticle(undefined); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("createInternalArticle (4)", async () => { @@ -235,8 +297,31 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.createInternalArticle(undefined); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.internalArticles.createInternalArticle(undefined); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createInternalArticle (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/internal_articles") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.internalArticles.createInternalArticle(undefined); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("retrieveInternalArticle (1)", async () => { @@ -253,11 +338,18 @@ describe("InternalArticlesClient", () => { id: "45", title: "title", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, }; server .mockEndpoint() @@ -267,7 +359,7 @@ describe("InternalArticlesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.internalArticles.retrieveInternalArticle({ + const response = await client.preview.internalArticles.retrieveInternalArticle({ id: 1, }); expect(response).toEqual({ @@ -275,11 +367,28 @@ describe("InternalArticlesClient", () => { id: "45", title: "title", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, }); }); @@ -302,10 +411,10 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.retrieveInternalArticle({ + return await client.preview.internalArticles.retrieveInternalArticle({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveInternalArticle (3)", async () => { @@ -327,10 +436,10 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.retrieveInternalArticle({ + return await client.preview.internalArticles.retrieveInternalArticle({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("updateInternalArticle (1)", async () => { @@ -341,17 +450,28 @@ describe("InternalArticlesClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { title: "Christmas is here!", body: "

New gifts in store for the jolly season

" }; + const rawRequestBody = { + title: "Christmas is here!", + body: "

New gifts in store for the jolly season

", + audience_ids: [1, 2], + }; const rawResponseBody = { type: "internal_article", id: "48", title: "title", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, }; server .mockEndpoint() @@ -362,21 +482,39 @@ describe("InternalArticlesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.internalArticles.updateInternalArticle({ + const response = await client.preview.internalArticles.updateInternalArticle({ id: 1, title: "Christmas is here!", body: "

New gifts in store for the jolly season

", + audience_ids: [1, 2], }); expect(response).toEqual({ type: "internal_article", id: "48", title: "title", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, }); }); @@ -394,11 +532,18 @@ describe("InternalArticlesClient", () => { id: "48", title: "title", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, }; server .mockEndpoint() @@ -409,7 +554,7 @@ describe("InternalArticlesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.internalArticles.updateInternalArticle({ + const response = await client.preview.internalArticles.updateInternalArticle({ id: 1, title: "Christmas is here!", body: "

New gifts in store for the jolly season

", @@ -419,11 +564,28 @@ describe("InternalArticlesClient", () => { id: "48", title: "title", body: "Body of the Article", + body_markdown: "Body of the Article\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 6, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, }); }); @@ -447,10 +609,10 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.updateInternalArticle({ + return await client.preview.internalArticles.updateInternalArticle({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateInternalArticle (4)", async () => { @@ -473,10 +635,10 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.updateInternalArticle({ + return await client.preview.internalArticles.updateInternalArticle({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("deleteInternalArticle (1)", async () => { @@ -497,7 +659,7 @@ describe("InternalArticlesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.internalArticles.deleteInternalArticle({ + const response = await client.preview.internalArticles.deleteInternalArticle({ id: 1, }); expect(response).toEqual({ @@ -526,10 +688,10 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.deleteInternalArticle({ + return await client.preview.internalArticles.deleteInternalArticle({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteInternalArticle (3)", async () => { @@ -551,10 +713,250 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.deleteInternalArticle({ + return await client.preview.internalArticles.deleteInternalArticle({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("attachTagToInternalArticle (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "7522907" }; + const rawResponseBody = { + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { type: "admin", id: "1234" }, + }; + server + .mockEndpoint() + .post("/internal_articles/1/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.internalArticles.attachTagToInternalArticle({ + internal_article_id: 1, + id: "7522907", + }); + expect(response).toEqual({ + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { + type: "admin", + id: "1234", + }, + }); + }); + + test("attachTagToInternalArticle (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/internal_articles/1/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.internalArticles.attachTagToInternalArticle({ + internal_article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("attachTagToInternalArticle (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/internal_articles/1/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.internalArticles.attachTagToInternalArticle({ + internal_article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("attachTagToInternalArticle (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { id: "id" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/internal_articles/1/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.internalArticles.attachTagToInternalArticle({ + internal_article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("detachTagFromInternalArticle (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { type: "contact", id: "1a2b3c" }, + }; + server + .mockEndpoint() + .delete("/internal_articles/1/tags/7522907") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.internalArticles.detachTagFromInternalArticle({ + internal_article_id: 1, + id: "7522907", + }); + expect(response).toEqual({ + type: "tag", + id: "7522907", + name: "Independent", + applied_at: 1663597223, + applied_by: { + type: "contact", + id: "1a2b3c", + }, + }); + }); + + test("detachTagFromInternalArticle (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/internal_articles/1/tags/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.internalArticles.detachTagFromInternalArticle({ + internal_article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("detachTagFromInternalArticle (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/internal_articles/1/tags/id") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.internalArticles.detachTagFromInternalArticle({ + internal_article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("detachTagFromInternalArticle (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/internal_articles/1/tags/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.internalArticles.detachTagFromInternalArticle({ + internal_article_id: 1, + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("searchInternalArticles (1)", async () => { @@ -574,11 +976,17 @@ describe("InternalArticlesClient", () => { { id: "55", body: "Body of the Article", + body_markdown: "# Internal Guide\n\nBody of the article in markdown\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 123, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, }, ], }, @@ -598,8 +1006,8 @@ describe("InternalArticlesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.internalArticles.searchInternalArticles({ - folder_id: "folder_id", + const response = await client.preview.internalArticles.searchInternalArticles({ + folder_id: 1, }); expect(response).toEqual({ type: "list", @@ -609,11 +1017,17 @@ describe("InternalArticlesClient", () => { { id: "55", body: "Body of the Article", + body_markdown: "# Internal Guide\n\nBody of the article in markdown\n", owner_id: 991266252, author_id: 991266252, created_at: 1672928359, updated_at: 1672928610, locale: "en", + folder_id: 123, + audience_ids: [1, 2], + ai_chatbot_availability: true, + ai_copilot_availability: true, + ai_sales_agent_availability: true, }, ], }, @@ -649,7 +1063,7 @@ describe("InternalArticlesClient", () => { .build(); await expect(async () => { - return await client.unstable.internalArticles.searchInternalArticles(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.internalArticles.searchInternalArticles(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/jobs.test.ts b/tests/wire/preview/jobs.test.ts similarity index 89% rename from tests/wire/unstable/jobs.test.ts rename to tests/wire/preview/jobs.test.ts index 7e511aee..b7802b1a 100644 --- a/tests/wire/unstable/jobs.test.ts +++ b/tests/wire/preview/jobs.test.ts @@ -25,7 +25,7 @@ describe("JobsClient", () => { }; server.mockEndpoint().get("/jobs/status/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.jobs.status({ + const response = await client.preview.jobs.status({ id: "id", }); expect(response).toEqual({ @@ -52,10 +52,10 @@ describe("JobsClient", () => { server.mockEndpoint().get("/jobs/status/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.jobs.status({ + return await client.preview.jobs.status({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("status (3)", async () => { @@ -71,9 +71,9 @@ describe("JobsClient", () => { server.mockEndpoint().get("/jobs/status/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.jobs.status({ + return await client.preview.jobs.status({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/unstable/macros.test.ts b/tests/wire/preview/macros.test.ts similarity index 95% rename from tests/wire/unstable/macros.test.ts rename to tests/wire/preview/macros.test.ts index 04168725..d1b21b6a 100644 --- a/tests/wire/unstable/macros.test.ts +++ b/tests/wire/preview/macros.test.ts @@ -46,7 +46,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.listMacros({ + const response = await client.preview.macros.listMacros({ per_page: 1, starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", updated_since: 1000000, @@ -132,7 +132,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.listMacros({ + const response = await client.preview.macros.listMacros({ per_page: 1, starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", updated_since: 1000000, @@ -207,7 +207,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.listMacros({ + const response = await client.preview.macros.listMacros({ per_page: 1, starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", updated_since: 1000000, @@ -269,7 +269,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.listMacros({ + const response = await client.preview.macros.listMacros({ per_page: 1, starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", updated_since: 1000000, @@ -330,7 +330,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.listMacros({ + const response = await client.preview.macros.listMacros({ per_page: 1, starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", updated_since: 1000000, @@ -390,7 +390,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.listMacros({ + const response = await client.preview.macros.listMacros({ per_page: 1, starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", updated_since: 1000000, @@ -434,8 +434,8 @@ describe("MacrosClient", () => { server.mockEndpoint().get("/macros").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.macros.listMacros(); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + return await client.preview.macros.listMacros(); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("listMacros (8)", async () => { @@ -451,8 +451,8 @@ describe("MacrosClient", () => { server.mockEndpoint().get("/macros").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.macros.listMacros(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.macros.listMacros(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("listMacros (9)", async () => { @@ -468,8 +468,8 @@ describe("MacrosClient", () => { server.mockEndpoint().get("/macros").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.macros.listMacros(); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); + return await client.preview.macros.listMacros(); + }).rejects.toThrow(Intercom.preview.ForbiddenError); }); test("getMacro (1)", async () => { @@ -496,7 +496,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.getMacro({ + const response = await client.preview.macros.getMacro({ id: "123", }); expect(response).toEqual({ @@ -538,7 +538,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.getMacro({ + const response = await client.preview.macros.getMacro({ id: "123", }); expect(response).toEqual({ @@ -580,7 +580,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.getMacro({ + const response = await client.preview.macros.getMacro({ id: "123", }); expect(response).toEqual({ @@ -622,7 +622,7 @@ describe("MacrosClient", () => { }; server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.macros.getMacro({ + const response = await client.preview.macros.getMacro({ id: "123", }); expect(response).toEqual({ @@ -653,10 +653,10 @@ describe("MacrosClient", () => { server.mockEndpoint().get("/macros/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.macros.getMacro({ + return await client.preview.macros.getMacro({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("getMacro (6)", async () => { @@ -672,10 +672,10 @@ describe("MacrosClient", () => { server.mockEndpoint().get("/macros/id").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.macros.getMacro({ + return await client.preview.macros.getMacro({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); + }).rejects.toThrow(Intercom.preview.ForbiddenError); }); test("getMacro (7)", async () => { @@ -691,9 +691,9 @@ describe("MacrosClient", () => { server.mockEndpoint().get("/macros/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.macros.getMacro({ + return await client.preview.macros.getMacro({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/unstable/messages.test.ts b/tests/wire/preview/messages.test.ts similarity index 76% rename from tests/wire/unstable/messages.test.ts rename to tests/wire/preview/messages.test.ts index 7b0b98a4..6bdc281d 100644 --- a/tests/wire/unstable/messages.test.ts +++ b/tests/wire/preview/messages.test.ts @@ -36,7 +36,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "user", id: "6762f2341bb69f9f2193bc17", @@ -86,7 +86,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "lead", id: "6762f2371bb69f9f2193bc18", @@ -146,7 +146,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "admin", id: "991267816", @@ -227,7 +227,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "admin", id: "991267817", @@ -284,7 +284,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "admin", id: "991267817", @@ -351,7 +351,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "admin", id: "991267818", @@ -406,7 +406,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "admin", id: "991267819", @@ -461,7 +461,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "admin", id: "991267820", @@ -516,7 +516,7 @@ describe("MessagesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.messages.createMessage({ + const response = await client.preview.messages.createMessage({ from: { type: "admin", id: "991267821", @@ -552,8 +552,8 @@ describe("MessagesClient", () => { server.mockEndpoint().post("/messages").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.messages.createMessage(undefined); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + return await client.preview.messages.createMessage(undefined); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("createMessage (11)", async () => { @@ -569,8 +569,8 @@ describe("MessagesClient", () => { server.mockEndpoint().post("/messages").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.messages.createMessage(undefined); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.messages.createMessage(undefined); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createMessage (12)", async () => { @@ -586,8 +586,8 @@ describe("MessagesClient", () => { server.mockEndpoint().post("/messages").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.messages.createMessage(undefined); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); + return await client.preview.messages.createMessage(undefined); + }).rejects.toThrow(Intercom.preview.ForbiddenError); }); test("createMessage (13)", async () => { @@ -603,8 +603,8 @@ describe("MessagesClient", () => { server.mockEndpoint().post("/messages").respondWith().statusCode(422).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.messages.createMessage(undefined); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); + return await client.preview.messages.createMessage(undefined); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); }); test("getWhatsAppMessageStatus (1)", async () => { @@ -646,7 +646,7 @@ describe("MessagesClient", () => { }; server.mockEndpoint().get("/messages/status").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.messages.getWhatsAppMessageStatus({ + const response = await client.preview.messages.getWhatsAppMessageStatus({ ruleset_id: "ruleset_id", per_page: 1, starting_after: "starting_after", @@ -701,10 +701,10 @@ describe("MessagesClient", () => { server.mockEndpoint().get("/messages/status").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.messages.getWhatsAppMessageStatus({ + return await client.preview.messages.getWhatsAppMessageStatus({ ruleset_id: "ruleset_id", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("getWhatsAppMessageStatus (3)", async () => { @@ -720,10 +720,10 @@ describe("MessagesClient", () => { server.mockEndpoint().get("/messages/status").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.messages.getWhatsAppMessageStatus({ + return await client.preview.messages.getWhatsAppMessageStatus({ ruleset_id: "ruleset_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("getWhatsAppMessageStatus (4)", async () => { @@ -739,10 +739,10 @@ describe("MessagesClient", () => { server.mockEndpoint().get("/messages/status").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.messages.getWhatsAppMessageStatus({ + return await client.preview.messages.getWhatsAppMessageStatus({ ruleset_id: "ruleset_id", }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); + }).rejects.toThrow(Intercom.preview.ForbiddenError); }); test("getWhatsAppMessageStatus (5)", async () => { @@ -758,9 +758,174 @@ describe("MessagesClient", () => { server.mockEndpoint().get("/messages/status").respondWith().statusCode(500).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.messages.getWhatsAppMessageStatus({ + return await client.preview.messages.getWhatsAppMessageStatus({ ruleset_id: "ruleset_id", }); - }).rejects.toThrow(Intercom.unstable.InternalServerError); + }).rejects.toThrow(Intercom.preview.InternalServerError); + }); + + test("RetrieveWhatsAppMessageStatus (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + conversation_id: "123456789", + status: "delivered", + type: "broadcast_outbound", + created_at: 1734537980, + updated_at: 1734538000, + template_name: "appointment_reminder", + message_id: "wamid_abc123", + error: { message: "message", details: "details" }, + }; + server + .mockEndpoint() + .get("/messages/whatsapp/status") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.messages.retrieveWhatsAppMessageStatus({ + message_id: "message_id", + }); + expect(response).toEqual({ + conversation_id: "123456789", + status: "delivered", + type: "broadcast_outbound", + created_at: 1734537980, + updated_at: 1734538000, + template_name: "appointment_reminder", + message_id: "wamid_abc123", + error: { + message: "message", + details: "details", + }, + }); + }); + + test("RetrieveWhatsAppMessageStatus (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + conversation_id: "123456789", + status: "failed", + type: "broadcast_outbound", + created_at: 1734537980, + updated_at: 1734538000, + template_name: "appointment_reminder", + message_id: "wamid_abc123", + error: { message: "Message delivery failed", details: "Recipient phone number not on WhatsApp" }, + }; + server + .mockEndpoint() + .get("/messages/whatsapp/status") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.messages.retrieveWhatsAppMessageStatus({ + message_id: "message_id", + }); + expect(response).toEqual({ + conversation_id: "123456789", + status: "failed", + type: "broadcast_outbound", + created_at: 1734537980, + updated_at: 1734538000, + template_name: "appointment_reminder", + message_id: "wamid_abc123", + error: { + message: "Message delivery failed", + details: "Recipient phone number not on WhatsApp", + }, + }); + }); + + test("RetrieveWhatsAppMessageStatus (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/messages/whatsapp/status") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.messages.retrieveWhatsAppMessageStatus({ + message_id: "message_id", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("RetrieveWhatsAppMessageStatus (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/messages/whatsapp/status") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.messages.retrieveWhatsAppMessageStatus({ + message_id: "message_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("RetrieveWhatsAppMessageStatus (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/messages/whatsapp/status") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.messages.retrieveWhatsAppMessageStatus({ + message_id: "message_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/unstable/news.test.ts b/tests/wire/preview/news.test.ts similarity index 93% rename from tests/wire/unstable/news.test.ts rename to tests/wire/preview/news.test.ts index 6ee5092f..98c27641 100644 --- a/tests/wire/unstable/news.test.ts +++ b/tests/wire/preview/news.test.ts @@ -61,7 +61,7 @@ describe("NewsClient", () => { }; server.mockEndpoint().get("/news/news_items").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.news.listNewsItems(); + const response = await client.preview.news.listNewsItems(); expect(response).toEqual({ type: "list", pages: { @@ -135,8 +135,8 @@ describe("NewsClient", () => { server.mockEndpoint().get("/news/news_items").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.news.listNewsItems(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.news.listNewsItems(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createNewsItem (1)", async () => { @@ -182,7 +182,7 @@ describe("NewsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.news.createNewsItem({ + const response = await client.preview.news.createNewsItem({ title: "Halloween is here!", body: "

New costumes in store for this spooky season

", sender_id: 991267834, @@ -240,11 +240,11 @@ describe("NewsClient", () => { .build(); await expect(async () => { - return await client.unstable.news.createNewsItem({ + return await client.preview.news.createNewsItem({ title: "title", sender_id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveNewsItem (1)", async () => { @@ -274,7 +274,7 @@ describe("NewsClient", () => { }; server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.news.retrieveNewsItem({ + const response = await client.preview.news.retrieveNewsItem({ id: 1, }); expect(response).toEqual({ @@ -313,10 +313,10 @@ describe("NewsClient", () => { server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.news.retrieveNewsItem({ + return await client.preview.news.retrieveNewsItem({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveNewsItem (3)", async () => { @@ -332,10 +332,10 @@ describe("NewsClient", () => { server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.news.retrieveNewsItem({ + return await client.preview.news.retrieveNewsItem({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("updateNewsItem (1)", async () => { @@ -377,7 +377,7 @@ describe("NewsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.news.updateNewsItem({ + const response = await client.preview.news.updateNewsItem({ id: 1, body: { title: "Christmas is here!", @@ -448,7 +448,7 @@ describe("NewsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.news.updateNewsItem({ + const response = await client.preview.news.updateNewsItem({ id: 1, body: { title: "Christmas is here!", @@ -500,14 +500,14 @@ describe("NewsClient", () => { .build(); await expect(async () => { - return await client.unstable.news.updateNewsItem({ + return await client.preview.news.updateNewsItem({ id: 1, body: { title: "title", sender_id: 1, }, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateNewsItem (4)", async () => { @@ -530,14 +530,14 @@ describe("NewsClient", () => { .build(); await expect(async () => { - return await client.unstable.news.updateNewsItem({ + return await client.preview.news.updateNewsItem({ id: 1, body: { title: "title", sender_id: 1, }, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("deleteNewsItem (1)", async () => { @@ -558,7 +558,7 @@ describe("NewsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.news.deleteNewsItem({ + const response = await client.preview.news.deleteNewsItem({ id: 1, }); expect(response).toEqual({ @@ -587,10 +587,10 @@ describe("NewsClient", () => { .build(); await expect(async () => { - return await client.unstable.news.deleteNewsItem({ + return await client.preview.news.deleteNewsItem({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteNewsItem (3)", async () => { @@ -612,10 +612,10 @@ describe("NewsClient", () => { .build(); await expect(async () => { - return await client.unstable.news.deleteNewsItem({ + return await client.preview.news.deleteNewsItem({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("listLiveNewsfeedItems (1)", async () => { @@ -664,7 +664,7 @@ describe("NewsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.news.listLiveNewsfeedItems({ + const response = await client.preview.news.listLiveNewsfeedItems({ id: "123", }); expect(response).toEqual({ @@ -725,10 +725,10 @@ describe("NewsClient", () => { .build(); await expect(async () => { - return await client.unstable.news.listLiveNewsfeedItems({ + return await client.preview.news.listLiveNewsfeedItems({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("listNewsfeeds (1)", async () => { @@ -757,7 +757,7 @@ describe("NewsClient", () => { }; server.mockEndpoint().get("/news/newsfeeds").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.news.listNewsfeeds(); + const response = await client.preview.news.listNewsfeeds(); expect(response).toEqual({ type: "list", pages: { @@ -803,8 +803,8 @@ describe("NewsClient", () => { server.mockEndpoint().get("/news/newsfeeds").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.news.listNewsfeeds(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.news.listNewsfeeds(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveNewsfeed (1)", async () => { @@ -831,7 +831,7 @@ describe("NewsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.news.retrieveNewsfeed({ + const response = await client.preview.news.retrieveNewsfeed({ id: "123", }); expect(response).toEqual({ @@ -856,9 +856,9 @@ describe("NewsClient", () => { server.mockEndpoint().get("/news/newsfeeds/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.news.retrieveNewsfeed({ + return await client.preview.news.retrieveNewsfeed({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/notes.test.ts b/tests/wire/preview/notes.test.ts similarity index 60% rename from tests/wire/unstable/notes.test.ts rename to tests/wire/preview/notes.test.ts index 64bff186..88ecdf5e 100644 --- a/tests/wire/unstable/notes.test.ts +++ b/tests/wire/preview/notes.test.ts @@ -22,6 +22,7 @@ describe("NotesClient", () => { id: "26", created_at: 1733932587, contact: { id: "214656d0c743eafcfde7f248" }, + company: { type: "company", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267581", @@ -43,6 +44,7 @@ describe("NotesClient", () => { id: "25", created_at: 1733846187, contact: { id: "214656d0c743eafcfde7f248" }, + company: { type: "company", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267581", @@ -63,6 +65,7 @@ describe("NotesClient", () => { id: "24", created_at: 1733846187, contact: { id: "214656d0c743eafcfde7f248" }, + company: { type: "company", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267581", @@ -97,8 +100,8 @@ describe("NotesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.notes.listCompanyNotes({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + const response = await client.preview.notes.listCompanyNotes({ + company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", }); expect(response).toEqual({ type: "list", @@ -110,6 +113,10 @@ describe("NotesClient", () => { contact: { id: "214656d0c743eafcfde7f248", }, + company: { + type: "company", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267581", @@ -136,6 +143,10 @@ describe("NotesClient", () => { contact: { id: "214656d0c743eafcfde7f248", }, + company: { + type: "company", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267581", @@ -158,6 +169,10 @@ describe("NotesClient", () => { contact: { id: "214656d0c743eafcfde7f248", }, + company: { + type: "company", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267581", @@ -204,17 +219,322 @@ describe("NotesClient", () => { const rawResponseBody = { key: "value" }; server .mockEndpoint() - .get("/companies/id/notes") + .get("/companies/company_id/notes") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.notes.listCompanyNotes({ + company_id: "company_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("createCompanyNote (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { body: "Hello", admin_id: "991267583" }; + const rawResponseBody = { + type: "note", + id: "31", + created_at: 1734537390, + contact: { type: "type", id: "214656d0c743eafcfde7f248" }, + company: { type: "company", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, + author: { + type: "admin", + id: "991267583", + name: "Ciaran124 Lee", + email: "admin124@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, + }, + body: "

Hello

", + }; + server + .mockEndpoint() + .post("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632/notes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.notes.createCompanyNote({ + company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + body: "Hello", + admin_id: "991267583", + }); + expect(response).toEqual({ + type: "note", + id: "31", + created_at: 1734537390, + contact: { + type: "type", + id: "214656d0c743eafcfde7f248", + }, + company: { + type: "company", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, + author: { + type: "admin", + id: "991267583", + name: "Ciaran124 Lee", + email: "admin124@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { + primary_team_ids: [814865], + secondary_team_ids: [493881], + }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + }, + body: "

Hello

", + }); + }); + + test("createCompanyNote (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { body: "Hello", admin_id: "123" }; + const rawResponseBody = { + type: "note", + id: "31", + created_at: 1734537390, + contact: { type: "type", id: "214656d0c743eafcfde7f248" }, + company: { type: "company", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, + author: { + type: "admin", + id: "991267583", + name: "Ciaran124 Lee", + email: "admin124@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, + }, + body: "

Hello

", + }; + server + .mockEndpoint() + .post("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632/notes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.notes.createCompanyNote({ + company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + body: "Hello", + admin_id: "123", + }); + expect(response).toEqual({ + type: "note", + id: "31", + created_at: 1734537390, + contact: { + type: "type", + id: "214656d0c743eafcfde7f248", + }, + company: { + type: "company", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, + author: { + type: "admin", + id: "991267583", + name: "Ciaran124 Lee", + email: "admin124@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { + primary_team_ids: [814865], + secondary_team_ids: [493881], + }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + }, + body: "

Hello

", + }); + }); + + test("createCompanyNote (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { body: "Hello" }; + const rawResponseBody = { + type: "note", + id: "31", + created_at: 1734537390, + contact: { type: "type", id: "214656d0c743eafcfde7f248" }, + company: { type: "company", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, + author: { + type: "admin", + id: "991267583", + name: "Ciaran124 Lee", + email: "admin124@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, + }, + body: "

Hello

", + }; + server + .mockEndpoint() + .post("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632/notes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.notes.createCompanyNote({ + company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + body: "Hello", + }); + expect(response).toEqual({ + type: "note", + id: "31", + created_at: 1734537390, + contact: { + type: "type", + id: "214656d0c743eafcfde7f248", + }, + company: { + type: "company", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, + author: { + type: "admin", + id: "991267583", + name: "Ciaran124 Lee", + email: "admin124@email.com", + job_title: "Associate", + away_mode_enabled: false, + away_mode_reassign: false, + away_status_reason_id: 12345, + has_inbox_seat: true, + team_ids: [814865], + avatar: "https://picsum.photos/200/300", + team_priority_level: { + primary_team_ids: [814865], + secondary_team_ids: [493881], + }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, + }, + body: "

Hello

", + }); + }); + + test("createCompanyNote (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { body: "body" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/companies/company_id/notes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.notes.createCompanyNote({ + company_id: "company_id", + body: "body", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createCompanyNote (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { body: "body" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/companies/company_id/notes") + .jsonBody(rawRequestBody) .respondWith() .statusCode(404) .jsonBody(rawResponseBody) .build(); await expect(async () => { - return await client.unstable.notes.listCompanyNotes({ - id: "id", + return await client.preview.notes.createCompanyNote({ + company_id: "company_id", + body: "body", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("listNotes (1)", async () => { @@ -234,6 +554,7 @@ describe("NotesClient", () => { id: "26", created_at: 1733932587, contact: { type: "contact", id: "6762f0ab1bb69f9f2193bb60" }, + company: { id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267581", @@ -254,6 +575,7 @@ describe("NotesClient", () => { id: "25", created_at: 1733846187, contact: { type: "contact", id: "6762f0ab1bb69f9f2193bb60" }, + company: { id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267581", @@ -274,6 +596,7 @@ describe("NotesClient", () => { id: "24", created_at: 1733846187, contact: { type: "contact", id: "6762f0ab1bb69f9f2193bb60" }, + company: { id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267581", @@ -301,7 +624,7 @@ describe("NotesClient", () => { }; server.mockEndpoint().get("/contacts/1/notes").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.notes.listNotes({ + const response = await client.preview.notes.listNotes({ id: 1, }); expect(response).toEqual({ @@ -315,6 +638,9 @@ describe("NotesClient", () => { type: "contact", id: "6762f0ab1bb69f9f2193bb60", }, + company: { + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267581", @@ -338,6 +664,9 @@ describe("NotesClient", () => { type: "contact", id: "6762f0ab1bb69f9f2193bb60", }, + company: { + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267581", @@ -361,6 +690,9 @@ describe("NotesClient", () => { type: "contact", id: "6762f0ab1bb69f9f2193bb60", }, + company: { + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267581", @@ -404,10 +736,10 @@ describe("NotesClient", () => { server.mockEndpoint().get("/contacts/1/notes").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.notes.listNotes({ + return await client.preview.notes.listNotes({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("createNote (1)", async () => { @@ -424,6 +756,7 @@ describe("NotesClient", () => { id: "31", created_at: 1734537390, contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, + company: { type: "type", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267583", @@ -437,6 +770,7 @@ describe("NotesClient", () => { team_ids: [814865], avatar: "https://picsum.photos/200/300", team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, }, body: "

Hello

", }; @@ -449,7 +783,7 @@ describe("NotesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.notes.createNote({ + const response = await client.preview.notes.createNote({ id: 1, body: "Hello", contact_id: "6762f0ad1bb69f9f2193bb62", @@ -463,6 +797,10 @@ describe("NotesClient", () => { type: "contact", id: "6762f0ad1bb69f9f2193bb62", }, + company: { + type: "type", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267583", @@ -479,6 +817,11 @@ describe("NotesClient", () => { primary_team_ids: [814865], secondary_team_ids: [493881], }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, }, body: "

Hello

", }); @@ -498,6 +841,7 @@ describe("NotesClient", () => { id: "31", created_at: 1734537390, contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, + company: { type: "type", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267583", @@ -511,6 +855,7 @@ describe("NotesClient", () => { team_ids: [814865], avatar: "https://picsum.photos/200/300", team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, }, body: "

Hello

", }; @@ -523,7 +868,7 @@ describe("NotesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.notes.createNote({ + const response = await client.preview.notes.createNote({ id: 1, body: "Hello", contact_id: "6762f0af1bb69f9f2193bb63", @@ -537,6 +882,10 @@ describe("NotesClient", () => { type: "contact", id: "6762f0ad1bb69f9f2193bb62", }, + company: { + type: "type", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267583", @@ -553,6 +902,11 @@ describe("NotesClient", () => { primary_team_ids: [814865], secondary_team_ids: [493881], }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, }, body: "

Hello

", }); @@ -572,6 +926,7 @@ describe("NotesClient", () => { id: "31", created_at: 1734537390, contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, + company: { type: "type", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267583", @@ -585,6 +940,7 @@ describe("NotesClient", () => { team_ids: [814865], avatar: "https://picsum.photos/200/300", team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, }, body: "

Hello

", }; @@ -597,7 +953,7 @@ describe("NotesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.notes.createNote({ + const response = await client.preview.notes.createNote({ id: 1, body: "Hello", contact_id: "123", @@ -611,6 +967,10 @@ describe("NotesClient", () => { type: "contact", id: "6762f0ad1bb69f9f2193bb62", }, + company: { + type: "type", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267583", @@ -627,6 +987,11 @@ describe("NotesClient", () => { primary_team_ids: [814865], secondary_team_ids: [493881], }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, }, body: "

Hello

", }); @@ -652,11 +1017,11 @@ describe("NotesClient", () => { .build(); await expect(async () => { - return await client.unstable.notes.createNote({ + return await client.preview.notes.createNote({ id: 1, body: "body", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("retrieveNote (1)", async () => { @@ -673,6 +1038,7 @@ describe("NotesClient", () => { id: "34", created_at: 1733846617, contact: { type: "contact", id: "6762f2591bb69f9f2193bc1f" }, + company: { type: "type", id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" }, author: { type: "admin", id: "991267864", @@ -686,12 +1052,13 @@ describe("NotesClient", () => { team_ids: [814865], avatar: "https://picsum.photos/200/300", team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, + role: { type: "role", id: "1", name: "Support Agent" }, }, body: "

This is a note.

", }; server.mockEndpoint().get("/notes/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.notes.retrieveNote({ + const response = await client.preview.notes.retrieveNote({ id: 1, }); expect(response).toEqual({ @@ -702,6 +1069,10 @@ describe("NotesClient", () => { type: "contact", id: "6762f2591bb69f9f2193bc1f", }, + company: { + type: "type", + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", + }, author: { type: "admin", id: "991267864", @@ -718,6 +1089,11 @@ describe("NotesClient", () => { primary_team_ids: [814865], secondary_team_ids: [493881], }, + role: { + type: "role", + id: "1", + name: "Support Agent", + }, }, body: "

This is a note.

", }); @@ -736,10 +1112,10 @@ describe("NotesClient", () => { server.mockEndpoint().get("/notes/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.notes.retrieveNote({ + return await client.preview.notes.retrieveNote({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveNote (3)", async () => { @@ -755,9 +1131,88 @@ describe("NotesClient", () => { server.mockEndpoint().get("/notes/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.notes.retrieveNote({ + return await client.preview.notes.retrieveNote({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("deleteNote (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "34", type: "note", deleted: true }; + server.mockEndpoint().delete("/notes/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.notes.deleteNote({ + id: 1, + }); + expect(response).toEqual({ + id: "34", + type: "note", + deleted: true, + }); + }); + + test("deleteNote (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().delete("/notes/1").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.notes.deleteNote({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("deleteNote (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/notes/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.notes.deleteNote({ + id: 1, + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteNote (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().delete("/notes/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.notes.deleteNote({ id: 1, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/preview/officeHours.test.ts b/tests/wire/preview/officeHours.test.ts new file mode 100644 index 00000000..67dc7af3 --- /dev/null +++ b/tests/wire/preview/officeHours.test.ts @@ -0,0 +1,1146 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("OfficeHoursClient", () => { + test("listOfficeHoursSchedules (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "office_hours_schedule.list", + data: [ + { + type: "office_hours_schedule", + id: "123", + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [ + { start_minute: 540, end_minute: 1020, day_of_week: 0 }, + { start_minute: 1980, end_minute: 2460, day_of_week: 1 }, + ], + twenty_four_seven: false, + created_at: 1717200000, + updated_at: 1717200000, + }, + ], + }; + server + .mockEndpoint() + .get("/office_hours_schedules") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.listOfficeHoursSchedules(); + expect(response).toEqual({ + type: "office_hours_schedule.list", + data: [ + { + type: "office_hours_schedule", + id: "123", + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [ + { + start_minute: 540, + end_minute: 1020, + day_of_week: 0, + }, + { + start_minute: 1980, + end_minute: 2460, + day_of_week: 1, + }, + ], + twenty_four_seven: false, + created_at: 1717200000, + updated_at: 1717200000, + }, + ], + }); + }); + + test("listOfficeHoursSchedules (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/office_hours_schedules") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.listOfficeHoursSchedules(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createOfficeHoursSchedule (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [{ start_minute: 540, end_minute: 1020 }], + }; + const rawResponseBody = { + type: "office_hours_schedule", + id: "125", + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [{ start_minute: 540, end_minute: 1020, day_of_week: 0 }], + twenty_four_seven: false, + created_at: 1717200000, + updated_at: 1717200000, + }; + server + .mockEndpoint() + .post("/office_hours_schedules") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.createOfficeHoursSchedule({ + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [ + { + start_minute: 540, + end_minute: 1020, + }, + ], + }); + expect(response).toEqual({ + type: "office_hours_schedule", + id: "125", + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [ + { + start_minute: 540, + end_minute: 1020, + day_of_week: 0, + }, + ], + twenty_four_seven: false, + created_at: 1717200000, + updated_at: 1717200000, + }); + }); + + test("createOfficeHoursSchedule (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name", time_zone_name: "time_zone_name", time_intervals: [{}, {}] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/office_hours_schedules") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.createOfficeHoursSchedule({ + name: "name", + time_zone_name: "time_zone_name", + time_intervals: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createOfficeHoursSchedule (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name", time_zone_name: "time_zone_name", time_intervals: [{}, {}] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/office_hours_schedules") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.createOfficeHoursSchedule({ + name: "name", + time_zone_name: "time_zone_name", + time_intervals: [{}, {}], + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("getOfficeHoursSchedule (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "office_hours_schedule", + id: "123", + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [{ start_minute: 540, end_minute: 1020, day_of_week: 0 }], + twenty_four_seven: false, + created_at: 1717200000, + updated_at: 1717200000, + }; + server + .mockEndpoint() + .get("/office_hours_schedules/123") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.getOfficeHoursSchedule({ + id: "123", + }); + expect(response).toEqual({ + type: "office_hours_schedule", + id: "123", + name: "Standard Support Hours", + time_zone_name: "America/New_York", + time_intervals: [ + { + start_minute: 540, + end_minute: 1020, + day_of_week: 0, + }, + ], + twenty_four_seven: false, + created_at: 1717200000, + updated_at: 1717200000, + }); + }); + + test("getOfficeHoursSchedule (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/office_hours_schedules/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.getOfficeHoursSchedule({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("getOfficeHoursSchedule (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/office_hours_schedules/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.getOfficeHoursSchedule({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateOfficeHoursSchedule (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + name: "Extended Support Hours", + time_intervals: [{ start_minute: 480, end_minute: 1080 }], + }; + const rawResponseBody = { + type: "office_hours_schedule", + id: "123", + name: "Extended Support Hours", + time_zone_name: "America/New_York", + time_intervals: [{ start_minute: 480, end_minute: 1080, day_of_week: 0 }], + twenty_four_seven: false, + created_at: 1717200000, + updated_at: 1717203600, + }; + server + .mockEndpoint() + .put("/office_hours_schedules/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.updateOfficeHoursSchedule({ + id: "123", + name: "Extended Support Hours", + time_intervals: [ + { + start_minute: 480, + end_minute: 1080, + }, + ], + }); + expect(response).toEqual({ + type: "office_hours_schedule", + id: "123", + name: "Extended Support Hours", + time_zone_name: "America/New_York", + time_intervals: [ + { + start_minute: 480, + end_minute: 1080, + day_of_week: 0, + }, + ], + twenty_four_seven: false, + created_at: 1717200000, + updated_at: 1717203600, + }); + }); + + test("updateOfficeHoursSchedule (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/office_hours_schedules/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.updateOfficeHoursSchedule({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateOfficeHoursSchedule (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/office_hours_schedules/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.updateOfficeHoursSchedule({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateOfficeHoursSchedule (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/office_hours_schedules/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.updateOfficeHoursSchedule({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("deleteOfficeHoursSchedule (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "123", object: "office_hours_schedule", deleted: true }; + server + .mockEndpoint() + .delete("/office_hours_schedules/123") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.deleteOfficeHoursSchedule({ + id: "123", + }); + expect(response).toEqual({ + id: "123", + object: "office_hours_schedule", + deleted: true, + }); + }); + + test("deleteOfficeHoursSchedule (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/office_hours_schedules/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.deleteOfficeHoursSchedule({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteOfficeHoursSchedule (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/office_hours_schedules/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.deleteOfficeHoursSchedule({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listOfficeHoursExceptions (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "office_hours_exception.list", + data: [ + { + type: "office_hours_exception", + id: "456", + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + time_intervals: [{ start_minute: 540, end_minute: 1020, day_of_week: 0 }], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717200000, + }, + { + type: "office_hours_exception", + id: "457", + office_hours_schedule_id: "123", + exception_date: "2026-12-24", + exception_type: "custom_hours", + name: "Christmas Eve", + time_intervals: [{ start_minute: 540, end_minute: 780, day_of_week: 3 }], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717200000, + }, + ], + }; + server + .mockEndpoint() + .get("/office_hours_schedules/123/office_hours_exceptions") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.listOfficeHoursExceptions({ + office_hours_schedule_id: "123", + }); + expect(response).toEqual({ + type: "office_hours_exception.list", + data: [ + { + type: "office_hours_exception", + id: "456", + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + time_intervals: [ + { + start_minute: 540, + end_minute: 1020, + day_of_week: 0, + }, + ], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717200000, + }, + { + type: "office_hours_exception", + id: "457", + office_hours_schedule_id: "123", + exception_date: "2026-12-24", + exception_type: "custom_hours", + name: "Christmas Eve", + time_intervals: [ + { + start_minute: 540, + end_minute: 780, + day_of_week: 3, + }, + ], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717200000, + }, + ], + }); + }); + + test("listOfficeHoursExceptions (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.listOfficeHoursExceptions({ + office_hours_schedule_id: "office_hours_schedule_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("listOfficeHoursExceptions (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.listOfficeHoursExceptions({ + office_hours_schedule_id: "office_hours_schedule_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("createOfficeHoursException (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + recurring_annually: true, + }; + const rawResponseBody = { + type: "office_hours_exception", + id: "458", + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + time_intervals: [{ start_minute: 540, end_minute: 1020, day_of_week: 0 }], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717200000, + }; + server + .mockEndpoint() + .post("/office_hours_schedules/123/office_hours_exceptions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.createOfficeHoursException({ + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + recurring_annually: true, + }); + expect(response).toEqual({ + type: "office_hours_exception", + id: "458", + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + time_intervals: [ + { + start_minute: 540, + end_minute: 1020, + day_of_week: 0, + }, + ], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717200000, + }); + }); + + test("createOfficeHoursException (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { exception_date: "exception_date", exception_type: "closed" }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.createOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + exception_date: "exception_date", + exception_type: "closed", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("createOfficeHoursException (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { exception_date: "exception_date", exception_type: "closed" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.createOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + exception_date: "exception_date", + exception_type: "closed", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("createOfficeHoursException (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { exception_date: "exception_date", exception_type: "closed" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.createOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + exception_date: "exception_date", + exception_type: "closed", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("getOfficeHoursException (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "office_hours_exception", + id: "456", + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + time_intervals: [{ start_minute: 540, end_minute: 1020, day_of_week: 0 }], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717200000, + }; + server + .mockEndpoint() + .get("/office_hours_schedules/123/office_hours_exceptions/456") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.getOfficeHoursException({ + office_hours_schedule_id: "123", + id: "456", + }); + expect(response).toEqual({ + type: "office_hours_exception", + id: "456", + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "closed", + name: "Christmas Day", + time_intervals: [ + { + start_minute: 540, + end_minute: 1020, + day_of_week: 0, + }, + ], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717200000, + }); + }); + + test("getOfficeHoursException (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.getOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("getOfficeHoursException (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.getOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateOfficeHoursException (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + exception_type: "custom_hours", + name: "Christmas Day (reduced hours)", + time_intervals: [{ start_minute: 540, end_minute: 780 }], + recurring_annually: true, + }; + const rawResponseBody = { + type: "office_hours_exception", + id: "456", + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "custom_hours", + name: "Christmas Day (reduced hours)", + time_intervals: [{ start_minute: 540, end_minute: 780, day_of_week: 4 }], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717203600, + }; + server + .mockEndpoint() + .put("/office_hours_schedules/123/office_hours_exceptions/456") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.updateOfficeHoursException({ + office_hours_schedule_id: "123", + id: "456", + exception_type: "custom_hours", + name: "Christmas Day (reduced hours)", + time_intervals: [ + { + start_minute: 540, + end_minute: 780, + }, + ], + recurring_annually: true, + }); + expect(response).toEqual({ + type: "office_hours_exception", + id: "456", + office_hours_schedule_id: "123", + exception_date: "2026-12-25", + exception_type: "custom_hours", + name: "Christmas Day (reduced hours)", + time_intervals: [ + { + start_minute: 540, + end_minute: 780, + day_of_week: 4, + }, + ], + recurring_annually: true, + created_at: 1717200000, + updated_at: 1717203600, + }); + }); + + test("updateOfficeHoursException (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.updateOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateOfficeHoursException (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.updateOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateOfficeHoursException (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.updateOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("deleteOfficeHoursException (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "456", object: "office_hours_exception", deleted: true }; + server + .mockEndpoint() + .delete("/office_hours_schedules/123/office_hours_exceptions/456") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.officeHours.deleteOfficeHoursException({ + office_hours_schedule_id: "123", + id: "456", + }); + expect(response).toEqual({ + id: "456", + object: "office_hours_exception", + deleted: true, + }); + }); + + test("deleteOfficeHoursException (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.deleteOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteOfficeHoursException (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/office_hours_schedules/office_hours_schedule_id/office_hours_exceptions/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.officeHours.deleteOfficeHoursException({ + office_hours_schedule_id: "office_hours_schedule_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); +}); diff --git a/tests/wire/preview/procedures.test.ts b/tests/wire/preview/procedures.test.ts new file mode 100644 index 00000000..ff56655f --- /dev/null +++ b/tests/wire/preview/procedures.test.ts @@ -0,0 +1,284 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ProceduresClient", () => { + test("collectProcedureAgentInput (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + step_id: "d5b81f72-adb9-4317-b973-75b3c3624c09", + attribute_values: [ + { identifier: "workflow_local_variables.72c5a6b3-3cce-41d8-8e30-14da40791958", value: true }, + { + identifier: "workflow_local_variables.5adb55fb-f549-44a0-8ee9-7e652ad77c25", + value: "85f00ba7-558c-4b02-a397-6f5c3659941c", + }, + ], + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/procedures/215473853299345/collect_agent_input") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.procedures.collectProcedureAgentInput({ + conversation_id: "215473853299345", + step_id: "d5b81f72-adb9-4317-b973-75b3c3624c09", + attribute_values: [ + { + identifier: "workflow_local_variables.72c5a6b3-3cce-41d8-8e30-14da40791958", + value: true, + }, + { + identifier: "workflow_local_variables.5adb55fb-f549-44a0-8ee9-7e652ad77c25", + value: "85f00ba7-558c-4b02-a397-6f5c3659941c", + }, + ], + }); + expect(response).toEqual({ + key: "value", + }); + }); + + test("collectProcedureAgentInput (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + step_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + attribute_values: [ + { + identifier: "workflow_local_variables.11111111-2222-3333-4444-555555555555", + value: "Approved by manager", + }, + ], + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/procedures/215473853299345/collect_agent_input") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.procedures.collectProcedureAgentInput({ + conversation_id: "215473853299345", + step_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + attribute_values: [ + { + identifier: "workflow_local_variables.11111111-2222-3333-4444-555555555555", + value: "Approved by manager", + }, + ], + }); + expect(response).toEqual({ + key: "value", + }); + }); + + test("collectProcedureAgentInput (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + step_id: "step_id", + attribute_values: [ + { identifier: "identifier", value: { key: "value" } }, + { identifier: "identifier", value: { key: "value" } }, + ], + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/procedures/conversation_id/collect_agent_input") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.procedures.collectProcedureAgentInput({ + conversation_id: "conversation_id", + step_id: "step_id", + attribute_values: [ + { + identifier: "identifier", + value: { + key: "value", + }, + }, + { + identifier: "identifier", + value: { + key: "value", + }, + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("collectProcedureAgentInput (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + step_id: "step_id", + attribute_values: [ + { identifier: "identifier", value: { key: "value" } }, + { identifier: "identifier", value: { key: "value" } }, + ], + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/procedures/conversation_id/collect_agent_input") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.procedures.collectProcedureAgentInput({ + conversation_id: "conversation_id", + step_id: "step_id", + attribute_values: [ + { + identifier: "identifier", + value: { + key: "value", + }, + }, + { + identifier: "identifier", + value: { + key: "value", + }, + }, + ], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("collectProcedureAgentInput (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + step_id: "step_id", + attribute_values: [ + { identifier: "identifier", value: { key: "value" } }, + { identifier: "identifier", value: { key: "value" } }, + ], + }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/procedures/conversation_id/collect_agent_input") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.procedures.collectProcedureAgentInput({ + conversation_id: "conversation_id", + step_id: "step_id", + attribute_values: [ + { + identifier: "identifier", + value: { + key: "value", + }, + }, + { + identifier: "identifier", + value: { + key: "value", + }, + }, + ], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("collectProcedureAgentInput (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + step_id: "step_id", + attribute_values: [ + { identifier: "identifier", value: { key: "value" } }, + { identifier: "identifier", value: { key: "value" } }, + ], + }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/procedures/conversation_id/collect_agent_input") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.procedures.collectProcedureAgentInput({ + conversation_id: "conversation_id", + step_id: "step_id", + attribute_values: [ + { + identifier: "identifier", + value: { + key: "value", + }, + }, + { + identifier: "identifier", + value: { + key: "value", + }, + }, + ], + }); + }).rejects.toThrow(Intercom.preview.ConflictError); + }); +}); diff --git a/tests/wire/unstable/export.test.ts b/tests/wire/preview/reportingDataExport.test.ts similarity index 85% rename from tests/wire/unstable/export.test.ts rename to tests/wire/preview/reportingDataExport.test.ts index 0027d596..77dc51a3 100644 --- a/tests/wire/unstable/export.test.ts +++ b/tests/wire/preview/reportingDataExport.test.ts @@ -4,7 +4,7 @@ import * as Intercom from "../../../src/api/index"; import { IntercomClient } from "../../../src/Client"; import { mockServerPool } from "../../mock-server/MockServerPool"; -describe("ExportClient", () => { +describe("ReportingDataExportClient", () => { test("enqueueANewReportingDataExportJob (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ @@ -34,7 +34,7 @@ describe("ExportClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.export.enqueueANewReportingDataExportJob({ + const response = await client.preview.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "conversation", attribute_ids: ["conversation_id", "conversation_started_at"], start_time: 1717490000, @@ -73,13 +73,13 @@ describe("ExportClient", () => { .build(); await expect(async () => { - return await client.unstable.export.enqueueANewReportingDataExportJob({ + return await client.preview.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "dataset_id", attribute_ids: ["attribute_ids", "attribute_ids"], start_time: 1000000, end_time: 1000000, }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("enqueueANewReportingDataExportJob (3)", async () => { @@ -107,13 +107,13 @@ describe("ExportClient", () => { .build(); await expect(async () => { - return await client.unstable.export.enqueueANewReportingDataExportJob({ + return await client.preview.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "dataset_id", attribute_ids: ["attribute_ids", "attribute_ids"], start_time: 1000000, end_time: 1000000, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("enqueueANewReportingDataExportJob (4)", async () => { @@ -141,13 +141,13 @@ describe("ExportClient", () => { .build(); await expect(async () => { - return await client.unstable.export.enqueueANewReportingDataExportJob({ + return await client.preview.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "dataset_id", attribute_ids: ["attribute_ids", "attribute_ids"], start_time: 1000000, end_time: 1000000, }); - }).rejects.toThrow(Intercom.unstable.TooManyRequestsError); + }).rejects.toThrow(Intercom.preview.TooManyRequestsError); }); test("listAvailableDatasetsAndAttributes", async () => { @@ -167,7 +167,13 @@ describe("ExportClient", () => { name: "Conversation", description: "Conversation-level details: status, channel, assignee.", default_time_attribute_id: "conversation_started_at", - attributes: [{ id: "conversation_id", name: "Conversation ID" }], + attributes: [ + { + id: "conversation_id", + qualified_id: "conversation.conversation_id", + name: "Conversation ID", + }, + ], }, ], }; @@ -179,7 +185,7 @@ describe("ExportClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.export.listAvailableDatasetsAndAttributes(); + const response = await client.preview.reportingDataExport.listAvailableDatasetsAndAttributes(); expect(response).toEqual({ type: "list", data: [ @@ -191,6 +197,7 @@ describe("ExportClient", () => { attributes: [ { id: "conversation_id", + qualified_id: "conversation.conversation_id", name: "Conversation ID", }, ], diff --git a/tests/wire/unstable/teams.test.ts b/tests/wire/preview/roles.test.ts similarity index 52% rename from tests/wire/unstable/teams.test.ts rename to tests/wire/preview/roles.test.ts index f25b2268..84c715d5 100644 --- a/tests/wire/unstable/teams.test.ts +++ b/tests/wire/preview/roles.test.ts @@ -4,8 +4,8 @@ import * as Intercom from "../../../src/api/index"; import { IntercomClient } from "../../../src/Client"; import { mockServerPool } from "../../mock-server/MockServerPool"; -describe("TeamsClient", () => { - test("listTeams (1)", async () => { +describe("RolesClient", () => { + test("listRoles (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -15,38 +15,33 @@ describe("TeamsClient", () => { }); const rawResponseBody = { - type: "team.list", - teams: [ + type: "list", + data: [ { - type: "team", - id: "814865", - name: "Example Team", - admin_ids: [493881], - admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [814865] }, + type: "role", + id: "991267902", + name: "Support Lead", + description: "Can view and reply to conversations", }, ], }; - server.mockEndpoint().get("/teams").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + server.mockEndpoint().get("/roles").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.teams.listTeams(); + const response = await client.preview.roles.listRoles(); expect(response).toEqual({ - type: "team.list", - teams: [ + type: "list", + data: [ { - type: "team", - id: "814865", - name: "Example Team", - admin_ids: [493881], - admin_priority_level: { - primary_admin_ids: [493881], - secondary_admin_ids: [814865], - }, + type: "role", + id: "991267902", + name: "Support Lead", + description: "Can view and reply to conversations", }, ], }); }); - test("listTeams (2)", async () => { + test("listRoles (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -56,14 +51,14 @@ describe("TeamsClient", () => { }); const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/teams").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + server.mockEndpoint().get("/roles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.teams.listTeams(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.roles.listRoles(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); - test("retrieveTeam (1)", async () => { + test("retrieveRole (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -73,30 +68,25 @@ describe("TeamsClient", () => { }); const rawResponseBody = { - type: "team", + type: "role", id: "991267902", - name: "team 1", - admin_ids: [493881], - admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [814865] }, + name: "Support Lead", + description: "Can view and reply to conversations", }; - server.mockEndpoint().get("/teams/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + server.mockEndpoint().get("/roles/991267902").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.teams.retrieveTeam({ - id: "123", + const response = await client.preview.roles.retrieveRole({ + id: "991267902", }); expect(response).toEqual({ - type: "team", + type: "role", id: "991267902", - name: "team 1", - admin_ids: [493881], - admin_priority_level: { - primary_admin_ids: [493881], - secondary_admin_ids: [814865], - }, + name: "Support Lead", + description: "Can view and reply to conversations", }); }); - test("retrieveTeam (2)", async () => { + test("retrieveRole (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -106,16 +96,16 @@ describe("TeamsClient", () => { }); const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/teams/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + server.mockEndpoint().get("/roles/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.teams.retrieveTeam({ + return await client.preview.roles.retrieveRole({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); - test("retrieveTeam (3)", async () => { + test("retrieveRole (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -125,12 +115,12 @@ describe("TeamsClient", () => { }); const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/teams/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + server.mockEndpoint().get("/roles/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.teams.retrieveTeam({ + return await client.preview.roles.retrieveRole({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/unstable/segments.test.ts b/tests/wire/preview/segments.test.ts similarity index 90% rename from tests/wire/unstable/segments.test.ts rename to tests/wire/preview/segments.test.ts index 71d84bae..1c156471 100644 --- a/tests/wire/unstable/segments.test.ts +++ b/tests/wire/preview/segments.test.ts @@ -40,7 +40,7 @@ describe("SegmentsClient", () => { }; server.mockEndpoint().get("/segments").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.segments.listSegments({ + const response = await client.preview.segments.listSegments({ include_count: true, }); expect(response).toEqual({ @@ -84,8 +84,8 @@ describe("SegmentsClient", () => { server.mockEndpoint().get("/segments").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.segments.listSegments(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.segments.listSegments(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveSegment (1)", async () => { @@ -108,7 +108,7 @@ describe("SegmentsClient", () => { }; server.mockEndpoint().get("/segments/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.segments.retrieveSegment({ + const response = await client.preview.segments.retrieveSegment({ id: "123", }); expect(response).toEqual({ @@ -135,10 +135,10 @@ describe("SegmentsClient", () => { server.mockEndpoint().get("/segments/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.segments.retrieveSegment({ + return await client.preview.segments.retrieveSegment({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveSegment (3)", async () => { @@ -154,9 +154,9 @@ describe("SegmentsClient", () => { server.mockEndpoint().get("/segments/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.segments.retrieveSegment({ + return await client.preview.segments.retrieveSegment({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/unstable/subscriptionTypes.test.ts b/tests/wire/preview/subscriptionTypes.test.ts similarity index 91% rename from tests/wire/unstable/subscriptionTypes.test.ts rename to tests/wire/preview/subscriptionTypes.test.ts index 56304a5e..cbb442e2 100644 --- a/tests/wire/unstable/subscriptionTypes.test.ts +++ b/tests/wire/preview/subscriptionTypes.test.ts @@ -32,7 +32,7 @@ describe("SubscriptionTypesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + const response = await client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ contact_id: "63a07ddf05a32042dffac965", id: "37846", consent_type: "opt_in", @@ -85,7 +85,7 @@ describe("SubscriptionTypesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + const response = await client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ contact_id: "63a07ddf05a32042dffac965", id: "37846", consent_type: "opt_in", @@ -138,7 +138,7 @@ describe("SubscriptionTypesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + const response = await client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ contact_id: "63a07ddf05a32042dffac965", id: "invalid_id", consent_type: "opt_in", @@ -184,12 +184,12 @@ describe("SubscriptionTypesClient", () => { .build(); await expect(async () => { - return await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + return await client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ contact_id: "contact_id", id: "id", consent_type: "consent_type", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("attachSubscriptionTypeToContact (5)", async () => { @@ -212,12 +212,12 @@ describe("SubscriptionTypesClient", () => { .build(); await expect(async () => { - return await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + return await client.preview.subscriptionTypes.attachSubscriptionTypeToContact({ contact_id: "contact_id", id: "id", consent_type: "consent_type", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("detachSubscriptionTypeToContact (1)", async () => { @@ -246,7 +246,7 @@ describe("SubscriptionTypesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ + const response = await client.preview.subscriptionTypes.detachSubscriptionTypeToContact({ contact_id: "63a07ddf05a32042dffac965", id: "37846", }); @@ -290,11 +290,11 @@ describe("SubscriptionTypesClient", () => { .build(); await expect(async () => { - return await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ + return await client.preview.subscriptionTypes.detachSubscriptionTypeToContact({ contact_id: "contact_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("detachSubscriptionTypeToContact (3)", async () => { @@ -316,11 +316,11 @@ describe("SubscriptionTypesClient", () => { .build(); await expect(async () => { - return await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ + return await client.preview.subscriptionTypes.detachSubscriptionTypeToContact({ contact_id: "contact_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("listSubscriptionTypes (1)", async () => { @@ -358,7 +358,7 @@ describe("SubscriptionTypesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.subscriptionTypes.listSubscriptionTypes(); + const response = await client.preview.subscriptionTypes.listSubscriptionTypes(); expect(response).toEqual({ type: "list", data: [ @@ -404,7 +404,7 @@ describe("SubscriptionTypesClient", () => { .build(); await expect(async () => { - return await client.unstable.subscriptionTypes.listSubscriptionTypes(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.subscriptionTypes.listSubscriptionTypes(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/switch.test.ts b/tests/wire/preview/switch.test.ts similarity index 87% rename from tests/wire/unstable/switch.test.ts rename to tests/wire/preview/switch.test.ts index d7ee5321..78c108e7 100644 --- a/tests/wire/unstable/switch.test.ts +++ b/tests/wire/preview/switch.test.ts @@ -24,7 +24,7 @@ describe("SwitchClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.switch.createPhoneSwitch({ + const response = await client.preview.switch.createPhoneSwitch({ key: "value", }); expect(response).toEqual({ @@ -53,10 +53,10 @@ describe("SwitchClient", () => { .build(); await expect(async () => { - return await client.unstable.switch.createPhoneSwitch({ + return await client.preview.switch.createPhoneSwitch({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("createPhoneSwitch (3)", async () => { @@ -79,10 +79,10 @@ describe("SwitchClient", () => { .build(); await expect(async () => { - return await client.unstable.switch.createPhoneSwitch({ + return await client.preview.switch.createPhoneSwitch({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createPhoneSwitch (4)", async () => { @@ -105,9 +105,9 @@ describe("SwitchClient", () => { .build(); await expect(async () => { - return await client.unstable.switch.createPhoneSwitch({ + return await client.preview.switch.createPhoneSwitch({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); }); }); diff --git a/tests/wire/unstable/tags.test.ts b/tests/wire/preview/tags.test.ts similarity index 77% rename from tests/wire/unstable/tags.test.ts rename to tests/wire/preview/tags.test.ts index e7094ebe..f8ce0d36 100644 --- a/tests/wire/unstable/tags.test.ts +++ b/tests/wire/preview/tags.test.ts @@ -19,7 +19,7 @@ describe("TagsClient", () => { id: "81", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -30,7 +30,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.attachTagToContact({ + const response = await client.preview.tags.attachTagToContact({ contact_id: "63a07ddf05a32042dffac965", id: "7522907", }); @@ -40,8 +40,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -60,7 +60,7 @@ describe("TagsClient", () => { id: "81", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -71,7 +71,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.attachTagToContact({ + const response = await client.preview.tags.attachTagToContact({ contact_id: "63a07ddf05a32042dffac965", id: "7522907", }); @@ -81,8 +81,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -101,7 +101,7 @@ describe("TagsClient", () => { id: "81", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -112,7 +112,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.attachTagToContact({ + const response = await client.preview.tags.attachTagToContact({ contact_id: "63a07ddf05a32042dffac965", id: "123", }); @@ -122,8 +122,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -148,11 +148,11 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.attachTagToContact({ + return await client.preview.tags.attachTagToContact({ contact_id: "contact_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("attachTagToContact (5)", async () => { @@ -175,11 +175,11 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.attachTagToContact({ + return await client.preview.tags.attachTagToContact({ contact_id: "contact_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("detachTagFromContact (1)", async () => { @@ -196,7 +196,7 @@ describe("TagsClient", () => { id: "84", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -206,7 +206,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.detachTagFromContact({ + const response = await client.preview.tags.detachTagFromContact({ contact_id: "63a07ddf05a32042dffac965", id: "7522907", }); @@ -216,8 +216,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -241,11 +241,11 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.detachTagFromContact({ + return await client.preview.tags.detachTagFromContact({ contact_id: "contact_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("detachTagFromContact (3)", async () => { @@ -267,11 +267,11 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.detachTagFromContact({ + return await client.preview.tags.detachTagFromContact({ contact_id: "contact_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("attachTagToConversation (1)", async () => { @@ -288,7 +288,7 @@ describe("TagsClient", () => { id: "86", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -299,7 +299,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.attachTagToConversation({ + const response = await client.preview.tags.attachTagToConversation({ conversation_id: "64619700005694", id: "7522907", admin_id: "780", @@ -310,8 +310,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -330,7 +330,7 @@ describe("TagsClient", () => { id: "86", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -341,7 +341,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.attachTagToConversation({ + const response = await client.preview.tags.attachTagToConversation({ conversation_id: "64619700005694", id: "7522907", admin_id: "780", @@ -352,8 +352,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -378,12 +378,12 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.attachTagToConversation({ + return await client.preview.tags.attachTagToConversation({ conversation_id: "conversation_id", id: "id", admin_id: "admin_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("attachTagToConversation (4)", async () => { @@ -406,12 +406,12 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.attachTagToConversation({ + return await client.preview.tags.attachTagToConversation({ conversation_id: "conversation_id", id: "id", admin_id: "admin_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("detachTagFromConversation (1)", async () => { @@ -428,7 +428,7 @@ describe("TagsClient", () => { id: "89", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -439,7 +439,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.detachTagFromConversation({ + const response = await client.preview.tags.detachTagFromConversation({ conversation_id: "64619700005694", id: "7522907", admin_id: "123", @@ -450,8 +450,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -470,7 +470,7 @@ describe("TagsClient", () => { id: "89", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -481,7 +481,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.detachTagFromConversation({ + const response = await client.preview.tags.detachTagFromConversation({ conversation_id: "64619700005694", id: "7522907", admin_id: "123", @@ -492,8 +492,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -512,7 +512,7 @@ describe("TagsClient", () => { id: "89", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -523,7 +523,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.detachTagFromConversation({ + const response = await client.preview.tags.detachTagFromConversation({ conversation_id: "64619700005694", id: "7522907", admin_id: "123", @@ -534,8 +534,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -560,12 +560,12 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.detachTagFromConversation({ + return await client.preview.tags.detachTagFromConversation({ conversation_id: "conversation_id", id: "id", admin_id: "admin_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("detachTagFromConversation (5)", async () => { @@ -588,12 +588,12 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.detachTagFromConversation({ + return await client.preview.tags.detachTagFromConversation({ conversation_id: "conversation_id", id: "id", admin_id: "admin_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("listTags (1)", async () => { @@ -619,7 +619,7 @@ describe("TagsClient", () => { }; server.mockEndpoint().get("/tags").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.tags.listTags(); + const response = await client.preview.tags.listTags(); expect(response).toEqual({ type: "list", data: [ @@ -650,8 +650,8 @@ describe("TagsClient", () => { server.mockEndpoint().get("/tags").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.tags.listTags(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.tags.listTags(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createTag (1)", async () => { @@ -667,8 +667,8 @@ describe("TagsClient", () => { type: "tag", id: "105", name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + users: [{ id: "6329e838deab40166d1a53f7", tagged: true }], + companies: [{ id: "valid-123", tagged: true }], }; server .mockEndpoint() @@ -679,18 +679,25 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.createTag({ + const response = await client.preview.tags.createTag({ name: "test", }); expect(response).toEqual({ type: "tag", id: "105", name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, + users: [ + { + id: "6329e838deab40166d1a53f7", + tagged: true, + }, + ], + companies: [ + { + id: "valid-123", + tagged: true, + }, + ], }); }); @@ -707,8 +714,8 @@ describe("TagsClient", () => { type: "tag", id: "105", name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + users: [{ id: "6329e838deab40166d1a53f7", tagged: true }], + companies: [{ id: "valid-123", tagged: true }], }; server .mockEndpoint() @@ -719,112 +726,29 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.createTag({ + const response = await client.preview.tags.createTag({ name: "Independent", }); expect(response).toEqual({ type: "tag", id: "105", name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("createTag (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "test", companies: [{ company_id: "123" }] }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.createTag({ - name: "test", - companies: [ + users: [ { - company_id: "123", + id: "6329e838deab40166d1a53f7", + tagged: true, }, ], - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("createTag (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "test", users: [{ id: "123" }] }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.createTag({ - name: "test", - users: [ + companies: [ { - id: "123", + id: "valid-123", + tagged: true, }, ], }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); }); - test("createTag (5)", async () => { + test("createTag (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -844,13 +768,13 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.createTag({ + return await client.preview.tags.createTag({ name: "name", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); - test("createTag (6)", async () => { + test("createTag (4)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -870,36 +794,10 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.createTag({ - name: "name", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createTag (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.createTag({ + return await client.preview.tags.createTag({ name: "name", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("findTag (1)", async () => { @@ -911,27 +809,16 @@ describe("TagsClient", () => { environment: server.baseUrl, }); - const rawResponseBody = { - type: "tag", - id: "113", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; + const rawResponseBody = { type: "tag", id: "113", name: "Manual tag" }; server.mockEndpoint().get("/tags/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.tags.findTag({ + const response = await client.preview.tags.findTag({ id: "123", }); expect(response).toEqual({ type: "tag", id: "113", name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, }); }); @@ -948,10 +835,10 @@ describe("TagsClient", () => { server.mockEndpoint().get("/tags/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.tags.findTag({ + return await client.preview.tags.findTag({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("findTag (3)", async () => { @@ -967,10 +854,10 @@ describe("TagsClient", () => { server.mockEndpoint().get("/tags/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.tags.findTag({ + return await client.preview.tags.findTag({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("deleteTag (1)", async () => { @@ -984,7 +871,7 @@ describe("TagsClient", () => { server.mockEndpoint().delete("/tags/123").respondWith().statusCode(200).build(); - const response = await client.unstable.tags.deleteTag({ + const response = await client.preview.tags.deleteTag({ id: "123", }); expect(response).toEqual(undefined); @@ -1003,10 +890,10 @@ describe("TagsClient", () => { server.mockEndpoint().delete("/tags/id").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.tags.deleteTag({ + return await client.preview.tags.deleteTag({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); test("deleteTag (3)", async () => { @@ -1022,10 +909,10 @@ describe("TagsClient", () => { server.mockEndpoint().delete("/tags/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.tags.deleteTag({ + return await client.preview.tags.deleteTag({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("deleteTag (4)", async () => { @@ -1041,10 +928,10 @@ describe("TagsClient", () => { server.mockEndpoint().delete("/tags/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.tags.deleteTag({ + return await client.preview.tags.deleteTag({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("attachTagToTicket (1)", async () => { @@ -1061,7 +948,7 @@ describe("TagsClient", () => { id: "121", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1072,7 +959,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.attachTagToTicket({ + const response = await client.preview.tags.attachTagToTicket({ ticket_id: "64619700005694", id: "7522907", admin_id: "780", @@ -1083,8 +970,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1103,7 +990,7 @@ describe("TagsClient", () => { id: "121", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1114,7 +1001,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.attachTagToTicket({ + const response = await client.preview.tags.attachTagToTicket({ ticket_id: "64619700005694", id: "7522907", admin_id: "780", @@ -1125,8 +1012,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1151,12 +1038,12 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.attachTagToTicket({ + return await client.preview.tags.attachTagToTicket({ ticket_id: "ticket_id", id: "id", admin_id: "admin_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("attachTagToTicket (4)", async () => { @@ -1179,12 +1066,12 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.attachTagToTicket({ + return await client.preview.tags.attachTagToTicket({ ticket_id: "ticket_id", id: "id", admin_id: "admin_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("detachTagFromTicket (1)", async () => { @@ -1201,7 +1088,7 @@ describe("TagsClient", () => { id: "124", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1212,7 +1099,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.detachTagFromTicket({ + const response = await client.preview.tags.detachTagFromTicket({ ticket_id: "64619700005694", id: "7522907", admin_id: "123", @@ -1223,8 +1110,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1243,7 +1130,7 @@ describe("TagsClient", () => { id: "124", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1254,7 +1141,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.detachTagFromTicket({ + const response = await client.preview.tags.detachTagFromTicket({ ticket_id: "64619700005694", id: "7522907", admin_id: "123", @@ -1265,8 +1152,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1285,7 +1172,7 @@ describe("TagsClient", () => { id: "124", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1296,7 +1183,7 @@ describe("TagsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tags.detachTagFromTicket({ + const response = await client.preview.tags.detachTagFromTicket({ ticket_id: "64619700005694", id: "7522907", admin_id: "123", @@ -1307,8 +1194,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1333,12 +1220,12 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.detachTagFromTicket({ + return await client.preview.tags.detachTagFromTicket({ ticket_id: "ticket_id", id: "id", admin_id: "admin_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("detachTagFromTicket (5)", async () => { @@ -1361,11 +1248,11 @@ describe("TagsClient", () => { .build(); await expect(async () => { - return await client.unstable.tags.detachTagFromTicket({ + return await client.preview.tags.detachTagFromTicket({ ticket_id: "ticket_id", id: "id", admin_id: "admin_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/preview/teams.test.ts b/tests/wire/preview/teams.test.ts new file mode 100644 index 00000000..ead36b58 --- /dev/null +++ b/tests/wire/preview/teams.test.ts @@ -0,0 +1,449 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Intercom from "../../../src/api/index"; +import { IntercomClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("TeamsClient", () => { + test("getTeamMetrics (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "team_metric.list", + data: [ + { type: "team_metric", admin_id: "123", open: 5, idle: 2, snoozed: 1 }, + { type: "team_metric", admin_id: "456", open: 3, idle: 0, snoozed: 2 }, + ], + }; + server.mockEndpoint().get("/teams/42/metrics").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.teams.getTeamMetrics({ + team_id: "42", + idle_threshold: 1800, + }); + expect(response).toEqual({ + type: "team_metric.list", + data: [ + { + type: "team_metric", + admin_id: "123", + open: 5, + idle: 2, + snoozed: 1, + }, + { + type: "team_metric", + admin_id: "456", + open: 3, + idle: 0, + snoozed: 2, + }, + ], + }); + }); + + test("getTeamMetrics (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/teams/team_id/metrics") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.teams.getTeamMetrics({ + team_id: "team_id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("getTeamMetrics (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .get("/teams/team_id/metrics") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.teams.getTeamMetrics({ + team_id: "team_id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("getTeamMetrics (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/teams/team_id/metrics") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.teams.getTeamMetrics({ + team_id: "team_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("listTeams (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "team.list", + teams: [ + { + type: "team", + id: "814865", + name: "Example Team", + admin_ids: [493881], + admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [814865] }, + assignment_limit: 10, + distribution_method: "round_robin", + }, + ], + }; + server.mockEndpoint().get("/teams").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.teams.listTeams(); + expect(response).toEqual({ + type: "team.list", + teams: [ + { + type: "team", + id: "814865", + name: "Example Team", + admin_ids: [493881], + admin_priority_level: { + primary_admin_ids: [493881], + secondary_admin_ids: [814865], + }, + assignment_limit: 10, + distribution_method: "round_robin", + }, + ], + }); + }); + + test("listTeams (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/teams").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.teams.listTeams(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveTeam (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "team", + id: "991267902", + name: "team 1", + admin_ids: [493881], + admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [814865] }, + assignment_limit: 10, + distribution_method: "round_robin", + }; + server.mockEndpoint().get("/teams/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.teams.retrieveTeam({ + id: "123", + }); + expect(response).toEqual({ + type: "team", + id: "991267902", + name: "team 1", + admin_ids: [493881], + admin_priority_level: { + primary_admin_ids: [493881], + secondary_admin_ids: [814865], + }, + assignment_limit: 10, + distribution_method: "round_robin", + }); + }); + + test("retrieveTeam (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/teams/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.teams.retrieveTeam({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("retrieveTeam (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().get("/teams/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.teams.retrieveTeam({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateTeamMembers (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + admin_ids: [493881, 493882], + admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [493882] }, + }; + const rawResponseBody = { + type: "team", + id: "991267902", + name: "team 1", + admin_ids: [493881, 493882], + admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [493882] }, + assignment_limit: 10, + distribution_method: "load_balanced", + }; + server + .mockEndpoint() + .put("/teams/123") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.teams.updateTeamMembers({ + id: "123", + admin_ids: [493881, 493882], + admin_priority_level: { + primary_admin_ids: [493881], + secondary_admin_ids: [493882], + }, + }); + expect(response).toEqual({ + type: "team", + id: "991267902", + name: "team 1", + admin_ids: [493881, 493882], + admin_priority_level: { + primary_admin_ids: [493881], + secondary_admin_ids: [493882], + }, + assignment_limit: 10, + distribution_method: "load_balanced", + }); + }); + + test("updateTeamMembers (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_ids: [1, 1] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/teams/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.teams.updateTeamMembers({ + id: "id", + admin_ids: [1, 1], + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("updateTeamMembers (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_ids: [1, 1] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/teams/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.teams.updateTeamMembers({ + id: "id", + admin_ids: [1, 1], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateTeamMembers (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_ids: [1, 1] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/teams/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.teams.updateTeamMembers({ + id: "id", + admin_ids: [1, 1], + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("updateTeamMembers (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_ids: [1, 1] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/teams/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.teams.updateTeamMembers({ + id: "id", + admin_ids: [1, 1], + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateTeamMembers (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { admin_ids: [1, 1] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/teams/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.teams.updateTeamMembers({ + id: "id", + admin_ids: [1, 1], + }); + }).rejects.toThrow(Intercom.preview.ConflictError); + }); +}); diff --git a/tests/wire/unstable/ticketStates.test.ts b/tests/wire/preview/ticketStates.test.ts similarity index 99% rename from tests/wire/unstable/ticketStates.test.ts rename to tests/wire/preview/ticketStates.test.ts index 21e2b43c..65037045 100644 --- a/tests/wire/unstable/ticketStates.test.ts +++ b/tests/wire/preview/ticketStates.test.ts @@ -249,7 +249,7 @@ describe("TicketStatesClient", () => { }; server.mockEndpoint().get("/ticket_states").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.ticketStates.listTicketStates(); + const response = await client.preview.ticketStates.listTicketStates(); expect(response).toEqual({ type: "list", data: [ @@ -498,7 +498,7 @@ describe("TicketStatesClient", () => { server.mockEndpoint().get("/ticket_states").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.ticketStates.listTicketStates(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.ticketStates.listTicketStates(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/ticketTypeAttributes.test.ts b/tests/wire/preview/ticketTypeAttributes.test.ts similarity index 93% rename from tests/wire/unstable/ticketTypeAttributes.test.ts rename to tests/wire/preview/ticketTypeAttributes.test.ts index 83b633bd..674b5944 100644 --- a/tests/wire/unstable/ticketTypeAttributes.test.ts +++ b/tests/wire/preview/ticketTypeAttributes.test.ts @@ -47,7 +47,7 @@ describe("TicketTypeAttributesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ + const response = await client.preview.ticketTypeAttributes.createTicketTypeAttribute({ ticket_type_id: "ticket_type_id", name: "Attribute Title", description: "Attribute Description", @@ -97,13 +97,13 @@ describe("TicketTypeAttributesClient", () => { .build(); await expect(async () => { - return await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ + return await client.preview.ticketTypeAttributes.createTicketTypeAttribute({ ticket_type_id: "ticket_type_id", name: "name", description: "description", data_type: "string", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateTicketTypeAttribute (1)", async () => { @@ -143,7 +143,7 @@ describe("TicketTypeAttributesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ + const response = await client.preview.ticketTypeAttributes.updateTicketTypeAttribute({ ticket_type_id: "ticket_type_id", id: "id", description: "New Attribute Description", @@ -191,10 +191,10 @@ describe("TicketTypeAttributesClient", () => { .build(); await expect(async () => { - return await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ + return await client.preview.ticketTypeAttributes.updateTicketTypeAttribute({ ticket_type_id: "ticket_type_id", id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/ticketTypes.test.ts b/tests/wire/preview/ticketTypes.test.ts similarity index 96% rename from tests/wire/unstable/ticketTypes.test.ts rename to tests/wire/preview/ticketTypes.test.ts index 95efe063..19092dca 100644 --- a/tests/wire/unstable/ticketTypes.test.ts +++ b/tests/wire/preview/ticketTypes.test.ts @@ -67,7 +67,7 @@ describe("TicketTypesClient", () => { }; server.mockEndpoint().get("/ticket_types").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.ticketTypes.listTicketTypes(); + const response = await client.preview.ticketTypes.listTicketTypes(); expect(response).toEqual({ type: "list", data: [ @@ -136,8 +136,8 @@ describe("TicketTypesClient", () => { server.mockEndpoint().get("/ticket_types").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.ticketTypes.listTicketTypes(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + return await client.preview.ticketTypes.listTicketTypes(); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("createTicketType (1)", async () => { @@ -232,7 +232,7 @@ describe("TicketTypesClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.ticketTypes.createTicketType({ + const response = await client.preview.ticketTypes.createTicketType({ key: "value", }); expect(response).toEqual({ @@ -339,10 +339,10 @@ describe("TicketTypesClient", () => { .build(); await expect(async () => { - return await client.unstable.ticketTypes.createTicketType({ + return await client.preview.ticketTypes.createTicketType({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("getTicketType (1)", async () => { @@ -423,7 +423,7 @@ describe("TicketTypesClient", () => { }; server.mockEndpoint().get("/ticket_types/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.ticketTypes.getTicketType({ + const response = await client.preview.ticketTypes.getTicketType({ id: "id", }); expect(response).toEqual({ @@ -510,9 +510,9 @@ describe("TicketTypesClient", () => { server.mockEndpoint().get("/ticket_types/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.ticketTypes.getTicketType({ + return await client.preview.ticketTypes.getTicketType({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/tickets.test.ts b/tests/wire/preview/tickets.test.ts similarity index 57% rename from tests/wire/unstable/tickets.test.ts rename to tests/wire/preview/tickets.test.ts index d1c30b68..16a0a404 100644 --- a/tests/wire/unstable/tickets.test.ts +++ b/tests/wire/preview/tickets.test.ts @@ -21,12 +21,12 @@ describe("TicketsClient", () => { }; const rawResponseBody = { type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, + id: "155", + part_type: "comment", + body: "

Thanks for reaching out, we're looking into it!

", + created_at: 1734537880, + updated_at: 1734537880, + author: { type: "admin", id: "991267940", name: "Ciaran418 Lee", email: "admin418@email.com" }, attachments: [ { type: "upload", @@ -39,6 +39,11 @@ describe("TicketsClient", () => { }, ], redacted: false, + translations: { + original: "en", + en: "

Thanks for reaching out, we're looking into it!

", + fr: "

Merci de nous avoir contactés, nous nous en occupons !

", + }, }; server .mockEndpoint() @@ -49,7 +54,7 @@ describe("TicketsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.replyTicket({ + const response = await client.preview.tickets.replyTicket({ id: "123", body: { message_type: "comment", @@ -60,16 +65,16 @@ describe("TicketsClient", () => { }); expect(response).toEqual({ type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, + id: "155", + part_type: "comment", + body: "

Thanks for reaching out, we're looking into it!

", + created_at: 1734537880, + updated_at: 1734537880, author: { type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", + id: "991267940", + name: "Ciaran418 Lee", + email: "admin418@email.com", }, attachments: [ { @@ -83,6 +88,11 @@ describe("TicketsClient", () => { }, ], redacted: false, + translations: { + original: "en", + en: "

Thanks for reaching out, we're looking into it!

", + fr: "

Merci de nous avoir contact\u00E9s, nous nous en occupons !

", + }, }); }); @@ -120,6 +130,7 @@ describe("TicketsClient", () => { }, ], redacted: false, + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }; server .mockEndpoint() @@ -130,7 +141,7 @@ describe("TicketsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.replyTicket({ + const response = await client.preview.tickets.replyTicket({ id: "123", body: { message_type: "note", @@ -164,10 +175,108 @@ describe("TicketsClient", () => { }, ], redacted: false, + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }); }); test("replyTicket (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + message_type: "note", + type: "admin", + body: "This note will be cross-posted to all linked conversations.", + admin_id: "3156780", + cross_post: true, + }; + const rawResponseBody = { + type: "ticket_part", + id: "155", + part_type: "comment", + body: "

Thanks for reaching out, we're looking into it!

", + created_at: 1734537880, + updated_at: 1734537880, + author: { type: "admin", id: "991267940", name: "Ciaran418 Lee", email: "admin418@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + redacted: false, + translations: { + original: "en", + en: "

Thanks for reaching out, we're looking into it!

", + fr: "

Merci de nous avoir contactés, nous nous en occupons !

", + }, + }; + server + .mockEndpoint() + .post("/tickets/123/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.tickets.replyTicket({ + id: "123", + body: { + message_type: "note", + type: "admin", + body: "This note will be cross-posted to all linked conversations.", + admin_id: "3156780", + cross_post: true, + }, + }); + expect(response).toEqual({ + type: "ticket_part", + id: "155", + part_type: "comment", + body: "

Thanks for reaching out, we're looking into it!

", + created_at: 1734537880, + updated_at: 1734537880, + author: { + type: "admin", + id: "991267940", + name: "Ciaran418 Lee", + email: "admin418@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + redacted: false, + translations: { + original: "en", + en: "

Thanks for reaching out, we're looking into it!

", + fr: "

Merci de nous avoir contact\u00E9s, nous nous en occupons !

", + }, + }); + }); + + test("replyTicket (4)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -204,6 +313,7 @@ describe("TicketsClient", () => { }, ], redacted: false, + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }; server .mockEndpoint() @@ -214,7 +324,7 @@ describe("TicketsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.replyTicket({ + const response = await client.preview.tickets.replyTicket({ id: "123", body: { message_type: "quick_reply", @@ -257,10 +367,15 @@ describe("TicketsClient", () => { }, ], redacted: false, + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }); }); - test("replyTicket (4)", async () => { + test("replyTicket (5)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -276,12 +391,12 @@ describe("TicketsClient", () => { }; const rawResponseBody = { type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, + id: "155", + part_type: "comment", + body: "

Thanks for reaching out, we're looking into it!

", + created_at: 1734537880, + updated_at: 1734537880, + author: { type: "admin", id: "991267940", name: "Ciaran418 Lee", email: "admin418@email.com" }, attachments: [ { type: "upload", @@ -294,6 +409,11 @@ describe("TicketsClient", () => { }, ], redacted: false, + translations: { + original: "en", + en: "

Thanks for reaching out, we're looking into it!

", + fr: "

Merci de nous avoir contactés, nous nous en occupons !

", + }, }; server .mockEndpoint() @@ -304,7 +424,7 @@ describe("TicketsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.replyTicket({ + const response = await client.preview.tickets.replyTicket({ id: "123", body: { message_type: "comment", @@ -315,16 +435,16 @@ describe("TicketsClient", () => { }); expect(response).toEqual({ type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, + id: "155", + part_type: "comment", + body: "

Thanks for reaching out, we're looking into it!

", + created_at: 1734537880, + updated_at: 1734537880, author: { type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", + id: "991267940", + name: "Ciaran418 Lee", + email: "admin418@email.com", }, attachments: [ { @@ -338,10 +458,106 @@ describe("TicketsClient", () => { }, ], redacted: false, + translations: { + original: "en", + en: "

Thanks for reaching out, we're looking into it!

", + fr: "

Merci de nous avoir contact\u00E9s, nous nous en occupons !

", + }, }); }); - test("replyTicket (5)", async () => { + test("replyTicket (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f2971bb69f9f2193bc49", + }; + const rawResponseBody = { + type: "ticket_part", + id: "155", + part_type: "comment", + body: "

Thanks for reaching out, we're looking into it!

", + created_at: 1734537880, + updated_at: 1734537880, + author: { type: "admin", id: "991267940", name: "Ciaran418 Lee", email: "admin418@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + redacted: false, + translations: { + original: "en", + en: "

Thanks for reaching out, we're looking into it!

", + fr: "

Merci de nous avoir contactés, nous nous en occupons !

", + }, + }; + server + .mockEndpoint() + .post("/tickets/123/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.tickets.replyTicket({ + id: "123", + body: { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f2971bb69f9f2193bc49", + }, + }); + expect(response).toEqual({ + type: "ticket_part", + id: "155", + part_type: "comment", + body: "

Thanks for reaching out, we're looking into it!

", + created_at: 1734537880, + updated_at: 1734537880, + author: { + type: "admin", + id: "991267940", + name: "Ciaran418 Lee", + email: "admin418@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + redacted: false, + translations: { + original: "en", + en: "

Thanks for reaching out, we're looking into it!

", + fr: "

Merci de nous avoir contact\u00E9s, nous nous en occupons !

", + }, + }); + }); + + test("replyTicket (7)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -366,7 +582,7 @@ describe("TicketsClient", () => { .build(); await expect(async () => { - return await client.unstable.tickets.replyTicket({ + return await client.preview.tickets.replyTicket({ id: "id", body: { intercom_user_id: "intercom_user_id", @@ -375,10 +591,10 @@ describe("TicketsClient", () => { body: "body", }, }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); - test("replyTicket (6)", async () => { + test("replyTicket (8)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -403,7 +619,7 @@ describe("TicketsClient", () => { .build(); await expect(async () => { - return await client.unstable.tickets.replyTicket({ + return await client.preview.tickets.replyTicket({ id: "id", body: { intercom_user_id: "intercom_user_id", @@ -412,10 +628,10 @@ describe("TicketsClient", () => { body: "body", }, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); - test("replyTicket (7)", async () => { + test("replyTicket (9)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -440,7 +656,7 @@ describe("TicketsClient", () => { .build(); await expect(async () => { - return await client.unstable.tickets.replyTicket({ + return await client.preview.tickets.replyTicket({ id: "id", body: { intercom_user_id: "intercom_user_id", @@ -449,10 +665,10 @@ describe("TicketsClient", () => { body: "body", }, }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); - test("enqueueCreateTicket (1)", async () => { + test("linkConversationToTicket (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -460,57 +676,641 @@ describe("TicketsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { ticket_type_id: "1234", contacts: [{ id: "6762f2d81bb69f9f2193bc54" }] }; + const rawRequestBody = { conversation_id: "204" }; const rawResponseBody = { - type: "job", - id: "20", - url: "https://api.intercom.io/jobs/status/20", - status: "pending", - resource_type: "ticket", - resource_id: "resource_id", - resource_url: "http://api.intercom.io/tickets/123", + type: "conversation", + id: "204", + title: "Conversation Title", + created_at: 1734537715, + updated_at: 1734537740, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 0, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { type: "plan", id: "269315", name: "Pro" }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, + }, + ], + }, + notes: { + type: "note.list", + notes: [ + { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, + ], + }, + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, + teammate: { type: "contact", id: "1a2b3c" }, + }, + source: { + type: "conversation", + id: "403918350", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], + subject: "", + body: "

Customer report

", + author: { type: "admin", id: "991267645", name: "Ciaran176 Lee", email: "admin176@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f1261bb69f9f2193bba7", external_id: "70" }], + }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { + paid_subscriber: { type: "order.list", instances: [] }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], + assigned_team_first_response_time_in_office_hours: [ + { team_id: 100, team_name: "Team One", response_time: 2310 }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ + { + type: "conversation_part", + id: "3", + part_type: "comment", + body: "

Okay!

", + created_at: 1663597223, + updated_at: 1663597260, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + external_id: "abcd1234", + redacted: false, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + ], + total_count: 1, + }, + linked_objects: { + type: "list", + total_count: 1, + has_more: false, + data: [{ type: "ticket", id: "207", category: "Tracker" }], + }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: true, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; server .mockEndpoint() - .post("/tickets/enqueue") + .post("/tickets/64619700005694/linked_conversations") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.enqueueCreateTicket({ - ticket_type_id: "1234", - contacts: [ - { - id: "6762f2d81bb69f9f2193bc54", - }, - ], + const response = await client.preview.tickets.linkConversationToTicket({ + ticket_id: "64619700005694", + conversation_id: "204", }); expect(response).toEqual({ - type: "job", - id: "20", - url: "https://api.intercom.io/jobs/status/20", - status: "pending", - resource_type: "ticket", - resource_id: "resource_id", - resource_url: "http://api.intercom.io/tickets/123", - }); - }); - - test("enqueueCreateTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; - const rawResponseBody = { key: "value" }; + type: "conversation", + id: "204", + title: "Conversation Title", + created_at: 1734537715, + updated_at: 1734537740, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 0, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, + }, + ], + }, + notes: { + type: "note.list", + notes: [ + { + type: "note", + id: "17495962", + created_at: 1674589321, + body: "

Text for the note.

", + }, + ], + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + }, + teammate: { + type: "contact", + id: "1a2b3c", + }, + }, + source: { + type: "conversation", + id: "403918350", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], + subject: "", + body: "

Customer report

", + author: { + type: "admin", + id: "991267645", + name: "Ciaran176 Lee", + email: "admin176@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f1261bb69f9f2193bba7", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + teammates: [ + { + type: "contact", + id: "1a2b3c", + }, + ], + }, + custom_attributes: { + paid_subscriber: { + type: "order.list", + instances: [], + }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + sla_status: "hit", + }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, + ], + assigned_team_first_response_time_in_office_hours: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ + { + type: "conversation_part", + id: "3", + part_type: "comment", + body: "

Okay!

", + created_at: 1663597223, + updated_at: 1663597260, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + external_id: "abcd1234", + redacted: false, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + ], + total_count: 1, + }, + linked_objects: { + type: "list", + total_count: 1, + has_more: false, + data: [ + { + type: "ticket", + id: "207", + category: "Tracker", + }, + ], + }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: true, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], + }); + }); + + test("linkConversationToTicket (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "conversation_id" }; + const rawResponseBody = { key: "value" }; server .mockEndpoint() - .post("/tickets/enqueue") + .post("/tickets/ticket_id/linked_conversations") .jsonBody(rawRequestBody) .respondWith() .statusCode(400) @@ -518,21 +1318,14 @@ describe("TicketsClient", () => { .build(); await expect(async () => { - return await client.unstable.tickets.enqueueCreateTicket({ - ticket_type_id: "ticket_type_id", - contacts: [ - { - id: "id", - }, - { - id: "id", - }, - ], + return await client.preview.tickets.linkConversationToTicket({ + ticket_id: "ticket_id", + conversation_id: "conversation_id", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); - test("enqueueCreateTicket (3)", async () => { + test("linkConversationToTicket (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -540,11 +1333,11 @@ describe("TicketsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; + const rawRequestBody = { conversation_id: "conversation_id" }; const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; server .mockEndpoint() - .post("/tickets/enqueue") + .post("/tickets/ticket_id/linked_conversations") .jsonBody(rawRequestBody) .respondWith() .statusCode(401) @@ -552,21 +1345,41 @@ describe("TicketsClient", () => { .build(); await expect(async () => { - return await client.unstable.tickets.enqueueCreateTicket({ - ticket_type_id: "ticket_type_id", - contacts: [ - { - id: "id", - }, - { - id: "id", - }, - ], + return await client.preview.tickets.linkConversationToTicket({ + ticket_id: "ticket_id", + conversation_id: "conversation_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); - test("getTicket (1)", async () => { + test("linkConversationToTicket (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { conversation_id: "conversation_id" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/tickets/ticket_id/linked_conversations") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.linkConversationToTicket({ + ticket_id: "ticket_id", + conversation_id: "conversation_id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("unlinkConversationFromTicket (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -576,111 +1389,1339 @@ describe("TicketsClient", () => { }); const rawResponseBody = { - type: "ticket", - id: "631", - ticket_id: "38", - category: "Back-office", - ticket_attributes: { _default_title_: "attribute_value", _default_description_: "ticket_attributes" }, - ticket_state: { - type: "ticket_state", - id: "8537", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", + type: "conversation", + id: "204", + title: "Conversation Title", + created_at: 1734537715, + updated_at: 1734537752, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 0, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { type: "plan", id: "269315", name: "Pro" }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag" }] }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, + }, + ], + }, + notes: { + type: "note.list", + notes: [ + { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, + ], + }, }, - ticket_type: { - type: "ticket_type", - id: "95", - category: "Back-office", - name: "my-ticket-type-30", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id702_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537973, - updated_at: 1734537973, + tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, + teammate: { type: "contact", id: "1a2b3c" }, }, - contacts: { - type: "contact.list", - contacts: [ + source: { + type: "conversation", + id: "403918350", + delivered_as: "admin_initiated", + recipients: [{ type: "to", email: "user@example.com" }], + reply_to: [{ email: "replies@example.com", name: "Support Team" }], + subject: "", + body: "

Customer report

", + author: { type: "admin", id: "991267645", name: "Ciaran176 Lee", email: "admin176@email.com" }, + attachments: [ { - type: "contact", - id: "6762f2f61bb69f9f2193bc59", - external_id: "b16afa36-2637-4880-adee-a46d145bc27f", + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, }, ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [{ type: "from", email_address: "jdoe@example.com", name: "Joe Example" }], + history: "
On Jan 28, wrote:
Previous thread
", + }, }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537974, - updated_at: 1734537976, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ + contacts: { + type: "contact.list", + contacts: [{ type: "contact", id: "6762f1261bb69f9f2193bba7", external_id: "70" }], + }, + teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, + custom_attributes: { + paid_subscriber: { type: "order.list", instances: [] }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [{ team_id: 100, team_name: "Team One", response_time: 2310 }], + assigned_team_first_response_time_in_office_hours: [ + { team_id: 100, team_name: "Team One", response_time: 2310 }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ { - type: "ticket_part", - id: "185", - part_type: "ticket_state_updated_by_admin", + type: "conversation_part", + id: "3", + part_type: "comment", body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537975, - updated_at: 1734537975, - author: { type: "admin", id: "991268047", name: "Ciaran509 Lee", email: "admin509@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], + created_at: 1663597223, + updated_at: 1663597260, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, - is_shared: false, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ai_topics: { type: "ai_topics", topics: [{ type: "ai_topic", topic_name: "Billing" }] }, + ai_agent_participated: true, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { email: "user@example.com", "company.name": "Acme Inc" }, + }, + channel: { initial: "messenger", current: "messenger" }, + external_references: [ + { type: "zendesk_ticket", id: "3633338" }, + { type: "zendesk_sunshine_conversation", id: "abc-def-uuid" }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { admin_id: "991267715" }, + reviewer: { admin_id: "884120017" }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { type: "admin", admin_id: "884120017" }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [{ evaluator_id: "54321" }], + }, + ], }; - server.mockEndpoint().get("/tickets/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + server + .mockEndpoint() + .delete("/tickets/64619700005694/linked_conversations/204") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); - const response = await client.unstable.tickets.getTicket({ - id: "id", + const response = await client.preview.tickets.unlinkConversationFromTicket({ + ticket_id: "64619700005694", + id: "204", }); expect(response).toEqual({ - type: "ticket", - id: "631", - ticket_id: "38", - category: "Back-office", - ticket_attributes: { - _default_title_: "attribute_value", - _default_description_: "ticket_attributes", - }, - ticket_state: { + type: "conversation", + id: "204", + title: "Conversation Title", + created_at: 1734537715, + updated_at: 1734537752, + waiting_since: 1663597260, + snoozed_until: 1663597260, + open: true, + state: "open", + read: true, + priority: "none", + admin_assignee_id: 0, + team_assignee_id: 5017691, + company: { + type: "company", + id: "531ee472cce572a6ec000006", + name: "Blue Sun", + app_id: "ecahpwf5", + plan: { + type: "plan", + id: "269315", + name: "Pro", + }, + company_id: "6", + remote_created_at: 1663597223, + created_at: 1663597223, + updated_at: 1663597223, + last_request_at: 1663597223, + size: 100, + website: "https://www.intercom.com", + industry: "Software", + monthly_spend: 100, + session_count: 100, + user_count: 100, + custom_attributes: { + paid_subscriber: "custom_attributes", + monthly_spend: "custom_attributes", + team_mates: "custom_attributes", + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + }, + ], + }, + segments: { + type: "segment.list", + segments: [ + { + id: "56203d253cba154d39010062", + name: "Active", + created_at: 1394621988, + updated_at: 1394622004, + count: 3, + }, + ], + }, + notes: { + type: "note.list", + notes: [ + { + type: "note", + id: "17495962", + created_at: 1674589321, + body: "

Text for the note.

", + }, + ], + }, + }, + tags: { + type: "tag.list", + tags: [ + { + type: "tag", + id: "123456", + name: "Test tag", + applied_at: 1663597223, + }, + ], + }, + conversation_rating: { + rating: 5, + remark: "", + created_at: 1671028894, + updated_at: 1671028894, + contact: { + type: "contact", + id: "5ba682d23d7cf92bef87bfd4", + external_id: "70", + }, + teammate: { + type: "contact", + id: "1a2b3c", + }, + }, + source: { + type: "conversation", + id: "403918350", + delivered_as: "admin_initiated", + recipients: [ + { + type: "to", + email: "user@example.com", + }, + ], + reply_to: [ + { + email: "replies@example.com", + name: "Support Team", + }, + ], + subject: "", + body: "

Customer report

", + author: { + type: "admin", + id: "991267645", + name: "Ciaran176 Lee", + email: "admin176@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + url: "https://intercom.help/company/article/123", + redacted: false, + email_message_metadata: { + message_id: "", + subject: "Question about my order", + email_address_headers: [ + { + type: "from", + email_address: "jdoe@example.com", + name: "Joe Example", + }, + ], + history: "
On Jan 28, wrote:
Previous thread
", + }, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f1261bb69f9f2193bba7", + external_id: "70", + }, + ], + }, + teammates: { + type: "admin.list", + teammates: [ + { + type: "contact", + id: "1a2b3c", + }, + ], + }, + custom_attributes: { + paid_subscriber: { + type: "order.list", + instances: [], + }, + monthly_spend: "155.5", + team_mates: 9, + start_date_iso8601: "2023-03-04T09:46:14Z", + end_date_timestamp: 1677923174, + "CX Score rating": 4, + "CX Score explanation": + "The conversation was resolved quickly and the customer expressed satisfaction with the outcome.", + }, + first_contact_reply: { + created_at: 1663597223, + type: "conversation", + url: "https://developers.intercom.com/", + }, + sla_applied: { + type: "conversation_sla_summary", + sla_name: "", + sla_status: "hit", + }, + statistics: { + type: "conversation_statistics", + time_to_assignment: 2310, + time_to_admin_reply: 2310, + time_to_first_close: 2310, + time_to_last_close: 2310, + median_time_to_reply: 2310, + first_contact_reply_at: 1663597233, + first_assignment_at: 1663597233, + first_admin_reply_at: 1663597233, + first_close_at: 1663597233, + last_assignment_at: 1663597233, + last_assignment_admin_reply_at: 1663597233, + last_contact_reply_at: 1663597233, + last_admin_reply_at: 1663597233, + last_close_at: 1663597233, + last_closed_by_id: "c3po", + count_reopens: 1, + count_assignments: 1, + count_conversation_parts: 1, + assigned_team_first_response_time: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, + ], + assigned_team_first_response_time_in_office_hours: [ + { + team_id: 100, + team_name: "Team One", + response_time: 2310, + }, + ], + handling_time: 2310, + adjusted_handling_time: 1800, + }, + conversation_parts: { + type: "conversation_part.list", + conversation_parts: [ + { + type: "conversation_part", + id: "3", + part_type: "comment", + body: "

Okay!

", + created_at: 1663597223, + updated_at: 1663597260, + notified_at: 1663597260, + admin_assignee_id: 991267715, + team_assignee_id: 5017691, + external_id: "abcd1234", + redacted: false, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + ], + total_count: 1, + }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ai_topics: { + type: "ai_topics", + topics: [ + { + type: "ai_topic", + topic_name: "Billing", + }, + ], + }, + ai_agent_participated: true, + ai_agent: { + source_type: "essentials_plan_setup", + source_title: "My AI Workflow", + last_answer_type: "ai_answer", + resolution_state: "assumed_resolution", + rating: 4, + rating_remark: "Very helpful!", + created_at: 1663597260, + updated_at: 1663597260, + content_sources: { + type: "content_source.list", + total_count: 1, + content_sources: [ + { + url: "/fin-ai-agent/content?content=content_snippet&id=3234924", + title: "My internal content snippet", + locale: "en", + }, + ], + }, + }, + sales_agent_participated: false, + sales_agent: { + outcome: "qualified", + routing_outcome: "enterprise_sales", + collected_data: { + email: "user@example.com", + "company.name": "Acme Inc", + }, + }, + channel: { + initial: "messenger", + current: "messenger", + }, + external_references: [ + { + type: "zendesk_ticket", + id: "3633338", + }, + { + type: "zendesk_sunshine_conversation", + id: "abc-def-uuid", + }, + ], + monitor_evaluations: [ + { + monitor_id: "12345", + monitor_name: "Customer complaint handling", + monitor_type: "prompt", + result: "flagged", + explanation: "The customer mentioned wanting a refund without resolution.", + evaluated_at: 1719493065, + }, + ], + scorecards: [ + { + scorecard_id: "67890", + scorecard_version_id: "67891", + name: "Standard QA Review", + scorecard_type: "human", + passed: true, + score: 0.85, + ai_score: 0.9, + evaluated_at: 1719493065, + reviewed_teammate: { + admin_id: "991267715", + }, + reviewer: { + admin_id: "884120017", + }, + review_status: "unreviewed", + notes: [ + { + id: "9001", + created_at: 1734537900, + updated_at: 1734537900, + author: { + type: "admin", + admin_id: "884120017", + }, + body: "Great empathy in the second reply.", + }, + ], + evaluators: [ + { + evaluator_id: "54321", + }, + ], + }, + ], + }); + }); + + test("unlinkConversationFromTicket (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/tickets/ticket_id/linked_conversations/id") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.unlinkConversationFromTicket({ + ticket_id: "ticket_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("unlinkConversationFromTicket (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/tickets/ticket_id/linked_conversations/id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.unlinkConversationFromTicket({ + ticket_id: "ticket_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("unlinkConversationFromTicket (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/tickets/ticket_id/linked_conversations/id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.unlinkConversationFromTicket({ + ticket_id: "ticket_id", + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("enqueueCreateTicket (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { ticket_type_id: "1234", contacts: [{ id: "6762f2d81bb69f9f2193bc54" }] }; + const rawResponseBody = { + type: "job", + id: "20", + url: "https://api.intercom.io/jobs/status/20", + status: "pending", + resource_type: "ticket", + resource_id: "resource_id", + resource_url: "http://api.intercom.io/tickets/123", + }; + server + .mockEndpoint() + .post("/tickets/enqueue") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.tickets.enqueueCreateTicket({ + ticket_type_id: "1234", + contacts: [ + { + id: "6762f2d81bb69f9f2193bc54", + }, + ], + }); + expect(response).toEqual({ + type: "job", + id: "20", + url: "https://api.intercom.io/jobs/status/20", + status: "pending", + resource_type: "ticket", + resource_id: "resource_id", + resource_url: "http://api.intercom.io/tickets/123", + }); + }); + + test("enqueueCreateTicket (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/tickets/enqueue") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.enqueueCreateTicket({ + ticket_type_id: "ticket_type_id", + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("enqueueCreateTicket (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .post("/tickets/enqueue") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.enqueueCreateTicket({ + ticket_type_id: "ticket_type_id", + contacts: [ + { + id: "id", + }, + { + id: "id", + }, + ], + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("getTicket (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { + type: "ticket", + id: "631", + ticket_id: "38", + category: "Back-office", + ticket_attributes: { _default_title_: "attribute_value", _default_description_: "ticket_attributes" }, + ticket_state: { + type: "ticket_state", + id: "8537", + category: "submitted", + internal_label: "Submitted", + external_label: "Submitted", + }, + ticket_type: { + type: "ticket_type", + id: "95", + category: "Back-office", + name: "my-ticket-type-30", + description: "my ticket type description is awesome.", + icon: "🦁", + workspace_id: "this_is_an_id702_that_should_be_at_least_", + ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, + ticket_states: { type: "list", data: [] }, + archived: false, + created_at: 1734537973, + updated_at: 1734537973, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f2f61bb69f9f2193bc59", + external_id: "b16afa36-2637-4880-adee-a46d145bc27f", + }, + ], + }, + admin_assignee_id: 0, + team_assignee_id: 0, + created_at: 1734537974, + updated_at: 1734537976, + open: true, + snoozed_until: 1663597260, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ticket_parts: { + type: "ticket_part.list", + ticket_parts: [ + { + type: "ticket_part", + id: "185", + part_type: "ticket_state_updated_by_admin", + body: "

Okay!

", + previous_ticket_state: "submitted", + ticket_state: "submitted", + created_at: 1734537975, + updated_at: 1734537975, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { type: "admin", id: "991268047", name: "Ciaran509 Lee", email: "admin509@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + ], + total_count: 1, + }, + is_shared: false, + previous_ticket_state_id: "7493", + }; + server.mockEndpoint().get("/tickets/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.tickets.getTicket({ + id: "id", + }); + expect(response).toEqual({ + type: "ticket", + id: "631", + ticket_id: "38", + category: "Back-office", + ticket_attributes: { + _default_title_: "attribute_value", + _default_description_: "ticket_attributes", + }, + ticket_state: { + type: "ticket_state", + id: "8537", + category: "submitted", + internal_label: "Submitted", + external_label: "Submitted", + }, + ticket_type: { + type: "ticket_type", + id: "95", + category: "Back-office", + name: "my-ticket-type-30", + description: "my ticket type description is awesome.", + icon: "\uD83E\uDD81", + workspace_id: "this_is_an_id702_that_should_be_at_least_", + ticket_type_attributes: { + type: "list", + ticket_type_attributes: [], + }, + ticket_states: { + type: "list", + data: [], + }, + archived: false, + created_at: 1734537973, + updated_at: 1734537973, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f2f61bb69f9f2193bc59", + external_id: "b16afa36-2637-4880-adee-a46d145bc27f", + }, + ], + }, + admin_assignee_id: 0, + team_assignee_id: 0, + created_at: 1734537974, + updated_at: 1734537976, + open: true, + snoozed_until: 1663597260, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ticket_parts: { + type: "ticket_part.list", + ticket_parts: [ + { + type: "ticket_part", + id: "185", + part_type: "ticket_state_updated_by_admin", + body: "

Okay!

", + previous_ticket_state: "submitted", + ticket_state: "submitted", + created_at: 1734537975, + updated_at: 1734537975, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991268047", + name: "Ciaran509 Lee", + email: "admin509@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + ], + total_count: 1, + }, + is_shared: false, + previous_ticket_state_id: "7493", + }); + }); + + test("getTicket (2)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().get("/tickets/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.tickets.getTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateTicket (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, + ticket_state_id: "123", + open: true, + snoozed_until: 1673609604, + admin_id: 991268011, + assignee_id: "123", + priority: "high", + }; + const rawResponseBody = { + type: "ticket", + id: "627", + ticket_id: "34", + category: "Back-office", + ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, + ticket_state: { + type: "ticket_state", + id: "8498", + category: "in_progress", + internal_label: "In progress", + external_label: "In progress", + }, + ticket_type: { + type: "ticket_type", + id: "90", + category: "Back-office", + name: "my-ticket-type-25", + description: "my ticket type description is awesome.", + icon: "🦁", + workspace_id: "this_is_an_id692_that_should_be_at_least_", + ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, + ticket_states: { type: "list", data: [] }, + archived: false, + created_at: 1734537948, + updated_at: 1734537948, + }, + contacts: { + type: "contact.list", + contacts: [ + { + type: "contact", + id: "6762f2dd1bb69f9f2193bc55", + external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", + }, + ], + }, + admin_assignee_id: 991268013, + team_assignee_id: 0, + created_at: 1734537950, + updated_at: 1734537955, + open: true, + snoozed_until: 1734627600, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + ticket_parts: { + type: "ticket_part.list", + ticket_parts: [ + { + type: "ticket_part", + id: "176", + part_type: "ticket_state_updated_by_admin", + body: "

Okay!

", + previous_ticket_state: "submitted", + ticket_state: "submitted", + created_at: 1734537951, + updated_at: 1734537951, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + { + type: "ticket_part", + id: "177", + part_type: "ticket_attribute_updated_by_admin", + body: "

Okay!

", + created_at: 1734537953, + updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "991268012", + name: "Fin", + email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + updated_attribute_data: { + attribute: { type: "attribute", id: "10", label: "Photo" }, + value: { type: "value", id: [2], label: ["photo.png"] }, + }, + }, + { + type: "ticket_part", + id: "178", + part_type: "ticket_attribute_updated_by_admin", + body: "

Okay!

", + created_at: 1734537953, + updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "991268012", + name: "Fin", + email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + updated_attribute_data: { + attribute: { type: "attribute", id: "7", label: "Progress" }, + value: { type: "value", id: "Fast", label: "Fast" }, + }, + }, + { + type: "ticket_part", + id: "179", + part_type: "ticket_state_updated_by_admin", + body: "

Okay!

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

Hello

", fr: "

Bonjour

" }, + }, + { + type: "ticket_part", + id: "180", + part_type: "assignment", + body: "

Okay!

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

Hello

", fr: "

Bonjour

" }, + }, + { + type: "ticket_part", + id: "181", + part_type: "snoozed", + body: "

Okay!

", + created_at: 1734537955, + updated_at: 1734537955, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "991268012", + name: "Fin", + email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, + }, + ], + total_count: 6, + }, + is_shared: false, + previous_ticket_state_id: "7493", + }; + server + .mockEndpoint() + .put("/tickets/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.preview.tickets.updateTicket({ + id: "id", + ticket_attributes: { + _default_title_: "example", + _default_description_: "there is a problem", + }, + ticket_state_id: "123", + open: true, + snoozed_until: 1673609604, + admin_id: 991268011, + assignee_id: "123", + priority: "high", + }); + expect(response).toEqual({ + type: "ticket", + id: "627", + ticket_id: "34", + category: "Back-office", + ticket_attributes: { + _default_title_: "example", + _default_description_: "there is a problem", + }, + ticket_state: { type: "ticket_state", - id: "8537", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", + id: "8498", + category: "in_progress", + internal_label: "In progress", + external_label: "In progress", }, ticket_type: { type: "ticket_type", - id: "95", + id: "90", category: "Back-office", - name: "my-ticket-type-30", + name: "my-ticket-type-25", description: "my ticket type description is awesome.", icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id702_that_should_be_at_least_", + workspace_id: "this_is_an_id692_that_should_be_at_least_", ticket_type_attributes: { type: "list", ticket_type_attributes: [], @@ -690,52 +2731,259 @@ describe("TicketsClient", () => { data: [], }, archived: false, - created_at: 1734537973, - updated_at: 1734537973, + created_at: 1734537948, + updated_at: 1734537948, }, contacts: { type: "contact.list", contacts: [ { type: "contact", - id: "6762f2f61bb69f9f2193bc59", - external_id: "b16afa36-2637-4880-adee-a46d145bc27f", + id: "6762f2dd1bb69f9f2193bc55", + external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", + }, + ], + }, + admin_assignee_id: 991268013, + team_assignee_id: 0, + created_at: 1734537950, + updated_at: 1734537955, + open: true, + snoozed_until: 1734627600, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [ + { + id: "7583", + }, + ], + }, + ticket_parts: { + type: "ticket_part.list", + ticket_parts: [ + { + type: "ticket_part", + id: "176", + part_type: "ticket_state_updated_by_admin", + body: "

Okay!

", + previous_ticket_state: "submitted", + ticket_state: "submitted", + created_at: 1734537951, + updated_at: 1734537951, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { + type: "admin", + id: "991268011", + name: "Ciaran477 Lee", + email: "admin477@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + }, + { + type: "ticket_part", + id: "177", + part_type: "ticket_attribute_updated_by_admin", + body: "

Okay!

", + created_at: 1734537953, + updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "991268012", + name: "Fin", + email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + updated_attribute_data: { + attribute: { + type: "attribute", + id: "10", + label: "Photo", + }, + value: { + type: "value", + id: [2], + label: ["photo.png"], + }, + }, + }, + { + type: "ticket_part", + id: "178", + part_type: "ticket_attribute_updated_by_admin", + body: "

Okay!

", + created_at: 1734537953, + updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, + author: { + type: "bot", + id: "991268012", + name: "Fin", + email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + external_id: "abcd1234", + redacted: false, + app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, + updated_attribute_data: { + attribute: { + type: "attribute", + id: "7", + label: "Progress", + }, + value: { + type: "value", + id: "Fast", + label: "Fast", + }, + }, + }, + { + type: "ticket_part", + id: "179", + part_type: "ticket_state_updated_by_admin", + body: "

Okay!

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

Hello

", + fr: "

Bonjour

", + }, }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537974, - updated_at: 1734537976, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ { - id: "7583", + type: "ticket_part", + id: "180", + part_type: "assignment", + body: "

Okay!

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

Hello

", + fr: "

Bonjour

", + }, }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ { type: "ticket_part", - id: "185", - part_type: "ticket_state_updated_by_admin", + id: "181", + part_type: "snoozed", body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537975, - updated_at: 1734537975, + created_at: 1734537955, + updated_at: 1734537955, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { - type: "admin", - id: "991268047", - name: "Ciaran509 Lee", - email: "admin509@email.com", + type: "bot", + id: "991268012", + name: "Fin", + email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", }, attachments: [ { @@ -750,35 +2998,22 @@ describe("TicketsClient", () => { ], external_id: "abcd1234", redacted: false, - app_package_code: "test-integration", + app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], - total_count: 1, + total_count: 6, }, is_shared: false, + previous_ticket_state_id: "7493", }); }); - test("getTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/tickets/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tickets.getTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateTicket (1)", async () => { + test("updateTicket (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -789,8 +3024,6 @@ describe("TicketsClient", () => { const rawRequestBody = { ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, ticket_state_id: "123", - open: true, - snoozed_until: 1673609604, admin_id: 991268011, assignee_id: "123", }; @@ -831,8 +3064,8 @@ describe("TicketsClient", () => { }, ], }, - admin_assignee_id: "991268013", - team_assignee_id: "0", + admin_assignee_id: 991268013, + team_assignee_id: 0, created_at: 1734537950, updated_at: 1734537955, open: true, @@ -850,6 +3083,8 @@ describe("TicketsClient", () => { ticket_state: "submitted", created_at: 1734537951, updated_at: 1734537951, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, attachments: [ { @@ -865,6 +3100,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -873,6 +3109,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -893,6 +3131,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, updated_attribute_data: { attribute: { type: "attribute", id: "10", label: "Photo" }, value: { type: "value", id: [2], label: ["photo.png"] }, @@ -905,6 +3144,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -925,6 +3166,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, updated_attribute_data: { attribute: { type: "attribute", id: "7", label: "Progress" }, value: { type: "value", id: "Fast", label: "Fast" }, @@ -939,6 +3181,8 @@ describe("TicketsClient", () => { ticket_state: "in_progress", created_at: 1734537954, updated_at: 1734537954, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -959,6 +3203,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -968,6 +3213,8 @@ describe("TicketsClient", () => { created_at: 1734537954, updated_at: 1734537954, assigned_to: { type: "admin", id: "991268013" }, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, attachments: [ { @@ -983,6 +3230,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -991,6 +3239,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537955, updated_at: 1734537955, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1011,11 +3261,13 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 6, }, is_shared: false, + previous_ticket_state_id: "7493", }; server .mockEndpoint() @@ -1026,15 +3278,13 @@ describe("TicketsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.updateTicket({ + const response = await client.preview.tickets.updateTicket({ id: "id", ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem", }, ticket_state_id: "123", - open: true, - snoozed_until: 1673609604, admin_id: 991268011, assignee_id: "123", }); @@ -1084,8 +3334,8 @@ describe("TicketsClient", () => { }, ], }, - admin_assignee_id: "991268013", - team_assignee_id: "0", + admin_assignee_id: 991268013, + team_assignee_id: 0, created_at: 1734537950, updated_at: 1734537955, open: true, @@ -1112,6 +3362,8 @@ describe("TicketsClient", () => { ticket_state: "submitted", created_at: 1734537951, updated_at: 1734537951, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", @@ -1132,6 +3384,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -1140,6 +3397,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1160,6 +3419,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, updated_attribute_data: { attribute: { type: "attribute", @@ -1180,6 +3444,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1200,6 +3466,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, updated_attribute_data: { attribute: { type: "attribute", @@ -1222,6 +3493,8 @@ describe("TicketsClient", () => { ticket_state: "in_progress", created_at: 1734537954, updated_at: 1734537954, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1242,6 +3515,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -1254,6 +3532,8 @@ describe("TicketsClient", () => { type: "admin", id: "991268013", }, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", @@ -1274,6 +3554,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -1282,6 +3567,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537955, updated_at: 1734537955, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1302,15 +3589,21 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 6, }, is_shared: false, + previous_ticket_state_id: "7493", }); }); - test("updateTicket (2)", async () => { + test("updateTicket (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -1361,8 +3654,8 @@ describe("TicketsClient", () => { }, ], }, - admin_assignee_id: "991268013", - team_assignee_id: "0", + admin_assignee_id: 991268013, + team_assignee_id: 0, created_at: 1734537950, updated_at: 1734537955, open: true, @@ -1380,6 +3673,8 @@ describe("TicketsClient", () => { ticket_state: "submitted", created_at: 1734537951, updated_at: 1734537951, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, attachments: [ { @@ -1395,6 +3690,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -1403,6 +3699,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1423,6 +3721,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, updated_attribute_data: { attribute: { type: "attribute", id: "10", label: "Photo" }, value: { type: "value", id: [2], label: ["photo.png"] }, @@ -1435,6 +3734,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1455,6 +3756,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, updated_attribute_data: { attribute: { type: "attribute", id: "7", label: "Progress" }, value: { type: "value", id: "Fast", label: "Fast" }, @@ -1469,6 +3771,8 @@ describe("TicketsClient", () => { ticket_state: "in_progress", created_at: 1734537954, updated_at: 1734537954, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1489,6 +3793,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -1498,6 +3803,8 @@ describe("TicketsClient", () => { created_at: 1734537954, updated_at: 1734537954, assigned_to: { type: "admin", id: "991268013" }, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, attachments: [ { @@ -1513,6 +3820,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -1521,6 +3829,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537955, updated_at: 1734537955, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1541,11 +3851,13 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 6, }, is_shared: false, + previous_ticket_state_id: "7493", }; server .mockEndpoint() @@ -1556,7 +3868,7 @@ describe("TicketsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.updateTicket({ + const response = await client.preview.tickets.updateTicket({ id: "id", ticket_attributes: { _default_title_: "example", @@ -1612,8 +3924,8 @@ describe("TicketsClient", () => { }, ], }, - admin_assignee_id: "991268013", - team_assignee_id: "0", + admin_assignee_id: 991268013, + team_assignee_id: 0, created_at: 1734537950, updated_at: 1734537955, open: true, @@ -1640,6 +3952,8 @@ describe("TicketsClient", () => { ticket_state: "submitted", created_at: 1734537951, updated_at: 1734537951, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", @@ -1660,6 +3974,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -1668,6 +3987,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1688,6 +4009,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, updated_attribute_data: { attribute: { type: "attribute", @@ -1708,6 +4034,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1728,6 +4056,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, updated_attribute_data: { attribute: { type: "attribute", @@ -1750,6 +4083,8 @@ describe("TicketsClient", () => { ticket_state: "in_progress", created_at: 1734537954, updated_at: 1734537954, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1770,6 +4105,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -1782,6 +4122,8 @@ describe("TicketsClient", () => { type: "admin", id: "991268013", }, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", @@ -1802,6 +4144,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -1810,6 +4157,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537955, updated_at: 1734537955, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1830,15 +4179,21 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 6, }, is_shared: false, + previous_ticket_state_id: "7493", }); }); - test("updateTicket (3)", async () => { + test("updateTicket (4)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -1846,12 +4201,7 @@ describe("TicketsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state_id: "123", - admin_id: 991268011, - assignee_id: "123", - }; + const rawRequestBody = { ticket_state_id: "123" }; const rawResponseBody = { type: "ticket", id: "627", @@ -1889,8 +4239,8 @@ describe("TicketsClient", () => { }, ], }, - admin_assignee_id: "991268013", - team_assignee_id: "0", + admin_assignee_id: 991268013, + team_assignee_id: 0, created_at: 1734537950, updated_at: 1734537955, open: true, @@ -1908,6 +4258,8 @@ describe("TicketsClient", () => { ticket_state: "submitted", created_at: 1734537951, updated_at: 1734537951, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, attachments: [ { @@ -1923,6 +4275,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -1931,6 +4284,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1951,6 +4306,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, updated_attribute_data: { attribute: { type: "attribute", id: "10", label: "Photo" }, value: { type: "value", id: [2], label: ["photo.png"] }, @@ -1963,6 +4319,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -1983,6 +4341,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, updated_attribute_data: { attribute: { type: "attribute", id: "7", label: "Progress" }, value: { type: "value", id: "Fast", label: "Fast" }, @@ -1997,6 +4356,8 @@ describe("TicketsClient", () => { ticket_state: "in_progress", created_at: 1734537954, updated_at: 1734537954, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -2017,6 +4378,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -2026,6 +4388,8 @@ describe("TicketsClient", () => { created_at: 1734537954, updated_at: 1734537954, assigned_to: { type: "admin", id: "991268013" }, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, attachments: [ { @@ -2041,6 +4405,7 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, { type: "ticket_part", @@ -2049,6 +4414,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537955, updated_at: 1734537955, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -2069,11 +4436,13 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 6, }, is_shared: false, + previous_ticket_state_id: "7493", }; server .mockEndpoint() @@ -2084,15 +4453,9 @@ describe("TicketsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.updateTicket({ + const response = await client.preview.tickets.updateTicket({ id: "id", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, ticket_state_id: "123", - admin_id: 991268011, - assignee_id: "123", }); expect(response).toEqual({ type: "ticket", @@ -2140,8 +4503,8 @@ describe("TicketsClient", () => { }, ], }, - admin_assignee_id: "991268013", - team_assignee_id: "0", + admin_assignee_id: 991268013, + team_assignee_id: 0, created_at: 1734537950, updated_at: 1734537955, open: true, @@ -2168,6 +4531,8 @@ describe("TicketsClient", () => { ticket_state: "submitted", created_at: 1734537951, updated_at: 1734537951, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", @@ -2188,6 +4553,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -2196,6 +4566,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -2216,6 +4588,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, updated_attribute_data: { attribute: { type: "attribute", @@ -2236,6 +4613,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537953, updated_at: 1734537953, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -2256,6 +4635,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, updated_attribute_data: { attribute: { type: "attribute", @@ -2278,6 +4662,8 @@ describe("TicketsClient", () => { ticket_state: "in_progress", created_at: 1734537954, updated_at: 1734537954, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -2298,6 +4684,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "test-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -2310,6 +4701,8 @@ describe("TicketsClient", () => { type: "admin", id: "991268013", }, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268011", @@ -2330,6 +4723,11 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, { type: "ticket_part", @@ -2338,6 +4736,8 @@ describe("TicketsClient", () => { body: "

Okay!

", created_at: 1734537955, updated_at: 1734537955, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", id: "991268012", @@ -2358,15 +4758,173 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 6, }, is_shared: false, + previous_ticket_state_id: "7493", + }); + }); + + test("updateTicket (5)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/tickets/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.updateTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.BadRequestError); + }); + + test("updateTicket (6)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/tickets/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.updateTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("updateTicket (7)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .put("/tickets/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.updateTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("updateTicket (8)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/tickets/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.updateTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("updateTicket (9)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/tickets/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.preview.tickets.updateTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnprocessableEntityError); + }); + + test("deleteTicket (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "632", object: "ticket", deleted: true }; + server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.preview.tickets.deleteTicket({ + id: "id", + }); + expect(response).toEqual({ + id: "632", + object: "ticket", + deleted: true, }); }); - test("updateTicket (4)", async () => { + test("deleteTicket (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -2374,209 +4932,121 @@ describe("TicketsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = { ticket_state_id: "123" }; + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.tickets.deleteTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); + }); + + test("deleteTicket (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; + server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.tickets.deleteTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.ForbiddenError); + }); + + test("deleteTicket (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.preview.tickets.deleteTicket({ + id: "id", + }); + }).rejects.toThrow(Intercom.preview.NotFoundError); + }); + + test("changeTicketType (1)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { ticket_type_id: "1234", ticket_state_id: "5678" }; const rawResponseBody = { type: "ticket", - id: "627", - ticket_id: "34", + id: "494", + ticket_id: "53", category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, + ticket_attributes: { _default_title_: "example", _default_description_: "having a problem" }, ticket_state: { type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", + id: "12", + category: "submitted", + internal_label: "With Dev Team", + external_label: "In Progress", }, ticket_type: { type: "ticket_type", - id: "90", + id: "1234", category: "Back-office", - name: "my-ticket-type-25", + name: "my-new-ticket-type", description: "my ticket type description is awesome.", icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", + workspace_id: "this_is_an_id664_that_should_be_at_least_", ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, ticket_states: { type: "list", data: [] }, archived: false, - created_at: 1734537948, - updated_at: 1734537948, + created_at: 1719493065, + updated_at: 1719493065, }, contacts: { type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], + contacts: [{ type: "contact", id: "667d61c88a68186f43bafe93", external_id: "71" }], }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, + admin_assignee_id: 0, + team_assignee_id: 0, + created_at: 1719493065, + updated_at: 1719493068, open: true, - snoozed_until: 1734627600, + snoozed_until: 1663597260, linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ { type: "ticket_part", - id: "176", + id: "136", part_type: "ticket_state_updated_by_admin", body: "

Okay!

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

Okay!

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

Okay!

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

Okay!

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

Okay!

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

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, + created_at: 1719493065, + updated_at: 1719493065, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", + id: "991267920", + name: "Operator", + email: "operator+this_is_an_id664_that_should_be_at_least_@intercom.io", }, attachments: [ { @@ -2592,49 +5062,52 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], - total_count: 6, + total_count: 1, }, is_shared: false, + previous_ticket_state_id: "7493", }; server .mockEndpoint() - .put("/tickets/id") + .post("/tickets/ticket_id/change_type") .jsonBody(rawRequestBody) .respondWith() .statusCode(200) .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.updateTicket({ - id: "id", - ticket_state_id: "123", + const response = await client.preview.tickets.changeTicketType({ + ticket_id: "ticket_id", + ticket_type_id: "1234", + ticket_state_id: "5678", }); expect(response).toEqual({ type: "ticket", - id: "627", - ticket_id: "34", + id: "494", + ticket_id: "53", category: "Back-office", ticket_attributes: { _default_title_: "example", - _default_description_: "there is a problem", + _default_description_: "having a problem", }, ticket_state: { type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", + id: "12", + category: "submitted", + internal_label: "With Dev Team", + external_label: "In Progress", }, ticket_type: { type: "ticket_type", - id: "90", + id: "1234", category: "Back-office", - name: "my-ticket-type-25", + name: "my-new-ticket-type", description: "my ticket type description is awesome.", icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", + workspace_id: "this_is_an_id664_that_should_be_at_least_", ticket_type_attributes: { type: "list", ticket_type_attributes: [], @@ -2644,25 +5117,25 @@ describe("TicketsClient", () => { data: [], }, archived: false, - created_at: 1734537948, - updated_at: 1734537948, + created_at: 1719493065, + updated_at: 1719493065, }, contacts: { type: "contact.list", contacts: [ { type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", + id: "667d61c88a68186f43bafe93", + external_id: "71", }, ], }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, + admin_assignee_id: 0, + team_assignee_id: 0, + created_at: 1719493065, + updated_at: 1719493068, open: true, - snoozed_until: 1734627600, + snoozed_until: 1663597260, linked_objects: { type: "list", total_count: 0, @@ -2678,160 +5151,20 @@ describe("TicketsClient", () => { ticket_parts: [ { type: "ticket_part", - id: "176", + id: "136", part_type: "ticket_state_updated_by_admin", body: "

Okay!

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

Okay!

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

Okay!

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

Okay!

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

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", + id: "991267920", + name: "Operator", + email: "operator+this_is_an_id664_that_should_be_at_least_@intercom.io", }, attachments: [ { @@ -2847,43 +5180,21 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", }, ], - total_count: 6, + total_count: 1, }, is_shared: false, + previous_ticket_state_id: "7493", }); }); - test("updateTicket (5)", async () => { + test("changeTicketType (2)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -2891,11 +5202,11 @@ describe("TicketsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = {}; + const rawRequestBody = { ticket_type_id: "ticket_type_id", ticket_state_id: "ticket_state_id" }; const rawResponseBody = { key: "value" }; server .mockEndpoint() - .put("/tickets/id") + .post("/tickets/ticket_id/change_type") .jsonBody(rawRequestBody) .respondWith() .statusCode(400) @@ -2903,13 +5214,15 @@ describe("TicketsClient", () => { .build(); await expect(async () => { - return await client.unstable.tickets.updateTicket({ - id: "id", + return await client.preview.tickets.changeTicketType({ + ticket_id: "ticket_id", + ticket_type_id: "ticket_type_id", + ticket_state_id: "ticket_state_id", }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); + }).rejects.toThrow(Intercom.preview.BadRequestError); }); - test("updateTicket (6)", async () => { + test("changeTicketType (3)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -2917,11 +5230,11 @@ describe("TicketsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = {}; + const rawRequestBody = { ticket_type_id: "ticket_type_id", ticket_state_id: "ticket_state_id" }; const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; server .mockEndpoint() - .put("/tickets/id") + .post("/tickets/ticket_id/change_type") .jsonBody(rawRequestBody) .respondWith() .statusCode(401) @@ -2929,13 +5242,15 @@ describe("TicketsClient", () => { .build(); await expect(async () => { - return await client.unstable.tickets.updateTicket({ - id: "id", + return await client.preview.tickets.changeTicketType({ + ticket_id: "ticket_id", + ticket_type_id: "ticket_type_id", + ticket_state_id: "ticket_state_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); - test("updateTicket (7)", async () => { + test("changeTicketType (4)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -2943,11 +5258,11 @@ describe("TicketsClient", () => { version: "2.14", environment: server.baseUrl, }); - const rawRequestBody = {}; + const rawRequestBody = { ticket_type_id: "ticket_type_id", ticket_state_id: "ticket_state_id" }; const rawResponseBody = { key: "value" }; server .mockEndpoint() - .put("/tickets/id") + .post("/tickets/ticket_id/change_type") .jsonBody(rawRequestBody) .respondWith() .statusCode(404) @@ -2955,70 +5270,12 @@ describe("TicketsClient", () => { .build(); await expect(async () => { - return await client.unstable.tickets.updateTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "632", object: "ticket", deleted: true }; - server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.tickets.deleteTicket({ - id: "id", - }); - expect(response).toEqual({ - id: "632", - object: "ticket", - deleted: true, - }); - }); - - test("deleteTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tickets.deleteTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tickets.deleteTicket({ - id: "id", + return await client.preview.tickets.changeTicketType({ + ticket_id: "ticket_id", + ticket_type_id: "ticket_type_id", + ticket_state_id: "ticket_state_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("searchTickets", async () => { @@ -3072,8 +5329,8 @@ describe("TicketsClient", () => { }, ], }, - admin_assignee_id: "0", - team_assignee_id: "0", + admin_assignee_id: 0, + team_assignee_id: 0, created_at: 1734537990, updated_at: 1734537992, open: true, @@ -3091,6 +5348,8 @@ describe("TicketsClient", () => { ticket_state: "submitted", created_at: 1734537991, updated_at: 1734537991, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268079", @@ -3111,11 +5370,13 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { original: "en", en: "

Hello

", fr: "

Bonjour

" }, }, ], total_count: 1, }, is_shared: false, + previous_ticket_state_id: "7493", }, ], total_count: 1, @@ -3136,7 +5397,7 @@ describe("TicketsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.tickets.searchTickets({ + const response = await client.preview.tickets.searchTickets({ query: { operator: "AND", value: [ @@ -3194,8 +5455,8 @@ describe("TicketsClient", () => { }, ], }, - admin_assignee_id: "0", - team_assignee_id: "0", + admin_assignee_id: 0, + team_assignee_id: 0, created_at: 1734537990, updated_at: 1734537992, open: true, @@ -3222,6 +5483,8 @@ describe("TicketsClient", () => { ticket_state: "submitted", created_at: 1734537991, updated_at: 1734537991, + admin_assignee_id: 991268013, + team_assignee_id: 5017691, author: { type: "admin", id: "991268079", @@ -3242,11 +5505,17 @@ describe("TicketsClient", () => { external_id: "abcd1234", redacted: false, app_package_code: "text-integration", + translations: { + original: "en", + en: "

Hello

", + fr: "

Bonjour

", + }, }, ], total_count: 1, }, is_shared: false, + previous_ticket_state_id: "7493", }, ], total_count: 1, diff --git a/tests/wire/unstable/visitors.test.ts b/tests/wire/preview/visitors.test.ts similarity index 95% rename from tests/wire/unstable/visitors.test.ts rename to tests/wire/preview/visitors.test.ts index b9c5c9b0..a585fd87 100644 --- a/tests/wire/unstable/visitors.test.ts +++ b/tests/wire/preview/visitors.test.ts @@ -85,7 +85,7 @@ describe("VisitorsClient", () => { }; server.mockEndpoint().get("/visitors").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.unstable.visitors.retrieveVisitorWithUserId({ + const response = await client.preview.visitors.retrieveVisitorWithUserId({ user_id: "user_id", }); expect(response).toEqual({ @@ -191,10 +191,10 @@ describe("VisitorsClient", () => { server.mockEndpoint().get("/visitors").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.visitors.retrieveVisitorWithUserId({ + return await client.preview.visitors.retrieveVisitorWithUserId({ user_id: "user_id", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("retrieveVisitorWithUserId (3)", async () => { @@ -210,10 +210,10 @@ describe("VisitorsClient", () => { server.mockEndpoint().get("/visitors").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { - return await client.unstable.visitors.retrieveVisitorWithUserId({ + return await client.preview.visitors.retrieveVisitorWithUserId({ user_id: "user_id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("updateVisitor (1)", async () => { @@ -306,7 +306,7 @@ describe("VisitorsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.visitors.updateVisitor({ + const response = await client.preview.visitors.updateVisitor({ id: "6762f30c1bb69f9f2193bc5e", name: "Gareth Bale", }); @@ -490,7 +490,7 @@ describe("VisitorsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.visitors.updateVisitor({ + const response = await client.preview.visitors.updateVisitor({ user_id: "fail", name: "Christian Fail", }); @@ -604,10 +604,10 @@ describe("VisitorsClient", () => { .build(); await expect(async () => { - return await client.unstable.visitors.updateVisitor({ + return await client.preview.visitors.updateVisitor({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); test("updateVisitor (4)", async () => { @@ -630,10 +630,10 @@ describe("VisitorsClient", () => { .build(); await expect(async () => { - return await client.unstable.visitors.updateVisitor({ + return await client.preview.visitors.updateVisitor({ key: "value", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); test("convertVisitor (1)", async () => { @@ -660,7 +660,7 @@ describe("VisitorsClient", () => { phone: "+1123456789", formatted_phone: "+1123456789", name: "John Doe", - owner_id: 123, + owner_id: "321", has_hard_bounced: false, marked_email_as_spam: false, unsubscribed_from_emails: false, @@ -713,6 +713,14 @@ describe("VisitorsClient", () => { social_profiles: { data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], }; server .mockEndpoint() @@ -723,7 +731,7 @@ describe("VisitorsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.visitors.convertVisitor({ + const response = await client.preview.visitors.convertVisitor({ type: "user", user: { email: "foo@bar.com", @@ -743,7 +751,7 @@ describe("VisitorsClient", () => { phone: "+1123456789", formatted_phone: "+1123456789", name: "John Doe", - owner_id: 123, + owner_id: "321", has_hard_bounced: false, marked_email_as_spam: false, unsubscribed_from_emails: false, @@ -829,6 +837,14 @@ describe("VisitorsClient", () => { }, ], }, + merge_history: [ + { + type: "merge_history", + source_contact_id: "5ba682d23d7cf92bef87bfd3", + source_contact_role: "lead", + merged_at: 1571672154, + }, + ], }); }); @@ -852,7 +868,7 @@ describe("VisitorsClient", () => { .build(); await expect(async () => { - return await client.unstable.visitors.convertVisitor({ + return await client.preview.visitors.convertVisitor({ type: "type", user: { key: "value", @@ -861,6 +877,6 @@ describe("VisitorsClient", () => { key: "value", }, }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); + }).rejects.toThrow(Intercom.preview.UnauthorizedError); }); }); diff --git a/tests/wire/unstable/workflows.test.ts b/tests/wire/preview/workflows.test.ts similarity index 92% rename from tests/wire/unstable/workflows.test.ts rename to tests/wire/preview/workflows.test.ts index b4035d7f..9575b63d 100644 --- a/tests/wire/unstable/workflows.test.ts +++ b/tests/wire/preview/workflows.test.ts @@ -42,7 +42,7 @@ describe("WorkflowsClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.unstable.workflows.exportWorkflow({ + const response = await client.preview.workflows.exportWorkflow({ id: "12345", }); expect(response).toEqual({ @@ -98,10 +98,10 @@ describe("WorkflowsClient", () => { .build(); await expect(async () => { - return await client.unstable.workflows.exportWorkflow({ + return await client.preview.workflows.exportWorkflow({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); + }).rejects.toThrow(Intercom.preview.ForbiddenError); }); test("exportWorkflow (3)", async () => { @@ -123,9 +123,9 @@ describe("WorkflowsClient", () => { .build(); await expect(async () => { - return await client.unstable.workflows.exportWorkflow({ + return await client.preview.workflows.exportWorkflow({ id: "id", }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); + }).rejects.toThrow(Intercom.preview.NotFoundError); }); }); diff --git a/tests/wire/export.test.ts b/tests/wire/reportingDataExport.test.ts similarity index 93% rename from tests/wire/export.test.ts rename to tests/wire/reportingDataExport.test.ts index c7ff75eb..ba19ef61 100644 --- a/tests/wire/export.test.ts +++ b/tests/wire/reportingDataExport.test.ts @@ -4,7 +4,7 @@ import * as Intercom from "../../src/api/index"; import { IntercomClient } from "../../src/Client"; import { mockServerPool } from "../mock-server/MockServerPool"; -describe("ExportClient", () => { +describe("ReportingDataExportClient", () => { test("enqueueANewReportingDataExportJob (1)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ @@ -34,7 +34,7 @@ describe("ExportClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.export.enqueueANewReportingDataExportJob({ + const response = await client.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "conversation", attribute_ids: ["conversation_id", "conversation_started_at"], start_time: 1717490000, @@ -73,7 +73,7 @@ describe("ExportClient", () => { .build(); await expect(async () => { - return await client.export.enqueueANewReportingDataExportJob({ + return await client.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "dataset_id", attribute_ids: ["attribute_ids", "attribute_ids"], start_time: 1000000, @@ -107,7 +107,7 @@ describe("ExportClient", () => { .build(); await expect(async () => { - return await client.export.enqueueANewReportingDataExportJob({ + return await client.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "dataset_id", attribute_ids: ["attribute_ids", "attribute_ids"], start_time: 1000000, @@ -141,7 +141,7 @@ describe("ExportClient", () => { .build(); await expect(async () => { - return await client.export.enqueueANewReportingDataExportJob({ + return await client.reportingDataExport.enqueueANewReportingDataExportJob({ dataset_id: "dataset_id", attribute_ids: ["attribute_ids", "attribute_ids"], start_time: 1000000, @@ -179,7 +179,7 @@ describe("ExportClient", () => { .jsonBody(rawResponseBody) .build(); - const response = await client.export.listAvailableDatasetsAndAttributes(); + const response = await client.reportingDataExport.listAvailableDatasetsAndAttributes(); expect(response).toEqual({ type: "list", data: [ diff --git a/tests/wire/tags.test.ts b/tests/wire/tags.test.ts index b31a212b..1812fc44 100644 --- a/tests/wire/tags.test.ts +++ b/tests/wire/tags.test.ts @@ -19,7 +19,7 @@ describe("TagsClient", () => { id: "81", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -40,8 +40,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -60,7 +60,7 @@ describe("TagsClient", () => { id: "81", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -81,8 +81,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -101,7 +101,7 @@ describe("TagsClient", () => { id: "81", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -122,8 +122,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -196,7 +196,7 @@ describe("TagsClient", () => { id: "84", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -216,8 +216,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -288,7 +288,7 @@ describe("TagsClient", () => { id: "86", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -310,8 +310,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -330,7 +330,7 @@ describe("TagsClient", () => { id: "86", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -352,8 +352,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -428,7 +428,7 @@ describe("TagsClient", () => { id: "89", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -450,8 +450,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -470,7 +470,7 @@ describe("TagsClient", () => { id: "89", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -492,8 +492,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -512,7 +512,7 @@ describe("TagsClient", () => { id: "89", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -534,8 +534,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -663,13 +663,7 @@ describe("TagsClient", () => { environment: server.baseUrl, }); const rawRequestBody = { name: "test" }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; + const rawResponseBody = { type: "tag", id: "105", name: "test" }; server .mockEndpoint() .post("/tags") @@ -686,11 +680,6 @@ describe("TagsClient", () => { type: "tag", id: "105", name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, }); }); @@ -703,13 +692,7 @@ describe("TagsClient", () => { environment: server.baseUrl, }); const rawRequestBody = { name: "Independent" }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; + const rawResponseBody = { type: "tag", id: "105", name: "test" }; server .mockEndpoint() .post("/tags") @@ -726,11 +709,6 @@ describe("TagsClient", () => { type: "tag", id: "105", name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, }); }); @@ -743,13 +721,7 @@ describe("TagsClient", () => { environment: server.baseUrl, }); const rawRequestBody = { name: "test", companies: [{ company_id: "123" }] }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; + const rawResponseBody = { type: "tag", id: "105", name: "test" }; server .mockEndpoint() .post("/tags") @@ -771,11 +743,6 @@ describe("TagsClient", () => { type: "tag", id: "105", name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, }); }); @@ -788,13 +755,7 @@ describe("TagsClient", () => { environment: server.baseUrl, }); const rawRequestBody = { name: "test", users: [{ id: "123" }] }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; + const rawResponseBody = { type: "tag", id: "105", name: "test" }; server .mockEndpoint() .post("/tags") @@ -816,11 +777,6 @@ describe("TagsClient", () => { type: "tag", id: "105", name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, }); }); @@ -911,13 +867,7 @@ describe("TagsClient", () => { environment: server.baseUrl, }); - const rawResponseBody = { - type: "tag", - id: "113", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; + const rawResponseBody = { type: "tag", id: "113", name: "Manual tag" }; server.mockEndpoint().get("/tags/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); const response = await client.tags.find({ @@ -927,11 +877,6 @@ describe("TagsClient", () => { type: "tag", id: "113", name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, }); }); @@ -1061,7 +1006,7 @@ describe("TagsClient", () => { id: "121", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1083,8 +1028,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1103,7 +1048,7 @@ describe("TagsClient", () => { id: "121", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1125,8 +1070,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1201,7 +1146,7 @@ describe("TagsClient", () => { id: "124", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1223,8 +1168,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1243,7 +1188,7 @@ describe("TagsClient", () => { id: "124", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1265,8 +1210,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); @@ -1285,7 +1230,7 @@ describe("TagsClient", () => { id: "124", name: "Manual tag", applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, + applied_by: { type: "admin", id: "456" }, }; server .mockEndpoint() @@ -1307,8 +1252,8 @@ describe("TagsClient", () => { name: "Manual tag", applied_at: 1663597223, applied_by: { - type: "contact", - id: "1a2b3c", + type: "admin", + id: "456", }, }); }); diff --git a/tests/wire/tickets.test.ts b/tests/wire/tickets.test.ts index 928f3523..d4b72122 100644 --- a/tests/wire/tickets.test.ts +++ b/tests/wire/tickets.test.ts @@ -168,6 +168,89 @@ describe("TicketsClient", () => { }); test("reply (3)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawRequestBody = { + message_type: "note", + type: "admin", + body: "This note will be cross-posted to all linked conversations.", + admin_id: "3156780", + cross_post: true, + }; + const rawResponseBody = { + type: "ticket_part", + id: "156", + part_type: "note", + body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", + created_at: 1734537884, + updated_at: 1734537884, + author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + redacted: false, + }; + server + .mockEndpoint() + .post("/tickets/123/reply") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.tickets.reply({ + ticket_id: "123", + body: { + message_type: "note", + type: "admin", + body: "This note will be cross-posted to all linked conversations.", + admin_id: "3156780", + cross_post: true, + }, + }); + expect(response).toEqual({ + type: "ticket_part", + id: "156", + part_type: "note", + body: "

An Unordered HTML List

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

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", + created_at: 1734537884, + updated_at: 1734537884, + author: { + type: "admin", + id: "991267943", + name: "Ciaran419 Lee", + email: "admin419@email.com", + }, + attachments: [ + { + type: "upload", + name: "example.png", + url: "https://picsum.photos/200/300", + content_type: "image/png", + filesize: 100, + width: 100, + height: 100, + }, + ], + redacted: false, + }); + }); + + test("reply (4)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -260,7 +343,7 @@ describe("TicketsClient", () => { }); }); - test("reply (4)", async () => { + test("reply (5)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -341,7 +424,7 @@ describe("TicketsClient", () => { }); }); - test("reply (5)", async () => { + test("reply (6)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -422,7 +505,7 @@ describe("TicketsClient", () => { }); }); - test("reply (6)", async () => { + test("reply (7)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -503,7 +586,7 @@ describe("TicketsClient", () => { }); }); - test("reply (7)", async () => { + test("reply (8)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -540,7 +623,7 @@ describe("TicketsClient", () => { }).rejects.toThrow(Intercom.BadRequestError); }); - test("reply (8)", async () => { + test("reply (9)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -577,7 +660,7 @@ describe("TicketsClient", () => { }).rejects.toThrow(Intercom.UnauthorizedError); }); - test("reply (9)", async () => { + test("reply (10)", async () => { const server = mockServerPool.createServer(); const client = new IntercomClient({ maxRetries: 0, @@ -660,7 +743,7 @@ describe("TicketsClient", () => { updated_at: 1734537946, open: true, snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -774,6 +857,7 @@ describe("TicketsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -1018,7 +1102,7 @@ describe("TicketsClient", () => { updated_at: 1734537976, open: true, snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -1117,6 +1201,7 @@ describe("TicketsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -1239,7 +1324,7 @@ describe("TicketsClient", () => { updated_at: 1734537955, open: true, snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -1498,6 +1583,7 @@ describe("TicketsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -1769,7 +1855,7 @@ describe("TicketsClient", () => { updated_at: 1734537955, open: true, snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -2026,6 +2112,7 @@ describe("TicketsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -2297,7 +2384,7 @@ describe("TicketsClient", () => { updated_at: 1734537955, open: true, snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -2554,6 +2641,7 @@ describe("TicketsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -2820,7 +2908,7 @@ describe("TicketsClient", () => { updated_at: 1734537955, open: true, snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ type: "ticket", id: "7583" }] }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -3071,6 +3159,7 @@ describe("TicketsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], @@ -3425,6 +3514,31 @@ describe("TicketsClient", () => { environment: server.baseUrl, }); + const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; + server + .mockEndpoint() + .delete("/tickets/ticket_id") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.tickets.deleteTicket({ + ticket_id: "ticket_id", + }); + }).rejects.toThrow(Intercom.ForbiddenError); + }); + + test("deleteTicket (4)", async () => { + const server = mockServerPool.createServer(); + const client = new IntercomClient({ + maxRetries: 0, + token: "test", + version: "2.14", + environment: server.baseUrl, + }); + const rawResponseBody = { key: "value" }; server .mockEndpoint() @@ -3498,7 +3612,12 @@ describe("TicketsClient", () => { updated_at: 1734537992, open: true, snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, + linked_objects: { + type: "list", + total_count: 0, + has_more: false, + data: [{ type: "ticket", id: "7583" }], + }, ticket_parts: { type: "ticket_part.list", ticket_parts: [ @@ -3611,6 +3730,7 @@ describe("TicketsClient", () => { has_more: false, data: [ { + type: "ticket", id: "7583", }, ], diff --git a/tests/wire/unstable/admins.test.ts b/tests/wire/unstable/admins.test.ts deleted file mode 100644 index 15a2ae87..00000000 --- a/tests/wire/unstable/admins.test.ts +++ /dev/null @@ -1,644 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("AdminsClient", () => { - test("identifyAdmin", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin", - id: "991267459", - name: "Ciaran1 Lee", - email: "admin1@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/assets/default-avatars/admins/128.png", - }, - email_verified: true, - app: { - type: "app", - id_code: "this_is_an_id1_that_should_be_at_least_40", - name: "MyApp 1", - region: "US", - timezone: "America/Los_Angeles", - created_at: 1734537243, - identity_verification: false, - }, - }; - server.mockEndpoint().get("/me").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.admins.identifyAdmin(); - expect(response).toEqual({ - type: "admin", - id: "991267459", - name: "Ciaran1 Lee", - email: "admin1@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/assets/default-avatars/admins/128.png", - }, - email_verified: true, - app: { - type: "app", - id_code: "this_is_an_id1_that_should_be_at_least_40", - name: "MyApp 1", - region: "US", - timezone: "America/Los_Angeles", - created_at: 1734537243, - identity_verification: false, - }, - }); - }); - - test("setAwayAdmin (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true, away_status_reason_id: 12345 }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("setAwayAdmin (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("setAwayAdmin (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("setAwayAdmin (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("setAwayAdmin (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("setAwayAdmin (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listActivityLogs (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "activity_log.list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 20, - total_pages: 1, - }, - activity_logs: [ - { - id: "fca05814-4b72-4dce-ad4f-77a786a2c136", - performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "😌 On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - }, - created_at: 1734537253, - activity_type: "app_name_change", - activity_description: "Ciaran5 Lee changed your app name from before to after.", - }, - { - id: "f48c653b-0185-48ac-a276-23d11006bafb", - performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "😌 On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - }, - created_at: 1734537253, - activity_type: "message_state_change", - activity_description: - "Ciaran5 Lee changed your Initial message title message from Initial message title to Eventual message title.", - }, - ], - }; - server - .mockEndpoint() - .get("/admins/activity_logs") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.admins.listActivityLogs({ - created_at_after: "1677253093", - created_at_before: "1677861493", - }); - expect(response).toEqual({ - type: "activity_log.list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 20, - total_pages: 1, - }, - activity_logs: [ - { - id: "fca05814-4b72-4dce-ad4f-77a786a2c136", - performed_by: { - type: "admin", - id: "991267464", - email: "admin5@email.com", - ip: "127.0.0.1", - }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "\uD83D\uDE0C On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - }, - created_at: 1734537253, - activity_type: "app_name_change", - activity_description: "Ciaran5 Lee changed your app name from before to after.", - }, - { - id: "f48c653b-0185-48ac-a276-23d11006bafb", - performed_by: { - type: "admin", - id: "991267464", - email: "admin5@email.com", - ip: "127.0.0.1", - }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "\uD83D\uDE0C On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - }, - created_at: 1734537253, - activity_type: "message_state_change", - activity_description: - "Ciaran5 Lee changed your Initial message title message from Initial message title to Eventual message title.", - }, - ], - }); - }); - - test("listActivityLogs (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/admins/activity_logs") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.admins.listActivityLogs({ - created_at_after: "created_at_after", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listAdmins (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin.list", - admins: [ - { - type: "admin", - id: "991267466", - name: "Ciaran7 Lee", - email: "admin7@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - ], - }; - server.mockEndpoint().get("/admins").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.admins.listAdmins(); - expect(response).toEqual({ - type: "admin.list", - admins: [ - { - type: "admin", - id: "991267466", - name: "Ciaran7 Lee", - email: "admin7@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - ], - }); - }); - - test("listAdmins (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/admins").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.admins.listAdmins(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveAdmin (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin", - id: "991267468", - name: "Ciaran9 Lee", - email: "admin9@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.admins.retrieveAdmin({ - id: 1, - }); - expect(response).toEqual({ - type: "admin", - id: "991267468", - name: "Ciaran9 Lee", - email: "admin9@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("retrieveAdmin (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.admins.retrieveAdmin({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveAdmin (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.admins.retrieveAdmin({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/articles.test.ts b/tests/wire/unstable/articles.test.ts deleted file mode 100644 index 20562566..00000000 --- a/tests/wire/unstable/articles.test.ts +++ /dev/null @@ -1,2141 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("ArticlesClient", () => { - test("listArticles (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 25, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "article", - id: "39", - workspace_id: "this_is_an_id64_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267492, - state: "published", - created_at: 1734537283, - updated_at: 1734537283, - url: "http://help-center.test/myapp-64/en/articles/39-this-is-the-article-title", - parent_id: 143, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - }; - server.mockEndpoint().get("/articles").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.articles.listArticles(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 25, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "article", - id: "39", - workspace_id: "this_is_an_id64_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267492, - state: "published", - created_at: 1734537283, - updated_at: 1734537283, - url: "http://help-center.test/myapp-64/en/articles/39-this-is-the-article-title", - parent_id: 143, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - }); - }); - - test("listArticles (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/articles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.listArticles(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { - statistics: { - type: "article_statistics", - views: 1, - conversions: 1, - reactions: 1, - happy_reaction_percentage: 1.1, - neutral_reaction_percentage: 1.1, - sad_reaction_percentage: 1.1, - }, - type: "article", - id: "id", - workspace_id: "workspace_id", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - parent_id: 1, - parent_ids: [1, 1], - parent_type: "parent_type", - default_locale: "default_locale", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bg: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ca: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - cs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - da: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - de: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - el: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - en: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - es: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - et: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - he: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hu: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - id: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - it: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ja: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ko: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - mn: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nb: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ro: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ru: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - tr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - vi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "pt-BR": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-CN": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-TW": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - }, - }; - server - .mockEndpoint() - .post("/articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.articles.createArticle({ - key: "value", - }); - expect(response).toEqual({ - statistics: { - type: "article_statistics", - views: 1, - conversions: 1, - reactions: 1, - happy_reaction_percentage: 1.1, - neutral_reaction_percentage: 1.1, - sad_reaction_percentage: 1.1, - }, - type: "article", - id: "id", - workspace_id: "workspace_id", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - parent_id: 1, - parent_ids: [1, 1], - parent_type: "parent_type", - default_locale: "default_locale", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bg: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ca: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - cs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - da: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - de: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - el: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - en: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - es: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - et: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - he: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hu: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - id: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - it: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ja: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ko: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - mn: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nb: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ro: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ru: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - tr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - vi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "pt-BR": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-CN": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-TW": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - }, - }); - }); - - test("createArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.articles.createArticle({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.articles.createArticle({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "article", - id: "45", - workspace_id: "this_is_an_id74_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267502, - state: "published", - created_at: 1734537292, - updated_at: 1734537292, - url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", - parent_id: 148, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.articles.retrieveArticle({ - id: 1, - }); - expect(response).toEqual({ - type: "article", - id: "45", - workspace_id: "this_is_an_id74_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267502, - state: "published", - created_at: 1734537292, - updated_at: 1734537292, - url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", - parent_id: 148, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }); - }); - - test("retrieveArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.retrieveArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.retrieveArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "51", object: "article", deleted: true }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.articles.deleteArticle({ - id: 1, - }); - expect(response).toEqual({ - id: "51", - object: "article", - deleted: true, - }); - }); - - test("deleteArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.deleteArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.deleteArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("searchArticles (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - total_count: 1, - data: { - articles: [ - { - type: "article", - id: "55", - workspace_id: "this_is_an_id92_that_should_be_at_least_4", - title: "Title 1", - description: "", - body: "", - author_id: 991267521, - state: "draft", - created_at: 1734537306, - updated_at: 1734537306, - url: "http://intercom.test/help/en/articles/3-default-language", - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - highlights: [{ article_id: "123" }], - }, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - }; - server.mockEndpoint().get("/articles/search").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.articles.searchArticles({ - phrase: "Getting started", - state: "published", - help_center_id: 1, - highlight: true, - }); - expect(response).toEqual({ - type: "list", - total_count: 1, - data: { - articles: [ - { - type: "article", - id: "55", - workspace_id: "this_is_an_id92_that_should_be_at_least_4", - title: "Title 1", - description: "", - body: "", - author_id: 991267521, - state: "draft", - created_at: 1734537306, - updated_at: 1734537306, - url: "http://intercom.test/help/en/articles/3-default-language", - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - highlights: [ - { - article_id: "123", - }, - ], - }, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - }); - }); - - test("searchArticles (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/articles/search").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.searchArticles(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/contacts.test.ts b/tests/wire/unstable/contacts.test.ts deleted file mode 100644 index 4893898e..00000000 --- a/tests/wire/unstable/contacts.test.ts +++ /dev/null @@ -1,2297 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("ContactsClient", () => { - test("listCompaniesForAContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - companies: [ - { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - total_count: 1, - pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/companies") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.listCompaniesForAContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - companies: [ - { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: "next", - per_page: 50, - total_pages: 1, - }, - }); - }); - - test("listCompaniesForAContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/id/companies") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listCompaniesForAContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listCompaniesForAContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/id/companies") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listCompaniesForAContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listSegmentsForAContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "segment", - id: "6762f0b21bb69f9f2193bb65", - name: "segment", - created_at: 1734537394, - updated_at: 1734537394, - person_type: "user", - count: 3, - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/segments") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.listSegmentsForAContact({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "segment", - id: "6762f0b21bb69f9f2193bb65", - name: "segment", - created_at: 1734537394, - updated_at: 1734537394, - person_type: "user", - count: 3, - }, - ], - }); - }); - - test("listSegmentsForAContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/segments") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listSegmentsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listSegmentsForAContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/segments") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listSegmentsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listSubscriptionsForAContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "subscription", - id: "91", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_out", - content_types: ["email"], - }, - { - type: "subscription", - id: "93", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/subscriptions") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.listSubscriptionsForAContact({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "subscription", - id: "91", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_out", - content_types: ["email"], - }, - { - type: "subscription", - id: "93", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }, - ], - }); - }); - - test("listSubscriptionsForAContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/subscriptions") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listSubscriptionsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listSubscriptionsForAContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/subscriptions") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listSubscriptionsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listTagsForAContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "tag", - id: "80", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/tags") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.listTagsForAContact({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "tag", - id: "80", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }, - ], - }); - }); - - test("listTagsForAContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/tags") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listTagsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listTagsForAContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/tags") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listTagsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("ShowContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "contact", - id: "6762f0d01bb69f9f2193bb7d", - external_id: "70", - workspace_id: "this_is_an_id283_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537424, - updated_at: 1734537424, - signed_up_at: 1734537424, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.showContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0d01bb69f9f2193bb7d", - external_id: "70", - workspace_id: "this_is_an_id283_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537424, - updated_at: 1734537424, - signed_up_at: 1734537424, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("ShowContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/contacts/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.contacts.showContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("UpdateContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { email: "joebloggs@intercom.io", name: "joe bloggs" }; - const rawResponseBody = { - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .put("/contacts/63a07ddf05a32042dffac965") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.updateContact({ - id: "63a07ddf05a32042dffac965", - email: "joebloggs@intercom.io", - name: "joe bloggs", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("UpdateContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { custom_attributes: { order: ["21"] } }; - const rawResponseBody = { - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { order_number: "ORDER-12345", total_amount: 99.99 }, - type: "Order", - }, - ], - }, - }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .put("/contacts/63a07ddf05a32042dffac965") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.updateContact({ - id: "63a07ddf05a32042dffac965", - custom_attributes: { - order: ["21"], - }, - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { - order_number: "ORDER-12345", - total_amount: 99.99, - }, - type: "Order", - }, - ], - }, - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("UpdateContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/contacts/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.updateContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("DeleteContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", deleted: true }; - server.mockEndpoint().delete("/contacts/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.contacts.deleteContact({ - id: "id", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - deleted: true, - }); - }); - - test("DeleteContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/contacts/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.contacts.deleteContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("MergeContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: "6762f0d51bb69f9f2193bb7f", into: "6762f0d51bb69f9f2193bb80" }; - const rawResponseBody = { - type: "contact", - id: "6762f0d51bb69f9f2193bb80", - external_id: "70", - workspace_id: "this_is_an_id291_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537429, - updated_at: 1734537430, - signed_up_at: 1734537429, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .post("/contacts/merge") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.mergeContact({ - from: "6762f0d51bb69f9f2193bb7f", - into: "6762f0d51bb69f9f2193bb80", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0d51bb69f9f2193bb80", - external_id: "70", - workspace_id: "this_is_an_id291_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537429, - updated_at: 1734537430, - signed_up_at: 1734537429, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("MergeContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/merge") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.mergeContact(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("SearchContacts (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, - pagination: { per_page: 5 }, - }; - const rawResponseBody = { - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, - notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 5, - total_pages: 0, - }, - }; - server - .mockEndpoint() - .post("/contacts/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.searchContacts({ - query: { - operator: "AND", - value: [ - { - field: "created_at", - operator: ">", - value: "1306054154", - }, - ], - }, - pagination: { - per_page: 5, - }, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", - total_count: 100, - has_more: true, - }, - notes: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - total_count: 100, - has_more: true, - }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 5, - total_pages: 0, - }, - }); - }); - - test("SearchContacts (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { query: {} }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.searchContacts({ - query: {}, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("ListContacts (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, - notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 0, - }, - }; - server.mockEndpoint().get("/contacts").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.contacts.listContacts(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", - total_count: 100, - has_more: true, - }, - notes: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - total_count: 100, - has_more: true, - }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 0, - }, - }); - }); - - test("ListContacts (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/contacts").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.contacts.listContacts(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("CreateContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { email: "joebloggs@intercom.io" }; - const rawResponseBody = { - type: "contact", - id: "6762f0dd1bb69f9f2193bb83", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id303_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537437, - updated_at: 1734537437, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .post("/contacts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.createContact({ - email: "joebloggs@intercom.io", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0dd1bb69f9f2193bb83", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id303_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537437, - updated_at: 1734537437, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("CreateContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.createContact({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("ShowContactByExternalId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "contact", - id: "6762f0df1bb69f9f2193bb84", - external_id: "70", - workspace_id: "this_is_an_id307_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537439, - updated_at: 1734537439, - signed_up_at: 1734537439, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .get("/contacts/find_by_external_id/cdd29344-5e0c-4ef0-ac56-f9ba2979bc27") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.showContactByExternalId({ - external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0df1bb69f9f2193bb84", - external_id: "70", - workspace_id: "this_is_an_id307_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537439, - updated_at: 1734537439, - signed_up_at: 1734537439, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("ShowContactByExternalId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/find_by_external_id/external_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.showContactByExternalId({ - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("ArchiveContact", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", archived: true }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/archive") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.archiveContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - archived: true, - }); - }); - - test("UnarchiveContact", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", archived: false }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/unarchive") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.unarchiveContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - archived: false, - }); - }); - - test("BlockContact", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", blocked: true }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/block") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.blockContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - blocked: true, - }); - }); -}); diff --git a/tests/wire/unstable/customChannelEvents.test.ts b/tests/wire/unstable/customChannelEvents.test.ts deleted file mode 100644 index bb810951..00000000 --- a/tests/wire/unstable/customChannelEvents.test.ts +++ /dev/null @@ -1,796 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("CustomChannelEventsClient", () => { - test("notifyNewConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "evt_12345", - external_conversation_id: "conv_67890", - contact: { type: "user", external_id: "user_001", name: "Jane Doe", email: "jane.doe@example.com" }, - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "evt_12345", - external_conversation_id: "conv_67890", - contact: { - type: "user", - external_id: "user_001", - name: "Jane Doe", - email: "jane.doe@example.com", - }, - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyNewConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("notifyNewConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("notifyNewConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("notifyNewConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("notifyNewMessage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "evt_54321", - external_conversation_id: "conv_98765", - contact: { type: "user", external_id: "user_002", name: "John Smith", email: "john.smith@example.com" }, - body: "Hello, I need help with my order.", - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.customChannelEvents.notifyNewMessage({ - event_id: "evt_54321", - external_conversation_id: "conv_98765", - contact: { - type: "user", - external_id: "user_002", - name: "John Smith", - email: "john.smith@example.com", - }, - body: "Hello, I need help with my order.", - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyNewMessage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("notifyNewMessage (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("notifyNewMessage (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("notifyNewMessage (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("notifyQuickReplySelected (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "evt_67890", - external_conversation_id: "conv_13579", - contact: { type: "user", external_id: "user_003", name: "Alice Example", email: "alice@example.com" }, - quick_reply_option_id: "1234", - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.customChannelEvents.notifyQuickReplySelected({ - event_id: "evt_67890", - external_conversation_id: "conv_13579", - contact: { - type: "user", - external_id: "user_003", - name: "Alice Example", - email: "alice@example.com", - }, - quick_reply_option_id: "1234", - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyQuickReplySelected (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("notifyQuickReplySelected (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("notifyQuickReplySelected (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("notifyQuickReplySelected (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("notifyAttributeCollected (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "evt_24680", - external_conversation_id: "conv_11223", - contact: { type: "user", external_id: "user_004", name: "Bob Example", email: "bob@example.com" }, - attribute: { id: "shipping_address", value: "123 Main St, Springfield" }, - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.customChannelEvents.notifyAttributeCollected({ - event_id: "evt_24680", - external_conversation_id: "conv_11223", - contact: { - type: "user", - external_id: "user_004", - name: "Bob Example", - email: "bob@example.com", - }, - attribute: { - id: "shipping_address", - value: "123 Main St, Springfield", - }, - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyAttributeCollected (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("notifyAttributeCollected (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("notifyAttributeCollected (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("notifyAttributeCollected (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); -}); From d0d9a701adf32f0ce25b9f2935b5ff8b713e16ce Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 24 Sep 2026 07:06:06 +0000 Subject: [PATCH 2/2] [fern-replay] advance lockfile --- .fern/replay.lock | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.fern/replay.lock b/.fern/replay.lock index c3d107b8..4d6e3be5 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -6,5 +6,11 @@ generations: timestamp: 2026-09-24T07:06:01.484Z cli_version: unknown generator_versions: {} -current_generation: d8a05dee0314b74d6d0bbd49caccdd680a635c1a + - commit_sha: 12e1780552a123bd80d924c5edde86f29935f0f9 + tree_hash: 00b288c374225b1ca20832a0693ff9848d2f5ba3 + timestamp: 2026-09-24T07:06:02.707Z + cli_version: unknown + generator_versions: + fernapi/fern-typescript-sdk: 3.35.8 +current_generation: 12e1780552a123bd80d924c5edde86f29935f0f9 patches: []